Chat SDK for Unity and Windows v1.3.0
Public Member Functions | Properties | List of all members
AgoraChat.SDKClient Class Reference

Public Member Functions

int InitWithOptions (Options options)
 
void CreateAccount (string userId, string password, CallBack callback=null)
 
void Login (string userId, string pwdOrToken, bool isToken=false, CallBack callback=null)
 
void LoginWithToken (string userId, string token, CallBack callback=null)
 
void Logout (bool unbindDeviceToken=true, CallBack callback=null)
 
void LoginWithAgoraToken (string userId, string token, CallBack callback=null)
 
void RenewAgoraToken (string token)
 
void RenewToken (string token)
 
void GetLoggedInDevicesFromServer (string userId, string password, ValueCallBack< List< DeviceInfo > > callback=null)
 
void GetLoggedInDevicesFromServerWithToken (string userId, string token, ValueCallBack< List< DeviceInfo > > callback=null)
 
void KickDevice (string userId, string password, string resource, CallBack callback=null)
 
void KickDeviceWithToken (string userId, string token, string resource, CallBack callback=null)
 
void KickAllDevices (string userId, string password, CallBack callback=null)
 
void KickAllDevicesWithToken (string userId, string token, CallBack callback=null)
 
void AddConnectionDelegate (IConnectionDelegate connectionDelegate)
 
void DeleteConnectionDelegate (IConnectionDelegate connectionDelegate)
 
void AddMultiDeviceDelegate (IMultiDeviceDelegate multiDeviceDelegate)
 
void DeleteMultiDeviceDelegate (IMultiDeviceDelegate multiDeviceDelegate)
 
void DeInit ()
 

Properties

static SDKClient Instance [get]
 
ChatManager ChatManager [get]
 
ContactManager ContactManager [get]
 
GroupManager GroupManager [get]
 
RoomManager RoomManager [get]
 
UserInfoManager UserInfoManager [get]
 
PresenceManager PresenceManager [get]
 
ChatThreadManager ThreadManager [get]
 
string SdkVersion [get]
 
string CurrentUsername [get]
 
bool IsLoggedIn [get]
 
bool IsConnected [get]
 
string AccessToken [get]
 

Detailed Description

The SDK client class, the entry of the chat SDK, defines how to log in to and log out of the chat app and how to manage the connection between the SDK and the chat server.

Member Function Documentation

◆ InitWithOptions()

int AgoraChat.SDKClient.InitWithOptions ( Options  options)

Initializes the SDK.

Make sure that the SDK initialization is complete before you call any methods.

Parameters
optionsThe options for SDK initialization. Ensure that you set the options. See Options.
Returns
The return result:
  • 0: Success;
  • 100: The App key is invalid.

◆ CreateAccount()

void AgoraChat.SDKClient.CreateAccount ( string  userId,
string  password,
CallBack  callback = null 
)

Creates a new user.

This method is not recommended and you are advised to call the RESTful API.

This is an asynchronous method.

Parameters
userIdThe user ID. Ensure that you set this parameter.

The user ID can contain a maximum of 64 characters of the following types:

  • 26 lowercase English letters (a-z);
  • 26 uppercase English letters (A-Z);
  • 10 numbers (0-9);
  • "_", "-", "."

The user ID is case-insensitive, so Aa and aa are the same user ID.

The email address or the UUID of the user cannot be used as the user ID.

You can also set the user ID using a regular expression in the format of ^[a-zA-Z0-9_-]+$.

Parameters
passwordThe password. The password can contain a maximum of 64 characters. Ensure that you set this parameter.
callbackThe creation result callback. See CallBack.

◆ Login()

void AgoraChat.SDKClient.Login ( string  userId,
string  pwdOrToken,
bool  isToken = false,
CallBack  callback = null 
)

Logs in to the chat server with a password or token.

This is an asynchronous method.

Parameters
userIdThe user ID. Ensure that you set this parameter.
pwdOrTokenThe password or token of the user. Ensure that you set this parameter.
isTokenWhether to log in with a token or a password.
  • true:Log in with a token.
  • (Default) false:Log in with a password.
callbackThe login result callback. See CallBack.

◆ LoginWithToken()

void AgoraChat.SDKClient.LoginWithToken ( string  userId,
string  token,
CallBack  callback = null 
)

Logs in to the chat server with a password or token.

This is an asynchronous method.

Parameters
userIdThe user ID. Ensure that you set this parameter.
tokenThe token of the user. Ensure that you set this parameter.
callbackThe login result callback. See CallBack.

◆ Logout()

void AgoraChat.SDKClient.Logout ( bool  unbindDeviceToken = true,
CallBack  callback = null 
)

Logs you out of the chat service.

This is an asynchronous method.

Parameters
unbindTokenWhether to unbind the device with the token upon logout. This parameter is valid only for mobile platforms.
  • true: Yes.
  • false: No.
callbackThe logout result callback. See CallBack.

◆ LoginWithAgoraToken()

void AgoraChat.SDKClient.LoginWithAgoraToken ( string  userId,
string  token,
CallBack  callback = null 
)

Logs in to the chat server with the user ID and an Agora token.

You can also log in to the chat server with the user ID and a password. See Login(string, string, bool, CallBack).

This an asynchronous method.

This method is obsolete; it is recommended to use the 'Login' method.

Parameters
userIdThe user ID. Ensure that you set this parameter.
tokenThe Agora token. Ensure that you set this parameter.
callbackThe login result callback. See CallBack.

◆ RenewAgoraToken()

void AgoraChat.SDKClient.RenewAgoraToken ( string  token)

Renews the Agora token.

If you log in with an Agora token and are notified by a callback method IConnectionDelegate that the token is to be expired, you can call this method to update the token to avoid unknown issues caused by an invalid token.

