초기커밋
This commit is contained in:
56
GameServer/z.Backup/ChatRoomHandler.cs
Normal file
56
GameServer/z.Backup/ChatRoomHandler.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
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;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user