EMClient

EMClient

new EMClient(chatConfigs)

Source:
EMClient constructor.
Parameters:
Name Type Description
chatConfigs Object EMChatConfigs

Methods

addConnectionListener(listener) → {void}

Source:
register connection listener.
Parameters:
Name Type Description
listener EMConnectionListener 网络连接的回调监听对象
Returns:
Type
void

addMultiDevicesListener(listener) → {void}

Source:
register multi devices listener.
Parameters:
Name Type Description
listener EMMultiDevicesListener 多设备回调监听对象
Returns:
Type
void

changeAppkey(appKey) → {Object}

Source:
change appkey only when user not logged in.
Parameters:
Name Type Description
appKey String 修改后的appkey
Returns:
{code,description}修改结果
Type
Object

clearAllMultiDevicesListeners() → {void}

Source:
clear all register multi devices listener.
Returns:
Type
void

createAccount(username, password) → {Object}

Source:
Register a new account with user name and password.
Parameters:
Name Type Description
username String 用户名
password String 密码
Returns:
{code,description}注册结果
Type
Object

disconnect() → {void}

Source:
disconnect client.
Returns:
Type
void

getChatConfigs() → {EMChatConfigs}

Source:
get the chat configs.
Returns:
返回配置信息
Type
EMChatConfigs

getChatManager() → {EMChatManager}

Source:
Get chat manager to handle the message operation.
Returns:
返回会话管理对象
Type
EMChatManager

getChatroomManager() → {EMChatroomManager}

Source:
Get chatroom manager to manage the chatroom.
Returns:
返回聊天室管理对象
Type
EMChatroomManager

getContactManager() → {EMContactManager}

Source:
Get contact manager to manage the contacts.
Returns:
返回好友管理对象
Type
EMContactManager

getGroupManager() → {EMGroupManager}

Source:
Get group manager to manage the group.
Returns:
返回群组管理对象
Type
EMGroupManager

getLoggedInDevicesFromServer(username, password) → {Array}

Source:
get all logged in devices. return an array of EMDeviceInfo. EMDeviceInfo.resource device resource. EMDeviceInfo.deviceUUID device uuid. EMDeviceInfo.deviceName device name.
Parameters:
Name Type Description
username String 用户ID
password String 用户名密码
Returns:
EMDeviceInfo
Type
Array

getLoginInfo() → {Object}

Source:
Logout current user.
Returns:
{loginUser,loginPassword,loginToken}
Type
Object

kickAllDevices(username, password) → {void}

Source:
Forced to logout all logged in device.
Parameters:
Name Type Description
username String 用户ID
password String 用户密码
Returns:
Type
void

kickDevice(username, password, resource) → {void}

Source:
Forced to logout the specified logged in device.
Parameters:
Name Type Description
username String 用户ID
password String 用户密码
resource String 用户客户端resource
Returns:
Type
void

login(username, password) → {Object}

Source:
Login with username and password.
Parameters:
Name Type Description
username String 用户ID
password String 密码
Returns:
登录结果
Type
Object

loginWithToken(username, token) → {Object}

Source:
Login with username and token.
Parameters:
Name Type Description
username String 用户名
token String token
Returns:
登录结果
Type
Object

logout() → {Object}

Source:
Logout current user.
Returns:
登出结果
Type
Object

onNetworkChanged(to, forceReconnect) → {void}

Source:
call this method to notify SDK the network change.
Parameters:
Name Type Description
to Number 新的网络连接类型
forceReconnect Bool 是否强制重连
Returns:
{ NONE = 0 CABLE = 1, WIFI = 2, MOBILE = 3 }
Type
void

reconnect() → {void}

Source:
reconnect client.
Returns:
Type
void

removeConnectionListener(listener) → {void}

Source:
remove connection listener.
Parameters:
Name Type Description
listener EMConnectionListener 网络连接的回调监听对象
Returns:
Type
void

removeMultiDevicesListener(listener) → {void}

Source:
remove register multi devices listener.
Parameters:
Name Type Description
listener EMMultiDevicesListener 多设备回调监听对象
Returns:
Type
void