Create a CChatroomManager object Add callback function pointer Add getting chat room list callback function pointer
The class which the object belongs to needs to implement the IChatroomManagerListener interface and the IChatroomGetListListener interface. XHChatroomManager::addChatroomGetListListener(this); m_pChatroomManager = new XHChatroomManager(this);
5.2 The description of getting chat room list
The usage without AEC
/* * Get the chat room list */ void getChatroomList() { XHChatroomManager::getChatroomList("", CHATROOM_LIST_TYPE_CHATROOM); } After calling this method, the corresponding chatroomQueryAllListOK callback function will be called. /* * Save the chat room */ 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);
/* * Delete the chat room */ m_pChatroomManager->deleteChatRoom(dlg.m_strContent.GetBuffer(0));
The usage with AEC
/* * Get the chat room list */ void getChatroomList() { list<ChatroomInfo> listData; CInterfaceUrls::demoRequestChatroomList(listData, m_pUserManager); chatroomQueryAllListOK(listData); }
/* * Delete the chat room */ CInterfaceUrls::demoDeleteFromList(m_pUserManager->m_ServiceParam.m_strUserId, CHATROOM_LIST_TYPE_CHATROOM, dlg.m_strContent.GetBuffer(0));
5.3 Callback function description
/** * Get the chat room list * @param the chat room list */ virtual int chatroomQueryAllListOK(list<ChatroomInfo>& listData); /** * The number of chatroom members has changed * @param number the number */ virtual void onMembersUpdated(int number);
/** * You are removed from the current chatroom */ virtual void onSelfKicked();
/** * You are being mute */ virtual void onSelfMuted(int seconds);
/** * Notification of the chatroom close */ virtual void onClosed();
/* * Add the callback function pointer after getting the group list * @param pChatroomGetListListener Callback function pointer */ staticvoid addChatroomGetListListener(IChatroomGetListListener* pChatroomGetListListener);
/* * Get the chat room list * @param pUserManager User information * @param listType type */ staticvoid getChatroomList(string strUserId, int listType);
/* * Create a chatroom * @param strName name * @param chatroomType type * @return chatroom id */ string createChatRoom(string strName, int chatroomType);
/** * delete the chatroom * @param strChatroomId the chatroom ID which will be deleted */ bool deleteChatRoom(string strRoomId);
/** * Join the chatroom * @param strChatroomId the chatroom ID which will be added */ bool joinChatRoom(string strChatroomId);
/** * Exit the chatroom * @param strChatroomId the chatroom ID which will be exited */ bool exitChatroom(string strChatroomId);
/** * mute somebody in the chatroom * @param strChatroomId chatroom ID * @param strMemberId the member who is being muted * @param muteSeconds mute time(Unit: second) */ bool muteMember(string strChatroomId, string strMemberId, int muteSeconds);
/** * unmute somebody in the chatroom * @param chatroomID chatroom ID * @param memberID the member who is being unmuted */ bool unMuteMember(string strChatroomId, string strMemberId);
/** * kick out users in the chatroom * @param chatroomID chatroom ID * @param memberID the member who is being kicked out */ bool kickMember(string chatroomID, string memberID);
/* * Send a private message * @param toUserId receiver id * @param msgData message data */ CIMMessage* sendPrivateChat(string toUserId, char* msgData);
/**(only for private deployments) * Save the chat roomn to the list * @param userId user ID * @param type list type * @param chatroomId * @param data */ bool saveToList(string userId, int type, string chatroomId, string data);
/** * Delete the chat room from the list * @param userId user ID * @param chatroomId chatroom ID */ void deleteFromList(string userId, int type, string chatroomId); /* * Check the number of online users in the chatroom */ bool getOnlineNumber(string strChatroomId);
/** * get current chatroom id * @return Chatroom id */ string getChatroomId();