This method is deprecated. Use the 'RenewToken' method instead.

Parameters
tokenThe new Agora token.

◆ RenewToken()

void AgoraChat.SDKClient.RenewToken ( string  token)

Renews the token.

If you log in with a token and are notified by a callback method IConnectionDelegate that the token is to be expired, you can call this method to update the token to avoid unknown issues caused by an invalid token.

Parameters
tokenThe new token.

◆ GetLoggedInDevicesFromServer()

void AgoraChat.SDKClient.GetLoggedInDevicesFromServer ( string  userId,
string  password,
ValueCallBack< List< DeviceInfo > >  callback = null 
)

Gets the list of currently logged-in devices of a specified account.

This is an asynchronous method.

Parameters
userIdThe user ID.
passwordThe password.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#OnSuccessValue(Object) to show device information list; if this call fails, calls ValueCallBack#onError(int, String).

◆ GetLoggedInDevicesFromServerWithToken()

void AgoraChat.SDKClient.GetLoggedInDevicesFromServerWithToken ( string  userId,
string  token,
ValueCallBack< List< DeviceInfo > >  callback = null 
)

Gets the list of currently logged-in devices of a specified account.

This is an asynchronous method.

Parameters
userIdThe user ID.
tokenThe token.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#OnSuccessValue(Object) to show device information list; if this call fails, calls ValueCallBack#onError(int, String).

◆ KickDevice()

void AgoraChat.SDKClient.KickDevice ( string  userId,
string  password,
string  resource,
CallBack  callback = null 
)

Forces the specified account to log out from the specified device.

You can call GetLoggedInDevicesFromServer() to get the device information DeviceInfo.

This is an asynchronous method.

Parameters
userIdThe user ID.
passwordThe password.
resourceThe device ID. See DeviceInfo#Resource.

◆ KickDeviceWithToken()

void AgoraChat.SDKClient.KickDeviceWithToken ( string  userId,
string  token,
string  resource,
CallBack  callback = null 
)

Forces the specified account to log out from the specified device.

You can call GetLoggedInDevicesFromServer() to get the device information DeviceInfo.

This is an asynchronous method.

Parameters
userIdThe user ID.
tokenThe token.
resourceThe device ID. See DeviceInfo#Resource.

◆ KickAllDevices()

void AgoraChat.SDKClient.KickAllDevices ( string  userId,
string  password,
CallBack  callback = null 
)

Forces the specified account to log out from all devices.

This is an asynchronous method.

Parameters
userIdThe user ID.
passwordThe password.
callbackThe operation callback. See CallBack.

◆ KickAllDevicesWithToken()

void AgoraChat.SDKClient.KickAllDevicesWithToken ( string  userId,
string  token,
CallBack  callback = null 
)

Forces the specified account to log out from all devices.

This is an asynchronous method.

Parameters
userIdThe user ID.
tokenThe token.
callbackThe operation callback. See CallBack.

◆ AddConnectionDelegate()

void AgoraChat.SDKClient.AddConnectionDelegate ( IConnectionDelegate  connectionDelegate)

Adds a connection status listener.

Parameters
connectionDelegateThe connection status listener to add. It is inherited from IConnectionDelegate.

◆ DeleteConnectionDelegate()

void AgoraChat.SDKClient.DeleteConnectionDelegate ( IConnectionDelegate  connectionDelegate)

Removes a connection status listener.

Parameters
connectionDelegateThe connection status listener to remove. It is inherited from IConnectionDelegate.

◆ AddMultiDeviceDelegate()

void AgoraChat.SDKClient.AddMultiDeviceDelegate ( IMultiDeviceDelegate  multiDeviceDelegate)

Adds a connection listener.

Parameters
multiDeviceDelegateThe multi-device listener to add. It is inherited from IMultiDeviceDelegate.

◆ DeleteMultiDeviceDelegate()

void AgoraChat.SDKClient.DeleteMultiDeviceDelegate ( IMultiDeviceDelegate  multiDeviceDelegate)

Removes a connection listener.

Parameters
multiDeviceDelegateThe multi-device listener to remove. It is inherited from IMultiDeviceDelegate.

Property Documentation

◆ ChatManager

ChatManager AgoraChat.SDKClient.ChatManager
get

The chat manager instance.

◆ ContactManager

ContactManager AgoraChat.SDKClient.ContactManager
get

The contact manager instance.

◆ GroupManager

GroupManager AgoraChat.SDKClient.GroupManager
get

The group manager instance.

◆ RoomManager

RoomManager AgoraChat.SDKClient.RoomManager
get

The chat room manager instance.

◆ UserInfoManager

UserInfoManager AgoraChat.SDKClient.UserInfoManager
get

The user information manager instance.

◆ PresenceManager

PresenceManager AgoraChat.SDKClient.PresenceManager
get

The presence manager instance.

◆ ThreadManager

ChatThreadManager AgoraChat.SDKClient.ThreadManager
get

The thread manager instance.

◆ SdkVersion

string AgoraChat.SDKClient.SdkVersion
get

The SDK version.

◆ CurrentUsername

string AgoraChat.SDKClient.CurrentUsername
get

The ID of the current login user.

◆ IsLoggedIn

bool AgoraChat.SDKClient.IsLoggedIn
get

Whether the current user is logged into the chat app.

  • true: Yes.
  • false: No. The current user is not logged into the chat app yet.

◆ IsConnected

bool AgoraChat.SDKClient.IsConnected
get

Whether the SDK is connected to the server.

  • true: Yes.
  • false: No.

◆ AccessToken

string AgoraChat.SDKClient.AccessToken
get

The token of the current user.