环信聊天室模型支持最大成员数为5000,和群组不同,聊天室内成员离线后,服务器当监听到此成员不在线后不再会给此成员再发推送。
curl -X POST “http://a1.easemob.com/easemob-demo/chatdemoui/chatrooms” -H “Authorization: Bearer ${token}” -d ‘{“owner”:”u1”,”members”:[“u1”,”u2”],”maxusers”:5000,”groupname”:”chatroom title”,”desc”:”chatroom description”}”
curl -X GET “http://a1.easemob.com/easemob-demo/chatdemoui/chatrooms” -H “Authorization: Bearer ${token}”
curl -X GET “http://a1.easemob.com/easemob-demo/chatdemoui/chatrooms/1430798028680235” -H “Authorization: Bearer ${token}”
curl -X DELETE ‘https://a1.easemob.com/easemob-demo/chatdemoui/chatrooms/1430798028680235/users/u2’ -H “Authorization: Bearer ${token}”
curl -X DELETE ‘https://a1.easemob.com/easemob-demo/chatdemoui/chatrooms/143228117786605’ -H “Authorization: Bearer ${token}”
更多服务器端 REST 操作请参考聊天室管理。
//id为聊天室ID
EMError error;
string id = getStringAttrFromJson(json, "id");
if (!id.empty())
{
g_client->getChatroomManager().joinChatroom(id, error);
if (error.mErrorCode != EMError::EM_NO_ERROR)
{
callback->Failure(error.mErrorCode, error.mDescription);
}
else
{
callback->Success(id);
}
}
注意:对于聊天室模型,请一定要等到 Join 回调成功后再去初始化 conversation。
EMError error;
string id = getStringAttrFromJson(json, "id");
if (!id.empty())
{
g_client->getChatroomManager().leaveChatroom(id, error);
if (error.mErrorCode != EMError::EM_NO_ERROR)
{
callback->Failure(error.mErrorCode, error.mDescription);
}
else
{
callback->Success(id);
}
}
EMError error;
EMChatroomList roomList = g_client->getChatroomManager().fetchAllChatrooms(error);
string ret;
if (error.mErrorCode == EMError::EM_NO_ERROR) {
for (EMChatroomPtr room : roomList)
{
ret += "{\"owner\":\"";
ret += room->owner();
ret += "\",\"name\":\"";
ret += room->chatroomSubject();
ret += "\",\"id\":\"";
ret += room->chatroomId();
ret += "\",\"affiliations_count\":";
ret += "5";
ret += "},";
}
if (!ret.empty())
{
string tmp = ret.substr(0, ret.length() - 1);
ret = "[" + tmp + "]";
}
callback->Success(ret);
}
else
{
callback->Failure(error.mErrorCode, error.mDescription);
}
上一页:群组管理
下一页:Windows SDK更新日志