new connection(options) → {Class}
The connection class.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | -
Properties
|
Returns:
a single instance of connection
- Type
- Class
Methods
acceptInviteFromGroup(options)
接受加入申请
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
addGroupMembers(options)
添加群组成员
Example
Attention the sequence: message first (每个成员单独发一条message), iq second (多个成员可以合成一条iq发)
<!-- 添加成员通知:send -->
<message to='easemob-demo#chatdemoui_1477482739698@conference.easemob.com'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<invite to='easemob-demo#chatdemoui_lwz2@easemob.com'>
<reason>liuwz invite you to join group '谢谢'</reason>
</invite>
</x>
</message>
<!-- 添加成员:send -->
<iq id='09DFB1E5-C939-4C43-B5A7-8000DA0E3B73_easemob_occupants_change_affiliation' to='easemob-demo#chatdemoui_1477482739698@conference.easemob.com' type='set'>
<query xmlns='http://jabber.org/protocol/muc#admin'>
<item affiliation='member' jid='easemob-demo#chatdemoui_lwz2@easemob.com'/>
</query>
</iq>
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
addRoster(options)
- Deprecated:
- Yes
添加联系人
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
addToBlackList(options)
加入好友黑名单
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
addToGroupBlackList(options)
加入群组黑名单
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
agreeJoinGroup(opt)
通过RestFul API同意用户加入群
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
blockGroup(options)
通过RestFul API屏蔽群组
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
changeGroupSubject(options)
修改群名称
Example
<iq to='easemob-demo#chatdemoui_roomid@conference.easemob.com' type='set' id='3940489311' xmlns='jabber:client'>
<query xmlns='http://jabber.org/protocol/muc#owner'>
<x type='submit' xmlns='jabber:x:data'>
<field var='FORM_TYPE'><value>http://jabber.org/protocol/muc#roomconfig</value></field>
<field var='muc#roomconfig_roomname'><value>Room Name</value></field>
</x>
</query>
</iq>
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
close(reason)
close connection
Parameters:
Name | Type | Description |
---|---|---|
reason |
String |
createGroup(options)
创建群组
Example
1. 创建申请 -> 得到房主身份
2. 获取房主信息 -> 得到房间form
3. 完善房间form -> 创建成功
4. 添加房间成员
5. 消息通知成员
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
createGroupAsync(p)
创建群组-异步
Parameters:
Name | Type | Description |
---|---|---|
p |
Object | - |
destroyGroup(options)
删除群组
Example
<iq id="9BEF5D20-841A-4048-B33A-F3F871120E58" to="easemob-demo#chatdemoui_1477462231499@conference.easemob.com" type="set">
<query xmlns="http://jabber.org/protocol/muc#owner">
<destroy>
<reason>xxx destory group yyy</reason>
</destroy>
</query>
</iq>
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
dissolveGroup(opt)
通过RestFul API解散群组
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
getBlacklist(options)
获取好友黑名单
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
getChatRooms(options)
获取聊天室列表
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
getGroup(opt)
通过RestFul API列出某用户所加入的所有群组
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
getGroupAdmin(opt)
通过RestFul API获取群组下所有管理员
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
getGroupBlacklist(options)
获取群组黑名单
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
getGroupBlacklistNew(opt)
通过RestFul API获取群组黑名单
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
getGroupInfo(opt)
通过RestFul API根据groupid获取群组详情
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
getMuted(opt)
通过RestFul API获取群组下所有被禁言成员
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
getRoster(options)
获取联系人
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
getUniqueId(prefix) → {string}
gen uuid with customized prefix
Parameters:
Name | Type | Description |
---|---|---|
prefix |
String |
Returns:
- Type
- string
groupBlockMulti(opt)
通过RestFul API添加用户至群组黑名单(批量)
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
groupBlockSingle(opt)
通过RestFul API添加用户至群组黑名单(单个)
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
inviteToGroup(opt)
通过RestFul API邀请群成员
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
joinChatRoom(options)
加入聊天室
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
joinGroup(opt)
通过RestFul API发出入群申请
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
joinPublicGroup(options)
- Deprecated:
- Yes
加入公开群组
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
leaveGroup(options)
被踢出群组
Example
<iq id="9fb25cf4-1183-43c9-961e-9df70e300de4:sendIQ" to="easemob-demo#chatdemoui_1477481597120@conference.easemob.com" type="set" xmlns="jabber:client">
<query xmlns="http://jabber.org/protocol/muc#admin">
<item affiliation="none" jid="easemob-demo#chatdemoui_lwz4@easemob.com"/>
<item jid="easemob-demo#chatdemoui_lwz4@easemob.com" role="none"/>
<item affiliation="none" jid="easemob-demo#chatdemoui_lwz2@easemob.com"/>
<item jid="easemob-demo#chatdemoui_lwz2@easemob.com" role="none"/>
</query>
</iq>
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
leaveGroupBySelf(options)
主动离开群组
Example
<iq id="5CD33172-7B62-41B7-98BC-CE6EF840C4F6_easemob_occupants_change_affiliation" to="easemob-demo#chatdemoui_1477481609392@conference.easemob.com" type="set">
<query xmlns="http://jabber.org/protocol/muc#admin">
<item affiliation="none" jid="easemob-demo#chatdemoui_lwz2@easemob.com"/>
</query>
</iq>
<presence to="easemob-demo#chatdemoui_1479811172349@conference.easemob.com/mt002" type="unavailable"/>
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
listen(options)
注册监听函数
Parameters:
Name | Type | Description |
---|---|---|
options |
options | - |
listGroupMember(opt)
通过RestFul API列出群组的所有成员
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
listGroups(opt)
通过RestFul API获取群组列表
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
listRooms(options)
- Deprecated:
- Yes
获取聊天室列表
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
modifyGroup(opt)
通过RestFul API修改群信息
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
mute(opt)
通过RestFul API禁止群用户发言
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
open(options)
登录
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
queryRoomInfo(options)
获取聊天室信息
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
queryRoomMember(options)
获取聊天室成员列表
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
queryRoomOccupants(options)
- Deprecated:
- Yes
获取聊天室管理员
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
quitChatRoom(options)
退出聊天室
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
quitGroup(opt)
通过RestFul API离开群组
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
registerUser(options)
注册新用户
Parameters:
Name | Type | Description |
---|---|---|
options |
options | - |
rejectInviteFromGroup(options)
拒绝入群申请
Example
throw request for now 暂时不处理,直接丢弃
<message to='easemob-demo#chatdemoui_mt002@easemob.com' from='easmeob-demo#chatdemoui_mt001@easemob.com' id='B83B7210-BCFF-4DEE-AB28-B9FE5579C1E2'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<apply to='easemob-demo#chatdemoui_groupid1@conference.easemob.com' from='easmeob-demo#chatdemoui_mt001@easemob.com' toNick='llllll'>
<reason>reject</reason>
</apply>
</x>
</message>
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | - |
rejectJoinGroup(opt)
通过RestFul API拒绝用户加入群
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
removeAdmin(opt)
通过RestFul API取消群管理员
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
removeFromBlackList(options)
从好友黑名单删除
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
removeGroupBlockMulti(opt)
通过RestFul API将用户从群黑名单移除(批量)
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
removeGroupBlockSingle(opt)
通过RestFul API将用户从群黑名单移除(单个)
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
removeGroupMemberFromBlacklist(options)
从群组黑名单删除
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
removeMultiGroupMember(opt)
通过RestFul API删除多个群成员
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
removeMute(opt)
通过RestFul API取消对用户禁言
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
removeRoster(options)
删除联系人
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
removeSingleGroupMember(opt)
通过RestFul API删除单个群成员
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
send(messageSource)
send message
Parameters:
Name | Type | Description |
---|---|---|
messageSource |
Object |
setAdmin(opt)
通过RestFul API设置群管理员
Parameters:
Name | Type | Description |
---|---|---|
opt |
Object | - |
subscribe(options)
订阅
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
subscribed(options)
订阅成功
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
unsubscribe(options)
- Deprecated:
- Yes
取消订阅成功
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
unsubscribed(options)
取消订阅成功
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |