static void ASK_ROOM_LIST_REPLY(byte[] bytes) { AskRoomListReply input = AskRoomListReply.Parser.ParseFrom(bytes); if (!input.Ret) { string msg = "获取房间信息失败!"; UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error); ClientManager.Instance.LobbyManager.Log("MSG: ASK_ROOM_LIST_REPLY Error - " + msg); return; } ClientManager.Instance.LobbyManager.Log($"MSG: ASK_ROOM_LIST_REPLY - Room Count:{input.Rooms.Count}"); PanelLobbyMain.Instance.ClearRoomList(); foreach (var roomInfo in input.Rooms) { PanelLobbyMain.Instance.AddRoomInfo(roomInfo); ClientManager.Instance.LobbyManager.Log($"MSG: ASK_ROOM_LIST_REPLY - {roomInfo}"); } }
static void ASK_ROOM_LIST(byte[] bytes) { AskRoomList input = AskRoomList.Parser.ParseFrom(bytes); ServerLobbyManager.Instance.Log($"LobbyMsgReply ASK_ROOM_LIST - Received!"); // 从redis里读取房间信息 { AskRoomListReply output = new AskRoomListReply(); output.Ret = true; string[] tableNames = ServerLobbyManager.Instance.Redis.CSRedis.Keys("MAP:*"); ServerLobbyManager.Instance.Log($"ASK_ROOM_LIST : RoomCount:{tableNames.Length}"); foreach (string tableName in tableNames) { long createrId = ServerLobbyManager.Instance.Redis.CSRedis.HGet <long>(tableName, "Creator"); RoomInfo roomInfo = new RoomInfo() { RoomId = ServerLobbyManager.Instance.Redis.CSRedis.HGet <long>(tableName, "RoomId"), MaxPlayerCount = ServerLobbyManager.Instance.Redis.CSRedis.HGet <int>(tableName, "MaxPlayerCount"), RoomName = ServerLobbyManager.Instance.Redis.CSRedis.HGet <string>(tableName, "RoomName"), Creator = createrId, IsRunning = false, }; roomInfo.IsRunning = ServerLobbyManager.Instance.Rooms.ContainsKey(roomInfo.RoomId); if (roomInfo.IsRunning) { roomInfo.CurPlayerCount = ServerLobbyManager.Instance.Rooms[roomInfo.RoomId].CurPlayerCount; } output.Rooms.Add(roomInfo); ServerLobbyManager.Instance.Log($"RoomInfo : {roomInfo}"); } ServerLobbyManager.Instance.SendMsg(_args, LOBBY_REPLY.AskRoomListReply, output.ToByteArray()); } }