MMatchChatRoom.h
00001 #pragma once 00002 00003 00004 #include "MUID.h" 00005 #include <map> 00006 using namespace std; 00007 00008 00009 class MCommand; 00010 00011 00012 #define CHATROOM_MAX_ROOMMEMBER 64 00013 00014 00015 class MMatchChatRoom { 00016 protected: 00017 MUID m_uidChatRoom; 00018 MUID m_uidMaster; 00019 char m_szName[128]; 00020 MUIDRefCache m_PlayerList; 00021 00022 public: 00023 MMatchChatRoom(const MUID& uidRoom, const MUID& uidMaster, const char* pszName); 00024 virtual ~MMatchChatRoom(); 00025 00026 const MUID& GetUID() { return m_uidChatRoom; } 00027 const MUID& GetMaster() { return m_uidMaster; } 00028 const char* GetName() { return m_szName; } 00029 size_t GetUserCount() { return m_PlayerList.size(); } 00030 00031 bool AddPlayer(const MUID& uidPlayer); 00032 void RemovePlayer(const MUID& uidPlayer); 00033 00034 void RouteChat(const MUID& uidSender, char* pszMessage); 00035 void RouteInfo(const MUID& uidReceiver); 00036 void RouteCommand(const MCommand* pCommand); 00037 }; 00038 00039 00040 class MMatchChatRoomMap : public map<MUID, MMatchChatRoom*> { 00041 MUID m_uidGenerate; 00042 public: 00043 MMatchChatRoomMap() { m_uidGenerate = MUID(0,10); } 00044 virtual ~MMatchChatRoomMap(){} 00045 MUID UseUID() { m_uidGenerate.Increase(); return m_uidGenerate; } 00046 void Insert(const MUID& uid, MMatchChatRoom* pStage) { insert(value_type(uid, pStage)); } 00047 }; 00048 00049 class MMatchChatRoomStringSubMap : public map<string, MUID> {}; 00050 00051 00052 class MMatchChatRoomMgr { 00053 protected: 00054 MMatchChatRoomMap m_RoomMap; 00055 MMatchChatRoomStringSubMap m_RoomStringSubMap; 00056 00057 public: 00058 MMatchChatRoomMgr(); 00059 virtual ~MMatchChatRoomMgr(); 00060 00061 MMatchChatRoom* AddChatRoom(const MUID& uidMaster, const char* pszName); 00062 void RemoveChatRoom(const MUID& uidChatRoom); 00063 00064 MMatchChatRoom* FindChatRoom(const MUID& uidChatRoom); 00065 MMatchChatRoom* FindChatRoomByName(const char* pszName); 00066 00067 void Update(); 00068 };
MAIET entertainment