using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ServerCommon; namespace GameServer { internal class ChatRoomHandler { /*static int GetBestChattingServer(in List serverList) { int retIndex = 0; int minCount = -1; foreach (var serverInfo in serverList.Select((value, index) => new { value, index })) { if (minCount < serverInfo.value.Sessions) { retIndex = serverInfo.index; minCount = serverInfo.value.Sessions; } } return retIndex; } public static async Task CreateRoom(List allowList) { ServerInfo emptyServer = new ServerInfo(); List serverList = await GameServerApp.Instance.ServerCUStorage.getServersCU(ServerType.Chat); if (serverList.Count == 0) return null; int serverIndex = GetBestChattingServer(serverList); if(serverIndex == -1) return null; ServerInfo chatServer = serverList[serverIndex]; return await GameServerApp.Instance.ChatRoomStorage.CreateChatRoom( chatServer.Address, chatServer.Port, allowList); } public static async Task JoinRoom(long roomId, string charName) { ChatRoomInfo? charRoomInfo = await GameServerApp.Instance.ChatRoomStorage.GetChatRoom(roomId); if (charRoomInfo == null) return null; if (charRoomInfo.AllowList.Contains(charName) == false) return null; return charRoomInfo; }*/ } }