聊天室消息
5.1 聊天室创建
创建CChatroomManager对象
添加回调函数指针
添加获取聊天室列表回调函数指针
对象所属类需要实现IChatroomManagerListener接口和IChatroomGetListListener接口 XHChatroomManager::addChatroomGetListListener(this); m_pChatroomManager = new XHChatroomManager(this);
|
5.2 聊天室列表说明
无AEC使用方法
void getChatroomList() { XHChatroomManager::getChatroomList("", CHATROOM_LIST_TYPE_CHATROOM); } 调用该方法后会相应chatroomQueryAllListOK回调函数
string strInfo = "{\"id\":\""; strInfo += strRoomId; strInfo += "\",\"creator\":\""; strInfo += m_pUserManager->m_ServiceParam.m_strUserId; strInfo += "\",\"name\":\""; strInfo += dlg.m_strRoomName.GetBuffer(0); strInfo += "\"}"; m_pChatroomManager->saveToList(m_pUserManager->m_ServiceParam.m_strUserId, CHATROOM_LIST_TYPE_CHATROOM, strRoomId, strInfo);
m_pChatroomManager->deleteChatRoom(dlg.m_strContent.GetBuffer(0));
|
AEC使用方法
void getChatroomList() { list<ChatroomInfo> listData; CInterfaceUrls::demoRequestChatroomList(listData, m_pUserManager); chatroomQueryAllListOK(listData); }
string strInfo = "{\"id\":\""; strInfo += strRoomId; strInfo += "\",\"creator\":\""; strInfo += m_pUserManager->m_ServiceParam.m_strUserId; strInfo += "\",\"name\":\""; strInfo += dlg.m_strRoomName.GetBuffer(0); strInfo += "\"}"; CInterfaceUrls::demoSaveToList(m_pUserManager->m_ServiceParam.m_strUserId, CHATROOM_LIST_TYPE_CHATROOM, strRoomId, strInfo);
CInterfaceUrls::demoDeleteFromList(m_pUserManager->m_ServiceParam.m_strUserId, CHATROOM_LIST_TYPE_CHATROOM, dlg.m_strContent.GetBuffer(0));
|
5.3 回调函数说明
virtual int chatroomQueryAllListOK(list<ChatroomInfo>& listData);
virtual void onMembersUpdated(int number);
virtual void onSelfKicked();
virtual void onSelfMuted(int seconds);
virtual void onClosed();
virtual void onReceivedMessage(CIMMessage* pMessage);
virtual void onReceivePrivateMessage(CIMMessage* pMessage);
|
5.4 CChatroomManager API 说明
static void addChatroomGetListListener(IChatroomGetListListener* pChatroomGetListListener);
static void getChatroomList(string strUserId, int listType);
string createChatRoom(string strName, int chatroomType);
bool deleteChatRoom(string strRoomId);
bool joinChatRoom(string strChatroomId);
bool exitChatroom(string strChatroomId);
bool muteMember(string strChatroomId, string strMemberId, int muteSeconds);
bool unMuteMember(string strChatroomId, string strMemberId);
bool kickMember(string chatroomID, string memberID);
CIMMessage* sendMessage(string strMsg);
CIMMessage* sendPrivateChat(string toUserId, char* msgData);
bool saveToList(string userId, int type, string chatroomId, string data);
void deleteFromList(string userId, int type, string chatroomId);
bool getOnlineNumber(string strChatroomId);
string getChatroomId();
|