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

158 lines
5.8 KiB
C#

//using ServerCommon;
//using ServerCommon.Redis;
//using ServerCore; using ServerBase;
//using StackExchange.Redis;
//using System.Collections.Concurrent;
//using System.Diagnostics.CodeAnalysis;
//namespace GameServer
//{
// public class GameServerApp : IWithServerMetrics
// {
// public class ForcedMoveConnectInfo
// {
// public string ServerName = string.Empty;
// public string RoomId = string.Empty;
// public Pos Pos = new();
// public DateTime ExpireDate = DateTime.MinValue;
// }
// public static GameServerApp Instance { get; } = new();
// public LoginStorage LoginStorage = new();
// public ServerInfoStorage ServerCUStorage = new();
// public ChatRoomStorage ChatRoomStorage = new();
// public CharacterStorage CharacterStorage = new();
// public InstanceRoomStorage InstanceRoomStorage = new();
// public LastPositionStorage LastPositionStorage = new();
// public AwsNewInstanceInfoStorage awsNewInstanceInfoStorage = new();
// public BuffStorage buffStorage = new ();
// public PartyStorage PartyStorage = new();
// public MoveServerPlayerInfoStorage moveServerPlayerInfoStorage = new();
// public FileConfig Config = new();
// public MainDB MainDB = new();
// ConnectionMultiplexer _connection = default!;
// IDatabase _database = default!;
// ConcurrentDictionary<string, ForcedMoveConnectInfo> forcedMoveInfoFromGM = new();
// public ServerInfoStorage getServerMetrics() => ServerCUStorage;
// public GameServerApp()
// {
// }
// public async Task Init(string configFile, int type)
// {
// try
// {
// Config.LoadConfig(configFile);
// LogicThread.start(Config.SingleThreaded);
// if (type == 1)
// {
// Config.GameServerType = EGameServerType.Indun;
// }
// if (Config.GameServerType == EGameServerType.Indun)
// {
// DumpHelper.Init(Config.DumpDir, "InstanceServer");
// Log.getLogger().info("IndunServer Start");
// }
// else
// {
// DumpHelper.Init(Config.DumpDir, "GameServer");
// Log.getLogger().info("GameServer Start");
// }
// string prefix = string.Empty;
// Log.getLogger().info($"Redis {Config.Redis}");
// //_tw = new StreamWriter($"redis_{Config.GameServerType.ToString()}.log", true);
// //ConnectionMultiplexer.SetFeatureFlag(_tw);
// ConnectionMultiplexer.SetFeatureFlag("preventthreadtheft", true);
// var configObj = ConfigurationOptions.Parse(Config.Redis);
// configObj.SocketManager = SocketManager.Shared;
// _connection = await ConnectionMultiplexer.ConnectAsync(configObj);
// _database = _connection.GetDatabase();
// LoginStorage.Init(_database, prefix);
// ServerCUStorage.Init(_database, prefix);
// ChatRoomStorage.Init(_database, prefix);
// CharacterStorage.Init(_database, prefix);
// InstanceRoomStorage.Init(_database, prefix);
// LastPositionStorage.Init(_database, prefix);
// awsNewInstanceInfoStorage.Init(_database, prefix);
// buffStorage.Init(_database, prefix);
// PartyStorage.Init(_database, prefix);
// moveServerPlayerInfoStorage.Init(_database, prefix);
// MainDB.CreateClient(Config);
// if (await MainDB.CreateDBIfNotExists(false) == false)
// {
// Log.getLogger().error($"Can't Create DB");
// }
// if (Config.NftRule.NftDBAccess)
// {
// var result = await MySqlConnectorHelper.simpleTryConnectToDb(Config.AccountNftDb);
// if(result.isFail())
// {
// var err_msg = $"Failed to connect NFT Db !!! : {result.toBasicString()}";
// Log.getLogger().error(err_msg);
// throw new Exception(err_msg);
// }
// }
// ServerConfigHelper.init(Config);
// //await TestMainDB();
// }
// catch (Exception ex)
// {
// Log.getLogger().error(ex.ToString());
// throw;
// }
// }
// public void Stop()
// {
// LogicThread.join();
// }
// public void SetForecedMoveInfoFromGM(string GMName, ForcedMoveConnectInfo newServerConnectInfo)
// {
// if (!forcedMoveInfoFromGM.TryAdd(GMName, newServerConnectInfo))
// {
// forcedMoveInfoFromGM[GMName] = newServerConnectInfo;
// }
// }
// public bool GetForecedMoveInfoFromGM(string GMName, [MaybeNullWhen(false)] out ForcedMoveConnectInfo outData)
// {
// return forcedMoveInfoFromGM.TryGetValue(GMName, out outData);
// }
// public void UpdateForDeleteForecedMoveInfoFromGM()
// {
// foreach(var Info in forcedMoveInfoFromGM)
// {
// if(Info.Value.ExpireDate < DateTime.UtcNow)
// {
// if(forcedMoveInfoFromGM.TryRemove(Info.Key, out _) == false)
// {
// Log.getLogger().error($"Failed To Remove Data");
// continue;
// }
// }
// }
// }
// }
//}