Files
caliverse_server/GameServer/z.Backup/ChatRoomHandler.cs
2025-05-01 07:20:41 +09:00

57 lines
1.8 KiB
C#

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<ServerInfo> 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<ChatRoomInfo?> CreateRoom(List<string> allowList)
{
ServerInfo emptyServer = new ServerInfo();
List<ServerInfo> 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<ChatRoomInfo?> 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;
}*/
}
}