//using Amazon.DynamoDBv2.DocumentModel; //using GameServer.World; //using Google.Protobuf.Collections; //using Google.Protobuf.WellKnownTypes; //using Nettention.Proud; //using Newtonsoft.Json; //using ServerCommon; //using ServerCommon.BusinessLogDomain; //using ServerCore; using ServerBase; //using System.Collections.Concurrent; //using System.Net.Sockets; //using System.Numerics; //using System.Security.Claims; //using System.Threading.Channels; //using static ClientToGameMessage.Types; //using static ClientToGameReq.Types; //using static ClientToGameRes.Types; //using GameServer.BusinessLogInvoker; //using System; //namespace GameServer //{ // internal class ClientSessionManager // { // // Key:ProudNet.HostId // readonly ConcurrentDictionary _clients = new(); // // Key:LoginRes.UserId == LoginInfo.Name(Cache) == AccountAttr.id(DB) // readonly ConcurrentDictionary _clientsByName = new(); // static public ClientSessionManager Instance { get; private set; } = new ClientSessionManager(); // public int Count // { // get { return _clients.Count; } // } // public ClientSessionManager() // { // } // public ConcurrentDictionary getClientSessions() // { // return _clients; // } // public bool AddHost(ClientSession client) // { // if (false == _clients.TryAdd((int)client.HostId, client)) // { // if (true == _clients.TryGetValue((int)client.HostId, out ClientSession? oldClient)) // { // Log.getLogger().error($"Duplicated OldUser hostid:{oldClient.HostId} Account:{oldClient.Id}"); // } // else // { // Log.getLogger().error($"Duplicated NewUser hostid:{client.HostId}"); // } // return false; // } // return true; // } // public bool NewSession(ClientSession client) // { // if (false == _clientsByName.TryAdd(client.Id, client)) // { // Log.getLogger().error($"Duplicated User HostId:{client.Id}"); // if (true == _clientsByName.TryGetValue(client.Id, out ClientSession? oldClient)) // { // oldClient._StartMoving = false; // Task task = oldClient.Close(); // _clients.TryRemove((int)oldClient.HostId, out _); // _clientsByName.TryRemove(oldClient.Id, out _); // _clients.TryRemove((int)client.HostId, out _); // } // return false; // } // return true; // } // public void ReleaseSession(ClientSession client) // { // _clients.TryRemove((int)client.HostId, out _); // _clientsByName.TryRemove(client.Id, out _); // } // public ClientSession? GetSession(HostID hostId) // { // ClientSession? client; // if (_clients.TryGetValue((int)hostId, out client) == false) // return null; // return client; // } // public ClientSession? GetSessionByName(string name) // { // ClientSession? client; // if (_clientsByName.TryGetValue(name, out client) == false) // return null; // return client; // } // public void ForEach(Func action, CancellationToken tkn) // { // foreach (var client in _clientsByName) // { // if (tkn.IsCancellationRequested == true) // { // break; // } // if (action(client.Value) == false) // break; // } // } // public async Task ForEach(Func> action) // { // foreach (var client in _clientsByName) // { // bool ret = await action(client.Value); // if ( ret == false) // break; // } // } // public async Task ParrellForEach(Func> action, CancellationToken tkn) // { // ParallelOptions parallelOptions = new() // { // MaxDegreeOfParallelism = 10 // }; // await Parallel.ForEachAsync(_clientsByName.Values, parallelOptions, async (client, tkn) => // { // bool ret = await action(client); // if(tkn.IsCancellationRequested) return; // }); // } // public class LanguageChatInfo // { // public ClientToGame message = new(); // public LanguageType languageType = LanguageType.None; // public List clientList = new(); // } // public void ChatBroadcast(List languageChatInfos) // { // List clientList = new(); // foreach(var client in _clients.Values) // { // foreach(var languageChatInfo in languageChatInfos) // { // if (client._loginInfo.Language == languageChatInfo.languageType) // { // languageChatInfo.clientList.Add(client.HostId); // } // } // } // foreach (var languageChatInfo in languageChatInfos) // { // Log.getLogger().debug($"{languageChatInfo.message}"); // GameServer.Instance.Send(languageChatInfo.clientList.ToArray(), languageChatInfo.message); // } // } // public void Broadcast(Player player, ClientToGame message) // { // HostID[] allClients = _clients.Values.Where(x => x._selectedChar?.ownedBlockList.GetBlockInfo(player.Guid) is null) // .Select(x => x.HostId) // .ToArray(); // Log.getLogger().debug($"{message}"); // GameServer.Instance.Send(allClients, message); // } // public void Broadcast(ClientToGame message) // { // HostID[] allClients = _clients.Values.Select(x => x.HostId).ToArray(); // Log.getLogger().debug($"{message}"); ; // GameServer.Instance.Send(allClients, message); // } // public void AllPlayerSystemMailNoti() // { // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.NewMailNoti = new(); // clientToGameNoti.Message.NewMailNoti.IsLoginNoti = 0; // foreach (var session in _clients.Values) // { // session.ownedMail.newSystemMailNoti(); // session.Send(RmiContext.ReliableSend, clientToGameNoti); // if (session._selectedChar is not null) // { // } // } // } // public void AllPlayerClaimUpdateNoti() // { // foreach (var session in _clients.Values) // { // if (session._selectedChar == null) continue; // session.claimInfosRefreshAndNoti(session._selectedChar); // } // } // public async Task Kick(string name) // { // ClientSession? session = GetSessionByName(name); // if (session == null) // { // Log.getLogger().warn($"Already disconnected user:{name}"); // await GameServerApp.Instance.LoginStorage.Logout(name); // return false; // } // SendLogoutNoti(session); // ReleaseSession(session); // await session.Close(); // Log.getLogger().info($"kick {name}"); // return true; // } // public void SendLogoutNoti(ClientSession session) // { // ClientToGame gs2cMessage = new ClientToGame(); // gs2cMessage.Message = new ClientToGameMessage(); // gs2cMessage.Message.NtfLogout = new ClientToGameMessage.Types.GS2C_NTF_LOGOUT(); // gs2cMessage.Message.NtfLogout.LogoutReason = LogoutReasonType.DuplicatedLogin; // session.Send(RmiContext.ReliableSend, gs2cMessage); // } // } // public partial class ClientSession : IEntityWithSession // { // public HostID HostId { get; private set; } // // LoginRes.UserId == LoginInfo.Name(Cache) == AccountAttr.id(DB) // public string Id { get; set; } = string.Empty; // public string AccountGuid { get; set; } // public string Email { get; set; } // private readonly object _lock = new(); // readonly CancellationTokenSource _cts = new(); // //readonly int KEEP_LOGIN_TIME = 5 * 1000; // /////////////////////////////////////////////////////////////////////////////////////////////// // // - 여기에 추가는 허가 맞고 추가하세요. // // ROW 형태로 DB저장은 꼭 필요한 경우에만 하세요. // // 가극적 Play나 Account에 Attribute를 추가하세요. // /////////////////////////////////////////////////////////////////////////////////////////////// // public LoginInfo _loginInfo = new(); // public Player? _selectedChar; // public MyHome myHome = new(); // public IntPtr GameGuardInstance; // public OwnedLand ownedLand = new(); // public OwnedBuilding ownedBuilding = new(); // public OwnedRoom ownedRoom = new(); // public OwnedMail ownedMail = new(); // public OwnedSocialAction ownedSocialAction = new(); // public OwnedEmotion ownedEmotion = new(); // public AccountGameOptionEntity ownedGameOptionEntity = new(); // public CharMetaDataEntity ownedCharMetaDataEntity = new(); // public OwnedCart ownedCart = new(); // public OwnedShop ownedShop = new(); // public OwnedFriendList ownedFriendList = new(); // /////////////////////////////////////////////////////////////////////////////////////////////// // public override string ToString() // { // string str = string.Empty; // if (_selectedChar != null) // { // str = $"{{\"hostid\" = \"{HostId}\", \"accountGuid\" = \"{AccountGuid}\", \"AccountID\" = \"{Id}\", \"DisplayName\" = \"{_selectedChar?._charEntity.CharInfo.DisplayName}\"}}"; // } // else // { // str = $"{{\"hostid\" = \"{HostId}\", \"accountGuid\" = \"{AccountGuid}\", \"AccountID\" = \"{Id}\"}}"; // } // return str; // } // public TaskSerializer _serializer = new TaskSerializer(); // public DateTime lastPacketReceivTime = DateTime.MinValue; // public bool _StartMoving { get; set; } // public bool IsClosedProcessed { get; set; } = false; // /// // /// 현재 인스턴스 룸 아이디 // /// // public string InstanceRoomId { get; set; } = string.Empty; // /// // /// 현재 인스턴스 아이디 // /// // public int InstanceId { get; set; } = 0; // public Pos LastPosBeforeCESConcert // { // get { return lastPosBeforeCESConcert; } // set // { // lastPosBeforeCESConcert = value.Clone(); // } // } // Pos lastPosBeforeCESConcert = new(); // private readonly object _lockJoiningParty = new(); // public bool isJoiningParty { get; set; } = false; // public string PartyGuid { get; set; } = string.Empty; // public string SummonerAccountId { get; set; } = string.Empty; // public string SummonWorldName { get; set; } = string.Empty; // public Pos SummonPos // { // get { return _summonPos; } // set // { // _summonPos = value.Clone(); // } // } // Pos _summonPos = new(); // TaskCompletionSource? _partyVoteTaskCS; // public ClientSession(HostID hosid, string id, string accountGuid) // { // HostId = hosid; // Id = id; // AccountGuid = accountGuid; // _StartMoving = false; // } // public bool GameGuardInitialize() // { // if (GameServerApp.Instance.Config.GameGuard == true) // { // GameGuardInstance = GameGuardHelper.CSAuth3_CreateInstance(); // if (GameGuardInstance == IntPtr.Zero) // { // return false; // } // UInt32 uReturn = GameGuardHelper.CSAuth3_Init(GameGuardInstance, true); // if (uReturn > 0) // { // Log.getLogger().error($"GameGuard user init failed. uReturn : {uReturn}"); // return false; // } // } // return true; // } // public async Task Close() // { // if (IsClosedProcessed) // return; // _cts.Cancel(); // await SaveDB(); // if (_selectedChar?.map != null) // { // if (_selectedChar.map.Anchors.TryGetValue(_selectedChar.OccupiedAnchorGuid, out var anchorInfo)) // { // anchorInfo.OccupyingUserGuid = string.Empty; // } // } // switch (GameServerApp.Instance.Config.GameServerType) // { // case EGameServerType.Channel: // { // _selectedChar?.LeaveWorld(); // } // break; // case EGameServerType.Indun: // { // if (InstanceRoomId != string.Empty) // { // _ = InstanceRoomManager.Instance.LeaveRoom(this, InstanceRoomId, true); // } // if (_selectedChar != null) // { // if (_selectedChar.LastPositionInfo.EnterInstanceInfo.InstanceRoomId != string.Empty && !_StartMoving) // { // _ = GameServerApp.Instance.InstanceRoomStorage.LeaveInstanceRoom(_selectedChar.LastPositionInfo.EnterInstanceInfo.InstanceRoomId, Id, _selectedChar.LastPositionInfo.EnterInstanceInfo.InstanceId); // } // } // } // break; // default: // break; // } // if (!_StartMoving) // { // if (!PartyGuid.isNullOrWhiteSpace()) // await PartyHandler.LeaveParty(PartyGuid, this); // await PartyHandler.ClearInviteParty(Id); // //await GameServerApp.Instance.CharacterStorage.Leave(AccountGuid); // await GameServerApp.Instance.LoginStorage.Logout(Id); // } // else // { // if (!PartyGuid.isNullOrWhiteSpace()) // await PartyManager.Instance.LeaveParty(PartyGuid, this); // } // IsClosedProcessed = true; // if (GameServerApp.Instance.Config.GameGuard == true) // { // GameGuardHelper.CSAuth3_Close(GameGuardInstance); // } // GameServer.Instance._srv.CloseConnection(HostId); // if (null != _selectedChar) // { // var log_invoker = new GameLogInOutBusinessLog( new LogActionEx(LogActionType.UserLogout) // , DateTimeHelper.Current // , this.toLogoutUserLogInfo() ); // BusinessLogger.collectLog(_selectedChar, log_invoker); // //퀘스트 정보 관련 로그 추가 (임시) // writeTempQuestInfoLog(_selectedChar); // } // } // private void writeTempQuestInfoLog(Player player) // { // var quests = player.ownedQuestList.questListEntity.Quests; // Log.getLogger().debug($"{player.accountId} Quests : {JsonConvert.SerializeObject(quests)}"); // } // private async Task SaveDB() // { // if (_selectedChar == null) // { // return; // } // if (GameServerApp.Instance.MainDB == null) // { // Log.getLogger().error("GameServerApp.Instance.MainDB==null", ToString()); // return; // } // _selectedChar._charEntity.EquipInfo.ToolItemGuid = string.Empty; // _selectedChar._charEntity.EquipInfo.ToolItemId = 0; // _selectedChar._charEntity.EquipInfo.ToolItemStep = 0; // await GameServerApp.Instance.MainDB.SaveChar(_selectedChar._charEntity); // await _selectedChar._inventory.SaveInventory(); // } // public async Task LoadDB() // { // if (_selectedChar == null) // { // return false; // } // if (!await ownedLand.LoadDB(AccountGuid, _selectedChar._charEntity.eoa)) // { // Log.getLogger().error($"{Id} ownedLand LoadDB Fail !!!", ToString()); // return false; // } // if (!await ownedBuilding.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} ownedBuilding LoadDB Fail !!!", ToString()); // return false; // } // if (!await ownedRoom.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} ownedRoom LoadDB Fail !!!", ToString()); // return false; // } // if (!await myHome.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} myHome LoadDB Fail !!!", ToString()); // return false; // } // if (!await ownedSocialAction.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} ownedSocialAction LoadDB Fail !!!", ToString()); // return false; // } // if (!await ownedEmotion.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} ownedEmotion LoadDB Fail !!!", ToString()); // return false; // } // if (!await LoadGameOption()) // { // Log.getLogger().error($"{Id} LoadGameOption LoadDB Fail !!!", ToString()); // return false; // } // if (!await LoadCharMetaData()) // { // Log.getLogger().error($"{Id} LoadCharMetaData LoadDB Fail !!!", ToString()); // return false; // } // await updateSystemMail(); // if (!await ownedMail.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} ownedMail LoadDB Fail !!!", ToString()); // return false; // } // if (!await ownedCart.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} ownedCart LoadDB Fail !!!", ToString()); // return false; // } // if(! await ownedShop.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} ownedShop LoadDB Fail !!!", ToString()); // return false; // } // if (!await ownedFriendList.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} ownedFriendList LoadDB Fail !!!", ToString()); // return false; // } // if (!await _selectedChar.ownedBlockList.LoadDB(AccountGuid)) // { // Log.getLogger().error($"{Id} ownedBlockList LoadDB Fail !!!", ToString()); // return false; // } // //_selectedChar = new Dictionary() // if (!_selectedChar.archiveEvents.TryAdd(EEventType.ClaimReward, new ArchiveClaimEvent(_selectedChar))) // { // Log.getLogger().error($"{Id} archiveEvents new Fail !!!", ToString()); // return false; // } // foreach (var ev in _selectedChar.archiveEvents.Values) // { // var result = await ev.onInit(); // if (result.isFail()) // { // Log.getLogger().error($"{ev.GetType()} OnInit Fail !!!", ToString()); // } // ev.OnTick(); // } // await LoadMovePlayerInfo(); // string nickName = getUserNickname(); // NickNameEntity? nickNameEntity = await GameServerApp.Instance.MainDB.GetEntityFromNickName(nickName); // if (getUserNickname() != "" && nickNameEntity == null) // { // nickNameEntity = await GameServerApp.Instance.MainDB.InsertNickName(nickName, AccountGuid, Id); // if (nickNameEntity == null) // { // Log.getLogger().error($"{Id} nickNameEntity Insert Fail !!!", ToString()); // return false; // } // } // if (nickNameEntity != null) // { // _selectedChar._nickNameEntity = nickNameEntity; // } // return true; // } // public async Task LoadMovePlayerInfo() // { // var movePlayerInfo = await GameServerApp.Instance.moveServerPlayerInfoStorage.GetPlayerInfo(Id); // if (movePlayerInfo != null) // { // ownedMail.SaveMovePlayerInfo(movePlayerInfo); // } // } // public bool Send(RmiContext rmictx, ClientToGame msg) // { // Log.getLogger().debug($"{Id}{msg}", ToString()); // return GameServer.Instance.Send(HostId, rmictx, msg); // } // public void SendInfo() // { // LandManager.Instance.SendInfo(HostId); // BuildingManager.Instance.SendInfo(HostId); // RoomManager.Instance.SendInfo(HostId); // _selectedChar?.SendInfo(); // ownedLand.SendInfo(HostId); // ownedBuilding.SendInfo(HostId); // ownedRoom.SendInfo(HostId); // myHome.SendInfo(HostId, Id); // ownedSocialAction.SendInfo(HostId); // ownedEmotion.SendInfo(HostId); // SendGameOption(); // ownedFriendList.SendInfo(HostId); // _selectedChar?.ownedBlockList.SendInfo(HostId); // _selectedChar?._ownedBuff.SendInfo(HostId); // _selectedChar?.SendMinimapMarker(); // } // public void SendInfoFromLogin() // { // ownedMail.SendInfoFromLogin(HostId); // ownedCart.SendInfoFromLogin(HostId); // if (_selectedChar is null) return; // _selectedChar.ownedQuestList.SendInfoFromLogin(HostId); // } // public async Task LoadCharMetaData() // { // var document = await GameServerApp.Instance.MainDB.GetCharMetaData(AccountGuid); // if (document == null) // { // document = await GameServerApp.Instance.MainDB.InsertCharMetaData(AccountGuid); // if (document == null) // { // Log.getLogger().error("OptionDocument Insert Failed"); // return false; // } // } // if (ownedCharMetaDataEntity.ReadFrom(document) == false) // { // Log.getLogger().error("OptionDocument ReadFrom Failed"); // return false; // } // CharMetaDataEntity MetaDataEntity = new CharMetaDataEntity(ownedCharMetaDataEntity.DocumentForUpdate()); // bool needUpdate = false; // CheckMailSendTime(MetaDataEntity, ref needUpdate); // if (needUpdate == true) // { // if (await GameServerApp.Instance.MainDB.UpdateDocument(MetaDataEntity.DocumentForUpdate()) == false) // { // Log.getLogger().error("DB ownedCharMetaDataEntity UpdateCharMetaData Failed."); // return false; // } // ownedCharMetaDataEntity.ReadFrom(MetaDataEntity.DocumentForUpdate()); // } // return true; // } // public void CheckMailSendTime(CharMetaDataEntity charMetaDataEntity, ref bool needUpdate) // { // if (charMetaDataEntity.Attr.MailSendUpdateDay < DateTime.UtcNow.Date.Ticks) // { // charMetaDataEntity.Attr.MailSendCount = 0; // charMetaDataEntity.Attr.MailSendUpdateDay = DateTime.UtcNow.Date.Ticks; // needUpdate = true; // } // } // public async Task CheatMailSendUpdateDay() // { // ownedCharMetaDataEntity.Attr.MailSendUpdateDay = DateTime.UtcNow.AddDays(-1).Ticks; // if (await GameServerApp.Instance.MainDB.UpdateCharMetaData(ownedCharMetaDataEntity) == false) // { // Log.getLogger().error("DB ownedCharMetaDataEntity UpdateCharMetaData Failed."); // return false; // } // return true; // } // public async Task CheatModifyCurrency(string[] args) // { // if (_selectedChar is null) // { // Log.getLogger().error("CheatModifyCurrency _selectedChar is null"); // return false; // } // if (args.Length < 4) // { // Log.getLogger().error($"CheatModifyCurrency arg length short Length : {args.Length} "); // return false; // } // long max = 999999999; // double gold = 0; // double blue = 0; // double red = 0; // double black = 0; // try // { // gold = double.Parse(args[0]); // blue = double.Parse(args[1]); // red = double.Parse(args[2]); // black = double.Parse(args[3]); // } // catch (Exception e) // { // Log.getLogger().error($"Currency Parsing Error: {args[0]}, {args[1]}, {args[2]}, {args[3]} {e}"); // return false; // } // if (gold > max) gold = max; // if (blue > max) blue = max; // if (red > max) red = max; // if (black > max) black = max; // _selectedChar._charEntity.CharInfo.Gold = gold; // _selectedChar._charEntity.CharInfo.Sapphire = blue; // _selectedChar._charEntity.CharInfo.Calium = red; // _selectedChar._charEntity.CharInfo.Beam = black; // await GameServerApp.Instance.MainDB.SaveChar(_selectedChar._charEntity); // //여기에 Res 처리 // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.GetCurrencyInfoRes = new(); // clientToGame.Response.GetCurrencyInfoRes.CurrencyInfo = _selectedChar._charEntity.CharInfo; // Send(RmiContext.ReliableSend, clientToGame); // return true; // } // public void SendGameOption() // { // ClientToGame clientToGame = new(); // clientToGame.Message = new(); // clientToGame.Message.GameOptionNoti = new(); // byte[] byteOptions = Convert.FromBase64String(ownedGameOptionEntity.Attr.options); // clientToGame.Message.GameOptionNoti.ValuesList.AddRange(Array.ConvertAll(byteOptions, Convert.ToInt32).ToList()); // Send(RmiContext.ReliableSend, clientToGame); // } // public async Task SaveGameOption(RepeatedField gameOptionList) // { // Document backupDocument = ownedGameOptionEntity.DocumentForUpdate(); // try // { // byte[] byteOptions = Array.ConvertAll(gameOptionList.ToArray(), Convert.ToByte); // ownedGameOptionEntity.Attr.options = Convert.ToBase64String(byteOptions); // } // catch // { // Log.getLogger().error($"Convert Failed. GameOption Size is too big."); // return false; // } // Document document = ownedGameOptionEntity.DocumentForUpdate(); // if (await GameServerApp.Instance.MainDB.UpdateDocument(document) == false) // { // Log.getLogger().error($"DB Update Failed PK : {ownedGameOptionEntity.PK_Guid}"); // ownedGameOptionEntity.ReadFrom(backupDocument); // return false; // } // return true; // } // public async Task LoadGameOption() // { // var document = await GameServerApp.Instance.MainDB.GetGameOption(AccountGuid); // if (document == null) // { // document = await GameServerApp.Instance.MainDB.InsertGameOption(AccountGuid, new AccountGameOptionAttr()); // if (document == null) // { // Log.getLogger().error("OptionDocument Insert Failed"); // return false; // } // } // if (ownedGameOptionEntity.ReadFrom(document) == false) // { // Log.getLogger().error("OptionDocument ReadFrom Failed"); // return false; // } // return true; // } // public async Task KeepLogin() // { // try // { // await GameServerApp.Instance.LoginStorage.KeepLogin(Id, _loginInfo); // } // catch (Exception ex) // { // Log.getLogger().error($"KeepLogin {ex} {Id}"); // // throw; // } // } // public void ConcurrentUsersCountNotiToOperator(Dictionary userGroupCount) // { // if (_selectedChar == null || _selectedChar._charEntity == null || _selectedChar._charEntity.CharInfo == null) // return; // if (_selectedChar._charEntity.CharInfo.Operator != 1) // return; // var group = _selectedChar._charEntity.CharInfo.Usergroup; // if (!userGroupCount.TryGetValue(group, out var count)) // return; // ClientToGame clientToGame = new(); // clientToGame.Message = new(); // clientToGame.Message.ConcurrentUsersCountNoti = new(); // clientToGame.Message.ConcurrentUsersCountNoti.Count = count; // Send(RmiContext.ReliableSend, clientToGame); // } // public async Task AutoSelectChar(LoginInfo loginInfo) // { // List? list = await GameServerApp.Instance.MainDB.ListChar(AccountGuid); // if (list == null) // { // Log.getLogger().error($"list is null {JsonConvert.SerializeObject(loginInfo)}"); // return false; // } // var result = new Result(); // bool is_new_create_char = false; // bool isNeedSendQuestMail = false; // if (list.Count < 1) // { // Log.getLogger().debug($"InsertChar {AccountGuid} {Id}"); // result = await createCharacter(AccountGuid, Id, loginInfo.Email, loginInfo.Language); // if (result.isFail()) // { // return false; // } // list.Add(_selectedChar._charEntity); // isNeedSendQuestMail = true; // } // else // { // _selectedChar = new Player(HostId, loginInfo.Email, list[0]); // if (_selectedChar.accountId == string.Empty) // { // _selectedChar._charEntity.Id = Id; // } // _selectedChar._charEntity.CharInfo.LanguageInfo = (int)loginInfo.Language; // } // _loginInfo = loginInfo; // // 일단 임시로 여기서 LoginToGame 로그를 작성 한다. // // 나중에 플레이어 객체 생성후 LoginToGame 로그를 안전하게 작성할 수 있도록 // // 객체들과 정보들의 계층 구조를 설계 및 로직화 한다. // var log_invoker = new GameLogInOutBusinessLog( new LogActionEx(LogActionType.LoginToGame) // , DateTimeHelper.Current, this.toLoginUserLogInfo()); // BusinessLogger.collectLog(_selectedChar, log_invoker); // bool isFromLogin = loginInfo.CurrentServer.Contains(EServerType.Login.ToString()); // if (loginInfo.Moving != null) // { // loginInfo.CurrentServer = loginInfo.Moving.DestServer; // } // loginInfo.Moving = null; // // 로그인 진입 상태 인가? // if (true == isFromLogin) // { // // 캐릭터를 초기화 한다. // var is_success = await initChar(); // if (false == is_success) // { // return false; // } // } // if (GameServerApp.Instance.Config.NftRule.NftDBAccess) // { // var (error_code, eoa) = await NFTHelper.getEOA(Id); // if (error_code.isFail()) // { // Log.getLogger().error($"{Id} GetEOA Fail"); // return false; // } // _selectedChar._charEntity.eoa = eoa; // } // if (!await _selectedChar.LoadDB()) // { // Log.getLogger().error($"{Id} LoadDB Fail !!!", ToString()); // return false; // } // if (isFromLogin && GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel) // { // if (!await UserInitialize(Id)) // { // Log.getLogger().error($"{Id} UserInitialize Fail !!!", ToString()); // return false; // } // } // // 초기 위치 셋팅 // var lastPosition = await GameServerApp.Instance.LastPositionStorage.GetLastPositionInfo(AccountGuid); // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel) // { // if (isFromLogin) // { // bool is_set_to_spawn_pos = false; // // 테스트 계정용 스폰 위치 초기화를 설정 한다. // foreach (var data in TableData.Instance.m_test_user_initial_meta_datas.Values) // { // if (false == Id.ToLower().StartsWith(data.IdPattern)) // { // continue; // } // _selectedChar.CharPos.Pos = ServerUtil.MakePos(data.StartX, data.StartY, data.StartZ, data.StartAngle); // is_set_to_spawn_pos = true; // } // if(false == is_set_to_spawn_pos) // { // if (TableData.Instance._TestAccountTable.TryGetValue(Id, out var userData)) // { // _selectedChar.CharPos.Pos = ServerUtil.MakePos(userData.StartX, userData.StartY, userData.StartZ, userData.StartAngle); // is_set_to_spawn_pos = true; // } // } // // 스폰 위치 초기화를 설정하지 못했다면 // if (false == is_set_to_spawn_pos) // { // if (GameServer.Instance.Map == null) // { // Log.getLogger().error($"{Id} Channel Server Map is null"); // return false; // } // //if (_selectedChar._charEntity.CharInfo.IsIntroComplete == 0) // if (_selectedChar._charEntity.AvatarInfo.Init == 1) // { // if (!GameServer.Instance.Map.getAccountStartPoint(out var accountStartPoint)) // { // Log.getLogger().error($"{Id} getAccountStartPoint fail"); // return false; // } // _selectedChar.CharPos.Pos = accountStartPoint; // } // else // { // _selectedChar.CharPos.Pos = _selectedChar._charEntity.LastGameServerPos.Pos.Clone(); // if (GameServer.Instance.Map.GetNearestStartPoint(_selectedChar._charEntity.LastGameServerPos.Pos, out var startPointPos)) // { // _selectedChar.CharPos.Pos = startPointPos; // } // } // } // } // else // { // if (lastPosition is not null) // { // _selectedChar.CharPos.Pos = ServerUtil.MakePos(lastPosition.LastGameServerPos.X, lastPosition.LastGameServerPos.Y, lastPosition.LastGameServerPos.Z, lastPosition.LastGameServerPos.Angle); // } // else // { // Log.getLogger().debug($"{Id} {GameServerApp.Instance.Config.GameServerType} Server LastPosition is null"); // } // } // if (Id.StartsWith(ServerCommon.Constant.BOT_CLIENT)) // { // if (MapManager.Instance.GetBotStartPos(Id, out var boStartPos)) // { // _selectedChar.CharPos.Pos = boStartPos; // } // } // } // else // { // if (lastPosition is not null) // { // _selectedChar.LastPositionInfo = lastPosition; // _selectedChar.CharPos.Pos = _selectedChar.LastPositionInfo.EnterInstanceInfo.InstanceRoomPos; // } // else // { // Log.getLogger().debug($"{Id} {GameServerApp.Instance.Config.GameServerType} Server LastPosition is null"); // } // } // await _selectedChar._ownedBuff.InitLoadRedisBuff(Id, _selectedChar); // if (isNeedSendQuestMail) // { // } // return true; // } // public async Task createCharacter(string accountGuid, string id, string email, LanguageType languageType) // { // var result = new Result(); // var err_msg = string.Empty; // var user_attrib = new CharEntity(); // result = MetaHelper.fillupUserAttrib(Id, languageType, ref user_attrib); // if (result.isFail()) // { // return result; // } // _selectedChar = new Player(HostId, email, user_attrib); // if (_selectedChar.accountId == string.Empty) // { // _selectedChar._charEntity.Id = Id; // } // Log.getLogger().debug(JsonConvert.SerializeObject(user_attrib)); // user_attrib.PK_Guid = accountGuid; // var documents = new List(); // var item_entitys = new List(); // try // { // user_attrib.PK_Guid = accountGuid; // user_attrib.Id = id; // documents.Add(new DBDocumentInfo(MainDB.DocumentForInsert(EEntityType.Character, accountGuid, accountGuid, user_attrib), EDBExecuteType.Insert)); // documents.Add(new DBDocumentInfo(MainDB.DocumentForInsert(EEntityType.CharList, accountGuid, accountGuid), EDBExecuteType.Insert)); // var inventory_document = MainDB.DocumentForInsert(EEntityType.Inventory, accountGuid, "", new InventoryAttr()); // var new_inventory_entity = await _selectedChar._inventory.getInventoryEntityAfterReadDocument(inventory_document); // _selectedChar._inventory.SetOwner(accountGuid); // if(null == new_inventory_entity) // { // err_msg = $"Failed to get InventoryEntity !!! : userId:{Id}"; // result.setFail(ServerErrorCode.InventoryEntityEmpty, err_msg); // ServerCore.Log.getLogger().error(result.toBasicString()); // return result; // } // var toolslot_document = MainDB.DocumentForInsert(EEntityType.ToolSlot, accountGuid, "", new InventoryAttr()); // if (false == _selectedChar._toolSlotEntity.ReadFrom(toolslot_document)) // { // err_msg = $"Failed to read ToolSlotEntity !!! : userId:{Id}"; // result.setFail(ServerErrorCode.ToolSlotEntityEmpty, err_msg); // ServerCore.Log.getLogger().error(result.toBasicString()); // return result; // } // if (true == TableData.Instance.m_test_user_create_meta_datas.TryGetValue(Id, out var found_test_user_create_data)) // { // var inventory_item_meta_ids = found_test_user_create_data.InventoryItems.toMetaIds(); // foreach (var item_meta_id in inventory_item_meta_ids) // { // if (true == _selectedChar._inventory.HasItem(item_meta_id)) // { // continue; // } // if (false == _selectedChar._inventory.AddItem( item_meta_id, 1, new_inventory_entity // , out var added_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Faield to add Item !!!, to Inventory : errorCode:{error_code}, itemMId:{item_meta_id} - userId:{Id}"); // continue; // } // item_entitys.AddRange(added_items); // } // var wearing_item_meta_ids = found_test_user_create_data.WearingItems.toMetaIds(); // foreach (var item_meta_id in wearing_item_meta_ids) // { // if (false == TableData.Instance._ItemTable.TryGetValue(item_meta_id, out var itemData)) // { // ServerCore.Log.getLogger().error($"Not found Item !!! : itemMId:{item_meta_id}"); // continue; // } // if (false == itemData.isClothType()) // { // ServerCore.Log.getLogger().error($"Not Cloth Item !!! : itemMId:{item_meta_id}"); // continue; // } // var found_items = _selectedChar._inventory.GetItem(item_meta_id); // if (found_items.Count <= 0) // { // if (!_selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out found_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Failed to add Item !!! : errorCode:{error_code}, itemMId:{item_meta_id}"); // continue; // } // item_entitys.AddRange(found_items); // } // if (!_selectedChar.EquipCloth(found_items[0])) // { // ServerCore.Log.getLogger().error($"Failed to equip Cloth !!! : itemMid:{item_meta_id}"); // continue; // } // } // var tool_item_meta_ids = found_test_user_create_data.ToolPresets.toMetaIds(); // foreach (var (item_meta_id, index) in tool_item_meta_ids.Select((item_meta_id, index) => (item_meta_id, index))) // { // if (item_meta_id == 0) // { // _selectedChar.DeregisterToolSlot(index, out _); // } // else // { // var found_items = _selectedChar._inventory.GetItem(item_meta_id); // if (found_items.Count <= 0) // { // if (!_selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out found_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Failed to add Tool Item !!! : : errorCode:{error_code}, itemMid:{item_meta_id}"); // continue; // } // item_entitys.AddRange(found_items); // } // _selectedChar.RegisterToolSlot(index, found_items[0].Attr.ItemGuid, out _); // } // } // var tatto_item_meta_ids = found_test_user_create_data.TattooItems.toMetaIds(); // foreach (var (item_meta_id, index) in tatto_item_meta_ids.Select((item_meta_id, index) => (item_meta_id, index))) // { // if (item_meta_id == 0) // { // _selectedChar.DeregisterTattooSlot(index, out _); // } // else // { // var found_items = _selectedChar._inventory.GetItem(item_meta_id); // if (found_items.Count <= 0) // { // if (!_selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out found_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Failed to add Tatoo Item !!! : : errorCode:{error_code}, itemMid:{item_meta_id}"); // continue; // } // item_entitys.AddRange(found_items); // } // _selectedChar.RegisterTattooSlot(index, found_items[0].Attr.ItemGuid, out _); // } // } // } // else // { // // 현재 한개만 등록되어 있어서 1번 메타만 참조 한다. // if (true == TableData.Instance.m_user_create_meta_datas.TryGetValue(1, out var found_user_create_data)) // { // var inventory_item_meta_ids = found_user_create_data.InventoryItems.toMetaIds(); // foreach (var item_meta_id in inventory_item_meta_ids) // { // if (true == _selectedChar._inventory.HasItem(item_meta_id)) // { // continue; // } // if (false == _selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out var added_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Faield to add Item !!!, to Inventory : errorCode:{error_code}, itemMId:{item_meta_id} - userId:{Id}"); // continue; // } // item_entitys.AddRange(added_items); // } // var wearing_item_meta_ids = found_user_create_data.WearingItems.toMetaIds(); // foreach (var item_meta_id in wearing_item_meta_ids) // { // if (false == TableData.Instance._ItemTable.TryGetValue(item_meta_id, out var itemData)) // { // ServerCore.Log.getLogger().error($"Not found Item !!! : itemMId:{item_meta_id}"); // continue; // } // if (false == itemData.isClothType()) // { // ServerCore.Log.getLogger().error($"Not Cloth Item !!! : itemMId:{item_meta_id}"); // continue; // } // var found_items = _selectedChar._inventory.GetItem(item_meta_id); // if (found_items.Count <= 0) // { // if (!_selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out found_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Failed to add Item !!! : errorCode:{error_code}, itemMId:{item_meta_id}"); // continue; // } // item_entitys.AddRange(found_items); // } // if (!_selectedChar.EquipCloth(found_items[0])) // { // ServerCore.Log.getLogger().error($"Failed to equip Cloth !!! : itemMid:{item_meta_id}"); // continue; // } // } // var tool_item_meta_ids = found_user_create_data.ToolPresets.toMetaIds(); // foreach (var (item_meta_id, index) in tool_item_meta_ids.Select((item_meta_id, index) => (item_meta_id, index))) // { // if (item_meta_id == 0) // { // _selectedChar.DeregisterToolSlot(index, out _); // } // else // { // var found_items = _selectedChar._inventory.GetItem(item_meta_id); // if (found_items.Count <= 0) // { // if (!_selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out found_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Failed to add Tool Item !!! : errorCode:{error_code}, itemMid:{item_meta_id}"); // continue; // } // item_entitys.AddRange(found_items); // } // _selectedChar.RegisterToolSlot(index, found_items[0].Attr.ItemGuid, out _); // } // } // _selectedChar._charEntity.CharInfo.Gold = found_user_create_data.CurrencyGold; // _selectedChar._charEntity.CharInfo.Sapphire = found_user_create_data.CurrencySapphire; // _selectedChar._charEntity.CharInfo.Calium = found_user_create_data.CurrencyCalium; // _selectedChar._charEntity.CharInfo.Ruby = found_user_create_data.CurrencyRuby; // } // } // documents.Add(new DBDocumentInfo(new_inventory_entity.DocumentForUpdate(), EDBExecuteType.Update)); // foreach (var item in item_entitys) // { // documents.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update)); // } // documents.Add(new DBDocumentInfo(_selectedChar._toolSlotEntity.DocumentForUpdate(), EDBExecuteType.Update)); // documents.Add(new DBDocumentInfo(_selectedChar._tattooSlotEntity.DocumentForUpdate(), EDBExecuteType.Update)); // if (false == await GameServerApp.Instance.MainDB.Transaction(documents, 2)) // { // err_msg = $"Failed to transact DB when create Character !!! : userId:{Id}"; // result.setFail(ServerErrorCode.DynamoDbTransactException, err_msg); // ServerCore.Log.getLogger().error(result.toBasicString()); // return result; // } // await SaveDB(); // } // catch (Exception ex) // { // err_msg = $"Failed to transact DB when create Character !!! : errDesc:{ex.ToString()} - userId:{Id}"; // result.setFail(ServerErrorCode.DynamoDbTransactException, err_msg); // ServerCore.Log.getLogger().error(result.toBasicString()); // return result; // } // return result; // } // public async Task initChar() // { // var err_msg = string.Empty; // foreach (var data in TableData.Instance.m_test_user_initial_meta_datas.Values) // { // if (false == Id.ToLower().StartsWith(data.IdPattern)) // { // continue; // } // var inventory_document = MainDB.DocumentForInsert(EEntityType.Inventory, AccountGuid, "", new InventoryAttr()); // var new_inventory_entity = await _selectedChar._inventory.getInventoryEntityAfterReadDocument(inventory_document); // var toolSlot_document = MainDB.DocumentForInsert(EEntityType.ToolSlot, AccountGuid, "", new ToolSlotAttr()); // ToolSlotEntity newToolSlotEntity = new(toolSlot_document); // var tattoo_document = MainDB.DocumentForInsert(EEntityType.TattooSlot, AccountGuid, "", new TattooSlotAttr()); // TattooSlotEntity newTattooSlotEntity = new(tattoo_document); // if (null == new_inventory_entity) // { // err_msg = $"Failed to get InventoryEntity !!! : userId:{Id}"; // var result = new Result(); // result.setFail(ServerErrorCode.InventoryEntityEmpty, err_msg); // ServerCore.Log.getLogger().error(result.toBasicString()); // return false; // } // if (true == data.IsInventoryInitialize) // { // if (false == await _selectedChar._inventory.ClearDB()) // { // err_msg = $"Failed to clear DB of Inventory !!! : userId:{Id}"; // ServerCore.Log.getLogger().error(err_msg); // return false; // } // _selectedChar._inventory.Clear(); // } // if (data.IsMailInitialize) // { // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.ReceivedMail, AccountGuid); // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.SendedMail, AccountGuid); // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.CharMetaData, AccountGuid); // } // if (data.IsMyHomeInitialize) // { // await GameServerApp.Instance.MainDB.DeleteMyHome(AccountGuid, 0); // } // if (data.IsSocialActionInitialize) // { // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.SocialActionCollection, AccountGuid); // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.SocialActionSlot, AccountGuid); // } // if (data.IsAvatarCustomize) // { // _selectedChar._charEntity.AvatarInfo.Init = 1; // } // if (data.IsResetToItemsOfTestUserCreate) // { // if (false == await _selectedChar._inventory.ClearDB()) // { // err_msg = $"Failed to clear DB of Inventory !!! : userId:{Id}"; // ServerCore.Log.getLogger().error(err_msg); // return false; // } // _selectedChar._inventory.Clear(); // _selectedChar._inventory.SetOwner(AccountGuid); // _selectedChar._charEntity.ClothInfo = new ClothInfo(); // if (true == TableData.Instance.m_test_user_create_meta_datas.TryGetValue(Id, out var found_test_user_create_data)) // { // var documents = new List(); // var item_entitys = new List(); // var inventory_item_meta_ids = found_test_user_create_data.InventoryItems.toMetaIds(); // foreach (var item_meta_id in inventory_item_meta_ids) // { // if (true == _selectedChar._inventory.HasItem(item_meta_id)) // { // continue; // } // if (false == _selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out var added_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Faield to add Item !!!, to Inventory : errorCode:{error_code}, itemMId:{item_meta_id} - userId:{Id}"); // continue; // } // item_entitys.AddRange(added_items); // } // var wearing_item_meta_ids = found_test_user_create_data.WearingItems.toMetaIds(); // foreach (var item_meta_id in wearing_item_meta_ids) // { // if (false == TableData.Instance._ItemTable.TryGetValue(item_meta_id, out var itemData)) // { // ServerCore.Log.getLogger().error($"Not found Item !!! : itemMId:{item_meta_id}"); // continue; // } // if (false == itemData.isClothType()) // { // ServerCore.Log.getLogger().error($"Not Cloth Item !!! : itemMId:{item_meta_id}"); // continue; // } // var found_items = _selectedChar._inventory.GetItem(item_meta_id); // if (found_items.Count <= 0) // { // if (!_selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out found_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Failed to add Item !!! : errorCode:{error_code}, itemMId:{item_meta_id}"); // continue; // } // item_entitys.AddRange(found_items); // } // if (!_selectedChar.EquipCloth(found_items[0])) // { // ServerCore.Log.getLogger().error($"Failed to equip Cloth !!! : itemMid:{item_meta_id}"); // continue; // } // } // var tool_item_meta_ids = found_test_user_create_data.ToolPresets.toMetaIds(); // foreach (var (item_meta_id, index) in tool_item_meta_ids.Select((item_meta_id, index) => (item_meta_id, index))) // { // if (item_meta_id == 0) // { // _selectedChar.DeregisterToolSlot(index, out _); // } // else // { // var found_items = _selectedChar._inventory.GetItem(item_meta_id); // if (found_items.Count <= 0) // { // if (!_selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out found_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Failed to add Tool Item !!! : : errorCode:{error_code}, itemMid:{item_meta_id}"); // continue; // } // item_entitys.AddRange(found_items); // } // newToolSlotEntity.Attr.slotInfos[index] = found_items[0].Attr.ItemGuid; // } // } // var tatto_item_meta_ids = found_test_user_create_data.TattooItems.toMetaIds(); // foreach (var (item_meta_id, index) in tatto_item_meta_ids.Select((item_meta_id, index) => (item_meta_id, index))) // { // if (item_meta_id == 0) // { // _selectedChar.DeregisterTattooSlot(index, out _); // } // else // { // var found_items = _selectedChar._inventory.GetItem(item_meta_id); // if (found_items.Count <= 0) // { // if (!_selectedChar._inventory.AddItem(item_meta_id, 1, new_inventory_entity // , out found_items, out var error_code, out _)) // { // ServerCore.Log.getLogger().error($"Failed to add Tatoo Item !!! : : errorCode:{error_code}, itemMid:{item_meta_id}"); // continue; // } // item_entitys.AddRange(found_items); // } // if(TableData.Instance._ItemTable.TryGetValue(found_items[0].Attr.ItemId, out var itemMetaData) == false) // { // continue; // } // int slot = 0; // if (itemMetaData.TypeSmall == EItemSmallType.CHEST) slot = 0; // else if (itemMetaData.TypeSmall == EItemSmallType.LEFT_ARM) slot = 1; // else if (itemMetaData.TypeSmall == EItemSmallType.RIGHT_ARM) slot = 2; // else continue; // newTattooSlotEntity.Attr.slotInfos[slot].ItemGuid = found_items[0].Attr.ItemGuid; // } // } // documents.Add(new DBDocumentInfo(new_inventory_entity.DocumentForUpdate(), EDBExecuteType.Update)); // foreach (var item in item_entitys) // { // documents.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update)); // } // documents.Add(new DBDocumentInfo(newToolSlotEntity.DocumentForUpdate(), EDBExecuteType.Update)); // documents.Add(new DBDocumentInfo(newTattooSlotEntity.DocumentForUpdate(), EDBExecuteType.Update)); // if (false == await GameServerApp.Instance.MainDB.Transaction(documents, 2)) // { // err_msg = $"Failed to transact DB when Character init !!! : userId:{Id}"; // var result = new Result(); // result.setFail(ServerErrorCode.DynamoDbTransactException, err_msg); // ServerCore.Log.getLogger().error(result.toBasicString()); // return false; // } // } // } // _selectedChar._charEntity.CharInfo.Gold = data.CurrencyGold; // _selectedChar._charEntity.CharInfo.Sapphire = data.CurrencySapphire; // _selectedChar._charEntity.CharInfo.Calium = data.CurrencyCalium; // _selectedChar._charEntity.CharInfo.Ruby = data.CurrencyRuby // await GameServerApp.Instance.MainDB.SaveChar(_selectedChar._charEntity); // } // return true; // } // //public async Task UserInitialize(string accountId) // //{ // // if (_selectedChar == null) // // { // // Log.getLogger().error("_selectedChar is null"); // // return false; // // } // // List invokers = new List(); // // if (TableData.Instance._TestAccountTable.TryGetValue(Id, out var userData)) // // { // // _selectedChar._charEntity.CharInfo.Usergroup = userData.Usergroup; // // _selectedChar._charEntity.CharInfo.Operator = userData.Operator; // // } // // else // // { // // if (Id.StartsWith(ServerCommon.Constant.BOT_CLIENT) == true) // // { // // _selectedChar._charEntity.CharInfo.Operator = 2; // 봇계정으로 설정 // // _selectedChar._charEntity.CharInfo.DisplayName = Id; // // } // // else // // { // // _selectedChar._charEntity.CharInfo.Operator = 0; // // } // // } // // foreach (var data in TableData.Instance._UserInitialDataTable.Values) // // { // // if (!accountId.ToLower().StartsWith(data.IdPattern)) // // continue; // // if (data.IsInventoryInitialize) // // { // // if (!await _selectedChar._inventory.ClearDB()) // // { // // Log.getLogger().error($"{Id} Inventory ClearDB Fail !!!", ToString()); // // return false; // // } // // _selectedChar._inventory.Clear(); // // } // // if (data.IsMailInitialize) // // { // // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.ReceivedMail, AccountGuid); // // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.SendedMail, AccountGuid); // // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.CharMetaData, AccountGuid); // // } // // if (data.IsMyHomeInitialize) // // { // // await GameServerApp.Instance.MainDB.DeleteMyHome(AccountGuid, 0); // // } // // if (data.IsEmotionInitialize) // // { // // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.EmotionCollection, AccountGuid); // // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.EmotionSlot, AccountGuid); // // } // // if (data.IsSocialActionInitialize) // // { // // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.SocialActionCollection, AccountGuid); // // await GameServerApp.Instance.MainDB.ClearMatchPK(EEntityType.SocialActionSlot, AccountGuid); // // } // // if (data.IsAvatarCustomize) // // { // // _selectedChar._charEntity.AvatarInfo.Init = 1; // // } // // List dBDocumentInfos = new(); // // List itemEntityList = new List(); // // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity); // // foreach (var itemId in data.InventoryItems) // // { // // if (_selectedChar._inventory.HasItem(itemId)) // // continue; // // if (!_selectedChar._inventory.AddItem(itemId, 1, newInventoryEntity, out var Items, out var errorCode, out var itemlogDatas)) // // { // // Log.getLogger().error($"AddItem fail {itemId}"); // // continue; // // } // // itemEntityList.AddRange(Items); // // } // // _selectedChar._charEntity.ClothInfo = new ClothInfo(); // // foreach (var itemId in data.WearingItems) // // { // // if (!TableData.Instance._ItemTable.TryGetValue(itemId, out var itemData)) // // { // // Log.getLogger().error($"Not Found ItemTableId. itemTableId:{itemId}"); // // continue; // // } // // if (itemData.TypeLarge != EItemLargeType.CLOTH) // // { // // Log.getLogger().error($"Item is NOt CLOTH. itemTableId:{itemId}"); // // continue; // // } // // var itemList = _selectedChar._inventory.GetItem(itemId); // // if (itemList.Count <= 0) // // { // // if (!_selectedChar._inventory.AddItem(itemId, 1, newInventoryEntity, out itemList, out var errorCode, out var itemlogDatas)) // // { // // Log.getLogger().error($"AddItem fail {itemId}"); // // continue; // // } // // itemEntityList.AddRange(itemList); // // } // // if (!_selectedChar.EquipCloth(itemList[0])) // // { // // Log.getLogger().error($"EquipCloth fail {itemId}"); // // continue; // // } // // } // // foreach (var (itemId, index) in data.ToolItems.Select((itemId, index) => (itemId, index))) // // { // // if (itemId == 0) // // { // // _selectedChar.DeregisterToolSlot(index, out _); // // } // // else // // { // // var itemList = _selectedChar._inventory.GetItem(itemId); // // if (itemList.Count <= 0) // // { // // if (!_selectedChar._inventory.AddItem(itemId, 1, newInventoryEntity, out itemList, out var errorCode, out var itemlogDatas)) // // { // // Log.getLogger().error($"AddItem fail {itemId}"); // // continue; // // } // // itemEntityList.AddRange(itemList); // // } // // _selectedChar.RegisterToolSlot(index, itemList[0].Attr.ItemGuid, out _); // // } // // } // // _selectedChar.AllDeregisterTattooSlot(out var changedDocument); // // dBDocumentInfos.Add(new DBDocumentInfo(changedDocument, EDBExecuteType.Update)); // // dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update)); // // foreach (var item in itemEntityList) // // { // // dBDocumentInfos.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update)); // // } // // dBDocumentInfos.Add(new DBDocumentInfo(_selectedChar._toolSlotEntity.DocumentForUpdate(), EDBExecuteType.Update)); // // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // // { // // Log.getLogger().error($"DB UpdateInventory Failed."); // // return false; // // } // // _selectedChar.UpdateTattooSlotDBToMemory(changedDocument); // // _selectedChar._inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate()); // // _selectedChar._inventory.UpdateItemDBToMemory(itemEntityList); // // await SaveDB(); // // } // // return true; // //} // /// // /// *연결할 게임서버 정보 얻기*
// /// 마지막 접속 게임서버 확인
// /// 없거나 꽉 찬 경우 기존 게임서버에서 선택 // ///
// /// 접속할 게임서버 정보, 접속할 서버가 없는 경우 null // async Task GetGameServerInfoToConnect(int worldId, LanguageType languageType) // { // if (_selectedChar == null) // { // Log.getLogger().error("_selectChar is null"); // return null; // } // // 마지막 접속 게임서버 확인 // var gameServerInfo = await GameServerApp.Instance.ServerCUStorage.getServerCU(_selectedChar.LastPositionInfo.LastGameServer); // if (gameServerInfo == null || gameServerInfo.Sessions >= gameServerInfo.Capacity) // { // return await GameServerApp.Instance.getBalancedServerInfo(this, (ServerType)GameServer.Instance.myServerInfo.serverType, ServerType.Game, (UInt16)worldId); // //// 현재 게임서버 목록 얻기 // //List serverList = await GameServerApp.Instance.ServerCUStorage.getServersCU(ServerType.Game, worldId); // //if (serverList.Count == 0) // //{ // // // 서버가 없음. 새로운 GameServer 필요. // // Log.getLogger().error($"GameServerList Count is 0 EServerType.Game:{worldId}"); // // return null; // //} // //// 현재 게임서버에서 적당한 서버 고르기 // //int serverIndex = ServerUtil.GetBestGameServerIndex(serverList, languageType); // //if (serverIndex == -1) // //{ // // // 접속 할 수 있는 서버가 없음. 새로운 GameServer 필요. // // Log.getLogger().error("Need GameServer All GameServer is full EServerType.Game:{worldId}"); // // return null; // //} // //gameServerInfo = serverList[serverIndex]; // } // return gameServerInfo; // } // public async Task ProcessRequestPacket(ClientToGameReq request) // { // if (request.MsgCase != ClientToGameReq.MsgOneofCase.MoveReq) // { // Log.getLogger().debug($"{Id} {request}"); // } // switch (request.MsgCase) // { // case ClientToGameReq.MsgOneofCase.ChatReq: // await HandleChatReq(request.ChatReq); // break; // /* // case ClientToGameReq.MsgOneofCase.CreateCharReq: // await HandleCreateCharReq(request.CreateCharReq); // break; // case ClientToGameReq.MsgOneofCase.SelectCharReq: // await HandleSelectCharReq(request.SelectCharReq); // break; // case ClientToGameReq.MsgOneofCase.DeselectCharReq: // await HandleDeselectCharReq(request.DeselectCharReq); // break; // case ClientToGameReq.MsgOneofCase.DeleteCharReq: // await HandleDeleteCharReq(request.DeleteCharReq); // break; // case ClientToGameReq.MsgOneofCase.ListCharReq: // await HandleListCharReq(request.ListCharReq); // break; // */ // case ClientToGameReq.MsgOneofCase.CreateChatRoomReq: // await HandleCreateChatRoomReq(request.CreateChatRoomReq); // break; // case ClientToGameReq.MsgOneofCase.JoinChatRoomReq: // await HandleJoinChatRoomReq(request.JoinChatRoomReq); // break; // case ClientToGameReq.MsgOneofCase.LeaveChatRoomReq: // await HandleLeaveChatRoomReq(request.LeaveChatRoomReq); // break; // case ClientToGameReq.MsgOneofCase.MoveReq: // await HandleMoveReq(request.MoveReq); // break; // case ClientToGameReq.MsgOneofCase.JoinInstanceReq: // await HandleJoinInstanceReq(request.JoinInstanceReq); // break; // case ClientToGameReq.MsgOneofCase.LeaveInstanceReq: // await HandleLeaveInstanceReq(request.LeaveInstanceReq); // break; // case ClientToGameReq.MsgOneofCase.JoinInstanceRoomReq: // await HandleJoinInstanceRoomReq(request.JoinInstanceRoomReq); // break; // case ClientToGameReq.MsgOneofCase.LeaveInstanceRoomReq: // await HandleLeaveInstanceRoomReq(request.LeaveInstanceRoomReq); // break; // case ClientToGameReq.MsgOneofCase.EnterMyHomeReq: // await HandleEnterMyHomeReq(request.EnterMyHomeReq); // break; // case ClientToGameReq.MsgOneofCase.LeaveMyHomeReq: // await HandleLeaveMyHomeReq(request.LeaveMyHomeReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangeMyHomeReq: // await HandleExchangeMyHomeReq(request.ExchangeMyHomeReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangeMyHomePropReq: // await HandleExchangeMyHomePropReq(request.ExchangeMyHomePropReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangeLandPropReq: // await HandleExchangeLandPropReq(request.ExchangeLandPropReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangeBuildingReq: // await HandleExchangeBuildingReq(request.ExchangeBuildingReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangeBuildingLFPropReq: // await HandleExchangeBuildingLFPropReq(request.ExchangeBuildingLFPropReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangeInstanceReq: // await HandleExchangeInstanceReq(request.ExchangeInstanceReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangeSocialActionSlotReq: // await HandleExchangeSocialActionSlotReq(request.ExchangeSocialActionSlotReq); // break; // case ClientToGameReq.MsgOneofCase.UseItemReq: // await HandleUseItemReq(request.UseItemReq); // break; // case ClientToGameReq.MsgOneofCase.RemoveItemReq: // await HandleRemoveItemReq(request.RemoveItemReq); // break; // case ClientToGameReq.MsgOneofCase.AvatarInfoSaveReq: // await HandleAvatarInfoSaveReq(request.AvatarInfoSaveReq); // break; // case ClientToGameReq.MsgOneofCase.EnterFittingRoomReq: // await HandleEnterFittingRoomReq(request.EnterFittingRoomReq); // break; // case ClientToGameReq.MsgOneofCase.LeaveFittingRoomReq: // break; // case ClientToGameReq.MsgOneofCase.ExchangeEmotionSlotReq: // await HandleExchangeEmotionSlotReq(request.ExchangeEmotionSlotReq); // break; // case ClientToGameReq.MsgOneofCase.UseMountPropReq: // await HandleUseMountPropReq(request.UseMountPropReq); // break; // case ClientToGameReq.MsgOneofCase.EndUseMountPropReq: // await HandleEndUseMountPropReq(request.EndUseMountPropReq); // break; // case ClientToGameReq.MsgOneofCase.UseSocialActionReq: // await HandleUseSocialActionReq(request.UseSocialActionReq); // break; // case ClientToGameReq.MsgOneofCase.StopSocialActionReq: // await HandleStopSocialActionReq(request.StopSocialActionReq); // break; // case ClientToGameReq.MsgOneofCase.UseEmotionReq: // await HandleUseEmotionReq(request.UseEmotionReq); // break; // case ClientToGameReq.MsgOneofCase.StopEmotionReq: // await HandleStopEmotionReq(request.StopEmotionReq); // break; //// 사용되면 않되어 주석 처리 한다. - kangms //// case ClientToGameReq.MsgOneofCase.EquipClothItemReq: //// await HandleEquipClothItemReq(request.EquipClothItemReq); //// break; //// case ClientToGameReq.MsgOneofCase.UnequipClothItemReq: //// await HandleUnequipClothItemReq(request.UnequipClothItemReq); //// break; // case ClientToGameReq.MsgOneofCase.ClothInfoSaveReq: // await HandleClothInfoSaveReq(request.ClothInfoSaveReq); // break; // case ClientToGameReq.MsgOneofCase.StartBuffReq: // await HandleStartBuffReq(request.StartBuffReq); // break; // case ClientToGameReq.MsgOneofCase.StopBuffReq: // await HandleStopBuffReq(request.StopBuffReq); // break; // case ClientToGameReq.MsgOneofCase.SocialActionTogetherReq: // await HandleSocialActionTogetherReq(request.SocialActionTogetherReq); // break; // case ClientToGameReq.MsgOneofCase.EnterCESConcertReq: // await HandleEnterCESConcertReq(request.EnterCESConcertReq); // break; // case ClientToGameReq.MsgOneofCase.LeaveCESConcertReq: // await HandleLeaveCESConcertReq(request.LeaveCESConcertReq); // break; // case ClientToGameReq.MsgOneofCase.ChangeNickNameReq: // await HandleChangeNickNameReq(request.ChangeNickNameReq); // break; // case ClientToGameReq.MsgOneofCase.ChangeGameOptionReq: // await HandleChangeGameOptionReq(request.ChangeGameOptionReq); // break; // case ClientToGameReq.MsgOneofCase.SendMailReq: // await HandleSendMailReq(request.SendMailReq); // break; // case ClientToGameReq.MsgOneofCase.GetMailReq: // await HandleGetMailReq(request.GetMailReq); // break; // case ClientToGameReq.MsgOneofCase.ReadMailReq: // await HandleReadMailReq(request.ReadMailReq); // break; // case ClientToGameReq.MsgOneofCase.GetItemsMailReq: // await HandleGetItemsMailReq(request.GetItemsMailReq); // break; // case ClientToGameReq.MsgOneofCase.DeleteMailReq: // await HandleDeleteMailReq(request.DeleteMailReq); // break; // case ClientToGameReq.MsgOneofCase.GetChannelListReq: // await HandleGetChannelListReq(request.GetChannelListReq); // break; // case ClientToGameReq.MsgOneofCase.MoveChannelReq: // await HandleMoveChannelReq(request.MoveChannelReq); // break; // case ClientToGameReq.MsgOneofCase.MoveWorldReq: // await HandleMoveWorldReq(request.MoveWorldReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangeMannequinDisplayItemReq: // await HandleExchangeMannequinDisplayItemReq(request.ExchangeMannequinDisplayItemReq); // break; // case ClientToGameReq.MsgOneofCase.ElevatorFloorInfoReq: // await HandleElevatorFloorInfoReq(request.ElevatorFloorInfoReq); // break; // case ClientToGameReq.MsgOneofCase.RegisterToolSlotReq: // await HandleRegisterToolSlotReq(request.RegisterToolSlotReq); // break; // case ClientToGameReq.MsgOneofCase.DeregisterToolSlotReq: // await HandleDeregisterToolSlotReq(request.DeregisterToolSlotReq); // break; // case ClientToGameReq.MsgOneofCase.ActivateToolItemReq: // await HandleActivateToolItemReq(request.ActivateToolItemReq); // break; // case ClientToGameReq.MsgOneofCase.DeactivateToolItemReq: // await HandleDeactivateToolItemReq(request.DeactivateToolItemReq); // break; // case ClientToGameReq.MsgOneofCase.UseToolItemReq: // await HandleUseToolItemReq(request.UseToolItemReq); // break; // case ClientToGameReq.MsgOneofCase.UseEquipedBuffReq: // await HandleUseEquipedBuffReq(request.UseEquipedBuffReq); // break; // case ClientToGameReq.MsgOneofCase.ChangeStateReq: // await HandleChangeStateReq(request.ChangeStateReq); // break; // case ClientToGameReq.MsgOneofCase.TaxiReq: // await HandleTaxiReq(request.TaxiReq); // break; // case ClientToGameReq.MsgOneofCase.GetCartReq: // HandleGetCartReq(request.GetCartReq); // break; // case ClientToGameReq.MsgOneofCase.AddCartReq: // await HandleAddCartReq(request.AddCartReq); // break; // case ClientToGameReq.MsgOneofCase.DelCartReq: // await HandleDelCartReq(request.DelCartReq); // break; // case ClientToGameReq.MsgOneofCase.BuyCartReq: // await HandleBuyCartReq(request.BuyCartReq); // break; // case ClientToGameReq.MsgOneofCase.GetFriendListReq: // await HandleGetFriendListReq(request.GetFriendListReq); // break; // case ClientToGameReq.MsgOneofCase.GetFriendFolderListReq: // HandleGetFriendFolderListReq(request.GetFriendFolderListReq); // break; // case ClientToGameReq.MsgOneofCase.HoldFriendFolderReq: // await HandleHoldFriendFolderReq(request.HoldFriendFolderReq); // break; // case ClientToGameReq.MsgOneofCase.ReleaseFriendFolderReq: // await HandleReleaseFriendFolderReq(request.ReleaseFriendFolderReq); // break; // case ClientToGameReq.MsgOneofCase.ReplyReceivedFriendRequestReq: // await HandleReplyReceivedFriendRequestReq(request.ReplyReceivedFriendRequestReq); // break; // case ClientToGameReq.MsgOneofCase.ConfirmNewFriendReq: // await HandleConfirmNewFriendReq(request.ConfirmNewFriendReq); // break; // case ClientToGameReq.MsgOneofCase.ConfirmNewReceivedFriendRequestReq: // await HandleConfirmNewReceivedFriendRequestReq(request.ConfirmNewReceivedFriendRequestReq); // break; // case ClientToGameReq.MsgOneofCase.RegisterTattooReq: // await HandleRegisterTattooReq(request.RegisterTattooReq); // break; // case ClientToGameReq.MsgOneofCase.DeregisterTattooReq: // await HandleDeregisterTattooReq(request.DeregisterTattooReq); // break; // case ClientToGameReq.MsgOneofCase.LevelUpTattooReq: // await HandleLevelUpTattooReq(request.LevelUpTattooReq); // break; // case ClientToGameReq.MsgOneofCase.ChangeAttributeTattooReq: // await HandleChangeAttributeTattooReq(request.ChangeAttributeTattooReq); // break; // case ClientToGameReq.MsgOneofCase.MoveFriendFolderUserReq: // await HandleMoveFriendFolderUserReq(request.MoveFriendFolderUserReq); // break; // case ClientToGameReq.MsgOneofCase.ReNameFriendFolderReq: // await HandleReNameFriendFolderReq(request.ReNameFriendFolderReq); // break; // case ClientToGameReq.MsgOneofCase.BlockUserReq: // await HandleBlockUserReq(request.BlockUserReq); // break; // case ClientToGameReq.MsgOneofCase.GetReceivedFriendRequestListReq: // await HandleGetReceivedFriendRequestListReq(); // break; // case ClientToGameReq.MsgOneofCase.GetSendedFriendRequestListReq: // await HandleGetSendedFriendRequestListReq(); // break; // case ClientToGameReq.MsgOneofCase.GetBlockListReq: // HandleGetBlockListReq(); // break; // case ClientToGameReq.MsgOneofCase.CancelFriendRequestReq: // await HandleCancelFriendRequestReq(request.CancelFriendRequestReq); // break; // case ClientToGameReq.MsgOneofCase.CancelBlockReq: // await HandleCancelBlockReq(request.CancelBlockReq); // break; // case ClientToGameReq.MsgOneofCase.InviteFriendToMyhomeReq: // await HandleInviteFriendToMyhomeReq(request.InviteFriendToMyhomeReq); // break; // case ClientToGameReq.MsgOneofCase.GetQuestMailReq: // HandleGetQuestMailReq(request.GetQuestMailReq); // break; // case ClientToGameReq.MsgOneofCase.ReadQuestMailReq: // await HandleReadQuestMailReq(request.ReadQuestMailReq); // break; // case ClientToGameReq.MsgOneofCase.QuestRefuseReq: // await HandleQuestRefuseReq(request.QuestRefuseReq); // break; // case ClientToGameReq.MsgOneofCase.QuestAbandonReq: // await HandleQuestAbandonReq(request.QuestAbandonReq); // break; // case ClientToGameReq.MsgOneofCase.GetClaimInfoReq: // HandleGetClaimInfoReq(); // break; // case ClientToGameReq.MsgOneofCase.UseRandomBoxItemReq: // await HandleUseRandomBoxItemReq(request.UseRandomBoxItemReq); // break; // case ClientToGameReq.MsgOneofCase.InvitePartyReq: // await HandleInvitePartyReq(request.InvitePartyReq); // break; // case ClientToGameReq.MsgOneofCase.InvitePartyListReq: // await HandleInvitePartyListReq(request.InvitePartyListReq); // break; // case ClientToGameReq.MsgOneofCase.ReplyInvitePartyReq: // await HandleReplyInvitePartyReq(request.ReplyInvitePartyReq); // break; // case ClientToGameReq.MsgOneofCase.LeavePartyReq: // await HandleLeavePartyReq(request.LeavePartyReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangePartyNameReq: // await HandleExchangePartyNameReq(request.ExchangePartyNameReq); // break; // case ClientToGameReq.MsgOneofCase.ExchangePartyMemberMarkReq: // await HandleExchangePartyMemberMarkReq(request.ExchangePartyMemberMarkReq); // break; // case ClientToGameReq.MsgOneofCase.SummonPartyMemberReq: // await HandleSummonPartyMemberReq(request.SummonPartyMemberReq); // break; // case ClientToGameReq.MsgOneofCase.UserReportReq: // await HandleUserReportReq(request.UserReportReq); // break; // case ClientToGameReq.MsgOneofCase.ReplySummonPartyMemberReq: // await HandleReplySummonPartyMemberReq(request.ReplySummonPartyMemberReq); // break; // case ClientToGameReq.MsgOneofCase.RegisterMinimapMarkerReq: // await HandleRegisterMinimapMarkerReq(request.RegisterMinimapMarkerReq); // break; // case ClientToGameReq.MsgOneofCase.DeregisterMinimapMarkerReq: // await HandleDeregisterMinimapMarkerReq(request.DeregisterMinimapMarkerReq); // break; // case ClientToGameReq.MsgOneofCase.InvitePartySendListReq: // await HandleInvitePartySendListReq(request.InvitePartySendListReq); // break; // case ClientToGameReq.MsgOneofCase.SaveCharProfileReq: // await HandleSaveCharProfileReq(request.SaveCharProfileReq); // break; // case ClientToGameReq.MsgOneofCase.GetCharProfileReq: // await HandleGetCharProfileReq(request.GetCharProfileReq); // break; // case ClientToGameReq.MsgOneofCase.SaveLanguageReq: // await HandleSaveLanguageReq(request.SaveLanguageReq); // break; // case ClientToGameReq.MsgOneofCase.SaveChatTapReq: // await HandleSaveChatTapReq(request.SaveChatTapReq); // break; // case ClientToGameReq.MsgOneofCase.GetChatTapReq: // await HandleGetChatTapReq(request.GetChatTapReq); // break; // case ClientToGameReq.MsgOneofCase.SaveVisibleTattooSlotReq: // await HandleSaveVisibleTattooSlotReq(request.SaveVisibleTattooSlotReq); // break; // case ClientToGameReq.MsgOneofCase.PartyVoteReq: // await HandlePartyVoteReq(request.PartyVoteReq); // break; // case ClientToGameReq.MsgOneofCase.ReplyPartyVoteReq: // await HandleReplyPartyVoteReq(request.ReplyPartyVoteReq); // break; // case ClientToGameReq.MsgOneofCase.UseRewardPropReq: // await HandleUseRewardPropReq(request.UseRewardPropReq); // break; // case ClientToGameReq.MsgOneofCase.UseMegaPhoneItemReq: // await HandleUseMegaPhoneItemReq(request.UseMegaPhoneItemReq); // break; // case ClientToGameReq.MsgOneofCase.CreatePartyInstanceReq: // await HandleCreatePartyInstanceReq(request.CreatePartyInstanceReq); // break; // case ClientToGameReq.MsgOneofCase.JoinPartyInstanceReq: // await HandleJoinPartyInstanceReq(request.JoinPartyInstanceReq); // break; // case ClientToGameReq.MsgOneofCase.IntroCompleteReq: // await HandleIntroCompleteReq(request.IntroCompleteReq); // break; // case ClientToGameReq.MsgOneofCase.GameGuardAuthReq: // await HandleGameGuardAuthReq(request.GameGuardAuthReq); // break; // case ClientToGameReq.MsgOneofCase.ReqEscapePosition: // await handleEscapePosition(request.ReqEscapePosition); // break; // case ClientToGameReq.MsgOneofCase.ReqNPCDialogue: // await handleNPCDialogue(request.ReqNPCDialogue); // break; // default: // Log.getLogger().warn($"{request.MsgCase}"); // break; // } // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // public async Task HandleStartBuffReq(StartBuffReq startBuffReq) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // //await Task.Run(() => // { // //lock (_lock) // //{ // var errorCode = StartBuff(startBuffReq.BuffId); // if (errorCode != ServerErrorCode.Success) // { // ClientToGame message = new(); // message.Response = new(); // message.Response.StartBuffRes = new(); // message.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, message); // } // //} // }//); // } // public ServerErrorCode StartBuff(int buffId) // { // if (_selectedChar is null) // { // return ServerErrorCode.NotExistSelectedCharacter; // } // ServerErrorCode errorCode = _selectedChar._ownedBuff.AddBuffProcess(buffId, out var startBuff, out var endBuff); // if (errorCode != ServerErrorCode.Success) // { // return errorCode; // } // if (endBuff != null) // { // ClientToGame message = new(); // message.Response = new(); // message.Response.StopBuffRes = new(); // message.Response.ErrorCode = ServerErrorCode.Success; // message.Response.StopBuffRes.Buf = endBuff; // Send(RmiContext.ReliableSend, message); // ClientToGame noti = new(); // noti.Message = new(); // noti.Message.StopBuffNoti = new(); // noti.Message.StopBuffNoti.ActorGuid = AccountGuid; // noti.Message.StopBuffNoti.Buf = endBuff; // _selectedChar.map?.Broadcast(_selectedChar, noti); // } // if (startBuff != null) // { // ClientToGame message = new(); // message.Response = new(); // message.Response.StartBuffRes = new(); // message.Response.ErrorCode = ServerErrorCode.Success; // message.Response.StartBuffRes.Buf = startBuff; // Send(RmiContext.ReliableSend, message); // ClientToGame noti = new(); // noti.Message = new(); // noti.Message.StartBuffNoti = new(); // noti.Message.StartBuffNoti.ActorGuid = AccountGuid; // noti.Message.StartBuffNoti.Buf = startBuff; // _selectedChar.map?.Broadcast(_selectedChar, noti); // } // return ServerErrorCode.Success; // } // public void CheckBuff() // { // //lock(_lock) // //{ // try // { // /* // * foreach Dictory Remove는 이터레이터가 문제가 없지만 Add는 iterator에 문제가 생겨 익셉션이 발생한다. // * 꼭 try로 안해주면 task가 비정상종료 가능 // */ // if (_selectedChar == null) // { // Log.getLogger().warn("_selectedChar == null"); // return; // } // List listDeleteChannel = new(); // var it = _selectedChar._ownedBuff.getCopyBuff().GetEnumerator(); // while (it.MoveNext() == true) // { // var buffDirectory = it.Current; // var iter = buffDirectory.Value.GetEnumerator(); // while (iter.MoveNext() == true) // { // var buff = iter.Current; // if (!TableData.Instance._BuffTable.TryGetValue(buff.Value.BuffId, out BuffData? data)) // { // Log.getLogger().error($"Not found Buffid:{buff.Value.BuffId}"); // continue; // } // if (data.BuffChannel != buff.Key) // { // Log.getLogger().error($"Not found BuffChannel:{data.BuffChannel}"); // continue; // } // if (data.DurationTime == 0) // { // // 무한 // continue; // } // DateTime endTime = buff.Value.BuffStartTime.ToDateTime().AddSeconds(data.DurationTime); // //Log.getLogger().debug($"BuffId:{buff.Value.BuffId} curTime:{DateTime.UtcNow} endTime:{endTime}"); // if (DateTime.UtcNow >= endTime) // { // StopBuff(buff.Value.BuffId); // if (data.BuffEndExecutionType == "GETBUFF") // { // int newBuffId = data.BuffEndExecutionValue; // if (TableData.Instance._BuffTable.TryGetValue(newBuffId, out BuffData? newData)) // { // if (newData.BuffChannel != data.BuffChannel) // { // Log.getLogger().error($"Buff Channel newBuffId:{newBuffId} newData.BuffChannel:{newData.BuffChannel} data.BuffChannel:{data.BuffChannel} Buffid:{buff.Value.BuffId}"); // continue; // } // //Task.Run(() => // { // //lock (_lock) // StartBuff(newBuffId); // }//); // } // } // } // } // } // } // catch (Exception e) // { // Log.getLogger().error(e.ToString()); // } // //} // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // public async Task HandleStopBuffReq(StopBuffReq stopBuffReq) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // //await Task.Run(() => // { // //lock (_lock) // //{ // var errorCode = StopBuff(stopBuffReq.BuffId); // if (errorCode != ServerErrorCode.Success) // { // ClientToGame message = new(); // message.Response = new(); // message.Response.StopBuffRes = new(); // message.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, message); // } // //} // }//); // } // ServerErrorCode StopBuff(int buffId) // { // if (_selectedChar is null) // { // return ServerErrorCode.NotExistSelectedCharacter; // } // ServerErrorCode errorCode = _selectedChar._ownedBuff.DelBuffProcess(buffId, out var endBuff); // if (errorCode != ServerErrorCode.Success) // { // return errorCode; // } // if (endBuff != null) // { // ClientToGame message = new(); // message.Response = new(); // message.Response.StopBuffRes = new(); // message.Response.ErrorCode = ServerErrorCode.Success; // message.Response.StopBuffRes.Buf = endBuff; // Send(RmiContext.ReliableSend, message); // ClientToGame noti = new(); // noti.Message = new(); // noti.Message.StopBuffNoti = new(); // noti.Message.StopBuffNoti.ActorGuid = AccountGuid; // noti.Message.StopBuffNoti.Buf = endBuff; // _selectedChar.map?.Broadcast(_selectedChar, noti); // } // return ServerErrorCode.Success; // } // /* // * ClothAvatar = 0, // ClothHeadwear = 0, // ClothMask = 0, // ClothBag = 0, // ClothShoes = 0, // ClothOuter = 0, // ClothTops = 0, // ClothBottoms = 0, // ClothGloves = 0, // ClothEarrings = 0, // ClothNeckless = 0, // ClothSocks = 0, // */ // private async Task HandleClothInfoSaveReq(ClothInfoSaveReq clothInfoSaveReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ClothInfoSaveRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.ClothInfoSave(clothInfoSaveReq.ClothInfo, out var changedClothInfo, out var errorCode)) // { // Log.getLogger().error($"ClothInfoSave Fail", ToString()); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // clientToGame.Response.ClothInfoSaveRes.ClothInfo = changedClothInfo; // await GameServerApp.Instance.MainDB.SaveChar(_selectedChar._charEntity); // Send(RmiContext.ReliableSend, clientToGame); // return; // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. //// private async Task HandleEquipClothItemReq(EquipClothItemReq equipClothItemReq) //// { //// ClientToGame client = new(); //// client.Response = new(); //// client.Response.EquipClothItemRes = new(); //// if (_selectedChar == null) //// { //// client.Response.ErrorCode = ServerErrorCode.ServerLogicError; //// } //// else //// { //// client.Response.ErrorCode = _selectedChar.EquipClothSlot((int)equipClothItemReq.ClothSlot, equipClothItemReq.ItemGuid); //// client.Response.EquipClothItemRes.ClothSlot = equipClothItemReq.ClothSlot; //// await SaveDB(); //// } //// //// Send(RmiContext.ReliableSend, client); //// } //// private async Task HandleUnequipClothItemReq(UnequipClothItemReq unequipClothItemReq) //////#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. //// { //// ClientToGame client = new(); //// client.Response = new(); //// client.Response.UnequipClothItemRes = new(); //// //// if (_selectedChar == null) //// { //// client.Response.ErrorCode = ServerErrorCode.ServerLogicError; //// } //// else //// { //// client.Response.ErrorCode = _selectedChar.UnequipClothSlot((int)unequipClothItemReq.ClothSlot, out _); //// client.Response.EquipClothItemRes.ClothSlot = unequipClothItemReq.ClothSlot; //// await SaveDB(); //// } //// //// Send(RmiContext.ReliableSend, client); //// } // private async Task HandleAvatarInfoSaveReq(AvatarInfoSaveReq avatarInfoSaveReq) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.AvatarInfoSaveRes = new(); // if (_selectedChar == null) // { // clientToGame.Response.ErrorCode = ServerErrorCode.LoginFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ServerErrorCode ret = ServerErrorCode.Success; // //avatarInfoSaveReq.AvatarInfo.Init = 1; // // TODO: 데이터 정합성체크 필요 일단 무조건 저장 // if (avatarInfoSaveReq.AvatarInfo != null) // { // uint back = _selectedChar._charEntity.AvatarInfo.Init; // _selectedChar._charEntity.AvatarInfo = avatarInfoSaveReq.AvatarInfo; // _selectedChar._charEntity.AvatarInfo.Init = back; // //_selectedChar._charEntity.AvatarInfo.Init = 1; // } // List dBDocumentInfos = new(); // List itemEntityList = new List(); // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity); // List invokers = new List(); // List itemlogDatas = new(); // // ClothInfo 저장 방식 수정 필요 // ClothInfo ClothInfoBackup = _selectedChar._charEntity.ClothInfo.Clone(); // bool isClothInfoSave = false; // if (avatarInfoSaveReq.ClothInfo != null && _selectedChar._charEntity.AvatarInfo.Init == 1) // { // _selectedChar._charEntity.AvatarInfo.Init = 0; // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothAvatarItemGuid, avatarInfoSaveReq.ClothInfo.ClothAvatar, // _selectedChar._charEntity.ClothInfo, // nameof(ClothInfo.ClothAvatarItemGuid), // nameof(ClothInfo.ClothAvatar), 5, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothHeadwearItemGuid, avatarInfoSaveReq.ClothInfo.ClothHeadwear, // _selectedChar._charEntity.ClothInfo, // nameof(_selectedChar._charEntity.ClothInfo.ClothHeadwearItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothHeadwear), 6, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothMaskItemGuid, avatarInfoSaveReq.ClothInfo.ClothMask, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothMaskItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothMask), 7, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothBagItemGuid, avatarInfoSaveReq.ClothInfo.ClothBag, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothBagItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothBag), 8, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothShoesItemGuid, avatarInfoSaveReq.ClothInfo.ClothShoes, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothShoesItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothShoes), 9, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothOuterItemGuid, avatarInfoSaveReq.ClothInfo.ClothOuter, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothOuterItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothOuter), 10, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothTopsItemGuid, avatarInfoSaveReq.ClothInfo.ClothTops, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothTopsItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothTops), 11, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothBottomsItemGuid, avatarInfoSaveReq.ClothInfo.ClothBottoms, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothBottomsItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothBottoms), 12, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothGlovesItemGuid, avatarInfoSaveReq.ClothInfo.ClothGloves, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothGlovesItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothGloves), 13, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothEarringsItemGuid, avatarInfoSaveReq.ClothInfo.ClothEarrings, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothEarringsItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothEarrings), 14, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothNecklessItemGuid, avatarInfoSaveReq.ClothInfo.ClothNeckless, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothNecklessItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothNeckless), 15, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // ret = SaveInitClothInfo(avatarInfoSaveReq.ClothInfo.ClothSocksItemGuid, avatarInfoSaveReq.ClothInfo.ClothSocks, // _selectedChar._charEntity.ClothInfo, nameof(_selectedChar._charEntity.ClothInfo.ClothSocksItemGuid), // nameof(_selectedChar._charEntity.ClothInfo.ClothSocks), 16, newInventoryEntity, itemEntityList, ref itemlogDatas); // if (ret != ServerErrorCode.Success) // { // goto FINAL; // } // } // if (itemEntityList.Count != 0) // { // isClothInfoSave = true; // dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update)); // foreach (var item in itemEntityList) // { // dBDocumentInfos.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update)); // } // } // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"DB UpdateInventory Failed."); // ret = ServerErrorCode.DbUpdateFailed; // goto FINAL; // } // FINAL: // if (ret != ServerErrorCode.Success) // { // _selectedChar._charEntity.ClothInfo = ClothInfoBackup; // Log.getLogger().error($"ret = {ret}"); // } // else // { // if (isClothInfoSave == true) // { // _selectedChar._inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate()); // _selectedChar._inventory.UpdateItemDBToMemory(itemEntityList); // } // await GameServerApp.Instance.MainDB.SaveChar(_selectedChar._charEntity); // foreach (var itemInfoLog in itemlogDatas) // { // invokers.Add(new ItemLog(itemInfoLog)); // } // var log_action = new LogActionEx(LogActionType.CharLoading); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // clientToGame.Response.ErrorCode = ret; // clientToGame.Response.AvatarInfoSaveRes = new(); // if (ret == ServerErrorCode.Success) // { // clientToGame.Response.AvatarInfoSaveRes.AvatarInfo = _selectedChar._charEntity.AvatarInfo; // clientToGame.Response.AvatarInfoSaveRes.ClothInfo = _selectedChar._charEntity.ClothInfo; // } // if (isClothInfoSave == true && ret == ServerErrorCode.Success) // { // clientToGame.Response.AvatarInfoSaveRes.Inventory = _selectedChar._inventory.MakePacketInventoryData(); // } // Send(RmiContext.ReliableSend, clientToGame); // if (ret == ServerErrorCode.Success) // { // ClientToGame clientMsg = new(); // clientMsg.Message = new(); // clientMsg.Message.ActorModify = new(); // clientMsg.Message.ActorModify.ActorGuid = _selectedChar.Guid; // clientMsg.Message.ActorModify.AvatarInfo = _selectedChar._charEntity.AvatarInfo.Clone(); // clientMsg.Message.ActorModify.ClothInfo = ServerUtil.MakeClothInfoOfAnotherUser(_selectedChar._charEntity.ClothInfo); // Log.getLogger().debug($"{clientMsg.Message.ActorModify.AvatarInfo}"); // if (_selectedChar.map != null) // _selectedChar.map.Broadcast(_selectedChar, clientMsg); // //TODO : 확인 필요, 이전에는 자동생성, 아바타 생성 두군데 잇엇는데 해당 패킷에 필요 한지 확인 필요 // ////Insertchar 에서 전부 처리 된다고 판단해서 우선 주석 처리 // } // } // private ServerErrorCode SaveInitClothInfo(string packetItemGuid, // uint packetItemTableId, // object clothInfoObj, // string clothItemGuidPropName, // string clothItemTablePropName, // int ClothSlot, // InventoryEntity updateInventoryEntity, List addedItemList, ref List itemlogDatas) // { // ItemData? itemData; // if (packetItemTableId == 0) // { // // packetItemTableId=0이면 저장기능 스킵 // //Log.getLogger().error("packetItemTableId==0"); // return ServerErrorCode.Success; // } // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar == null"); // return ServerErrorCode.ServerLogicError; // } // if (false == TableData.Instance._ItemTable.TryGetValue((int)packetItemTableId, out itemData)) // { // Log.getLogger().error($"packetItemTableId:{packetItemTableId}"); // return ServerErrorCode.NotFoundItemTableId; // } // //TODO: 아이템 장착위치 체크 // //TODO: 아이템 사용기간 체크 // if (!_selectedChar._inventory.AddItem( // (int)packetItemTableId, // 1, // updateInventoryEntity, // out var listItem, // out var errorCode, // out var itemlogs)) // { // Log.getLogger().error($"_inventory.AddItem Error:{errorCode.ToString()}"); // return errorCode; // } // try // { // var prop = clothInfoObj.GetType().GetProperty(clothItemGuidPropName); // if (prop == null) // { // Log.getLogger().error($"prop == null"); // return ServerErrorCode.ServerLogicError; // } // prop.SetValue(clothInfoObj, listItem[0].Attr.ItemGuid); // var prop2 = clothInfoObj.GetType().GetProperty(clothItemTablePropName); // if (prop2 == null) // { // Log.getLogger().error($"prop2 == null"); // return ServerErrorCode.ServerLogicError; // } // prop2.SetValue(clothInfoObj, (uint)packetItemTableId); // } // catch (Exception ex) // { // Log.getLogger().error(ex.ToString()); // } // addedItemList.AddRange(listItem); // itemlogDatas.AddRange(itemlogs); // /* // clothItemGuid = listItem[0].ItemGuid; // clothItemTableId = packetItemTableId; // */ // return ServerErrorCode.Success; // } // private async Task HandleRemoveItemReq(RemoveItemReq removeItemReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.RemoveItemRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var errorCode = _selectedChar.CheckEquipItem(removeItemReq.ItemGuid); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error($"can't remove equipItem. itemGuid : {removeItemReq.ItemGuid}."); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List dBDocumentInfos = new(); // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity); // List invokers = new List(); // if (!_selectedChar._inventory.DeleteItem( // removeItemReq.ItemGuid, // removeItemReq.Count, // newInventoryEntity, // out var deletedItem, // out errorCode, // out var itemlogData)) // { // Log.getLogger().error($"{Id} DeleteItem Fail"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update)); // dBDocumentInfos.Add(new DBDocumentInfo(deletedItem.DocumentForUpdate(), EDBExecuteType.Update)); // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"DB UpdateInventory Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar._inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate()); // _selectedChar._inventory.UpdateItemDBToMemory(new List() { deletedItem }); // clientToGame.Response.RemoveItemRes.ItemGuid = deletedItem.Attr.ItemGuid; // clientToGame.Response.RemoveItemRes.Count = deletedItem.Attr.Count; // Send(RmiContext.ReliableSend, clientToGame); // invokers.Add(new ItemLog(itemlogData)); // BusinessLogger.collectLogs(new LogActionEx(LogActionType.ItemDestroy), _selectedChar, invokers); // } // private async Task HandleUseItemReq(UseItemReq useItemReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.UseItemRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List dBDocumentInfos = new(); // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity); // var invokers = new List(); // var log_action = new LogActionEx(LogActionType.ItemUse); // if (!_selectedChar._inventory.DeleteItem(useItemReq.ItemGuid, useItemReq.Count, newInventoryEntity, out var deletedItem, out var errorCode, out var itemlogData)) // { // Log.getLogger().error($"{Id} DeleteItem Fail"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._ItemTable.TryGetValue(deletedItem.Attr.ItemId, out var itemData)) // { // Log.getLogger().error($"Not Exist itemId({deletedItem.Attr.ItemId})"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundItemTableId; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Document? ExpendableDocument = null; // SocialActionLogInfo? socialActionLogInfo = null; // MyHomeLogInfo? myHomeLogInfo = null; // int itemEffectMID = 0; // if (itemData.TypeLarge == EItemLargeType.EXPENDABLE) // { // switch (itemData.TypeSmall) // { // case EItemSmallType.REGISTER_ITEM_SOCIAL_ACTION: // itemEffectMID = itemData.Register_id; // errorCode = ownedSocialAction.AddSocialAction(itemEffectMID, out ExpendableDocument, out socialActionLogInfo); // break; // case EItemSmallType.REGISTER_ITEM_INTERIOR: // itemEffectMID = itemData.Register_id; // errorCode = myHome.AddMyHome(itemData.Register_id, out ExpendableDocument, out myHomeLogInfo); // break; // case EItemSmallType.BUFF_DRINK: // itemEffectMID = itemData.buff_id; // errorCode = StartBuff(itemData.buff_id); // break; // default: // Log.getLogger().error($"Invalid ItemType TypeSmall : {itemData.TypeSmall}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundItemTableId; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error($"{Id} use expendable item failed."); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if(ExpendableDocument != null) // { // dBDocumentInfos.Add(new DBDocumentInfo(ExpendableDocument, EDBExecuteType.Update)); // } // } // dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update)); // dBDocumentInfos.Add(new DBDocumentInfo(deletedItem.DocumentForUpdate(), EDBExecuteType.Update)); // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"DB UpdateInventory Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar._inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate()); // _selectedChar._inventory.UpdateItemDBToMemory(new List() { deletedItem }); // if (ExpendableDocument != null) // { // if (itemData.TypeSmall == EItemSmallType.REGISTER_ITEM_SOCIAL_ACTION) // { // ownedSocialAction.UpdateSocialActionToMemory(ExpendableDocument); // ClientToGame noti = new(); // noti.Message = new(); // noti.Message.SocialActionAddNoti = new(); // noti.Message.SocialActionAddNoti.SocialActionId = itemData.Register_id; // Send(RmiContext.ReliableSend, noti); // } // else if (itemData.TypeSmall == EItemSmallType.REGISTER_ITEM_INTERIOR) // { // myHome.UpdateMyHomeToMemory(ExpendableDocument); // ClientToGame noti = new(); // noti.Message = new(); // noti.Message.MyHomeAddNoti = new(); // noti.Message.MyHomeAddNoti.MyHomeId = itemData.Register_id; // Send(RmiContext.ReliableSend, noti); // } // } // if (itemData.TypeLarge == EItemLargeType.EXPENDABLE) // { // if (itemData.TypeSmall == EItemSmallType.REGISTER_ITEM_SOCIAL_ACTION || itemData.TypeSmall == EItemSmallType.REGISTER_ITEM_INTERIOR) // { // } // } // clientToGame.Response.UseItemRes.ItemGuid = deletedItem.Attr.ItemGuid; // clientToGame.Response.UseItemRes.Count = deletedItem.Attr.Count; // Send(RmiContext.ReliableSend, clientToGame); // invokers.Add(new ItemLog(itemlogData)); // invokers.Add(new ItemUseLog(deletedItem.Attr.ItemGuid, itemData.TypeSmall.ToString(), itemEffectMID)); // if (socialActionLogInfo != null) // invokers.Add(new SocialActionLog(socialActionLogInfo)); // if (myHomeLogInfo != null) // invokers.Add(new MyHomeLog(myHomeLogInfo)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // public async Task HandleUseRandomBoxItemReq(UseRandomBoxItemReq useItemReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.UseRandomBoxItemRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string user_item_guid = useItemReq.ItemGuid; // int num = 1; // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var new_inventory_entity); // if (!_selectedChar._inventory.DeleteItem(user_item_guid, num, new_inventory_entity, out var deletedItem, out var errorCode, out var itemlogData)) // { // Log.getLogger().error($"{Id} DeleteItem Fail"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // int delete_item_id = deletedItem.Attr.ItemId; // if (!TableData.Instance._ItemTable.TryGetValue(delete_item_id, out var itemData)) // { // Log.getLogger().error($"Not Exist itemId({delete_item_id})"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundItemTableId; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (itemData.TypeLarge != EItemLargeType.RAND_BOX) // { // Log.getLogger().error($"RandomBoxItemDataInvalid itemId({delete_item_id})"); // clientToGame.Response.ErrorCode = ServerErrorCode.RandomBoxItemDataInvalid; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!int.TryParse(itemData.GachaGroupId, out int gachaGroupId)) // { // Log.getLogger().error($"RandomBoxItemDataInvalid itemId({delete_item_id})"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundItemTableId; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._GachaDataTable.TryGetValue(gachaGroupId, out var gachaData)) // { // Log.getLogger().error($"Not Exist GachaData gachaGroupId = {itemData.GachaGroupId}"); // errorCode = ServerErrorCode.NotExistGachaData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // GachaData gacha = gachaData.GetRandomReward(); // List rewards = new List(); // //Document inventory_doc = new_inventory_entity.DocumentForUpdate(); // IReward reward_proc = new RewardRandomItemBox(_selectedChar, new_inventory_entity, deletedItem, clientToGame, rewards); // if (error_code != ServerErrorCode.Success) // { // clientToGame.Response.ErrorCode = error_code; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // System.Guid tranGuid = System.Guid.NewGuid(); // RandomBoxItemUseInfo info = new RandomBoxItemUseInfo(user_item_guid, delete_item_id, num, gachaGroupId, gacha); // ILogInvokerEx invoker = new RandomBoxItemUseBusinessLog(info); // var log_action = new LogActionEx(LogActionType.ItemRandomBoxUse); // List invokers = new(); // invokers.Add(invoker); // invokers.AddRange(reward_proc.getCurrencyLogInvokers()); // invokers.AddRange(reward_proc.getItemLogInvokers()); // invokers.Add(new ItemLog(itemlogData)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // // TODO: 지역채팅인지 전체 채팅인지 구분해서 처리할 필요가 있음. // async Task HandleChatReq(ClientToGameReq.Types.ChatReq reqMsg) // { // ClientToGame resMsg = new(); // resMsg.Response = new(); // resMsg.Response.ChatRes = new(); // resMsg.Response.ErrorCode = ServerErrorCode.Success; // resMsg.Response.ChatRes.Receiver = reqMsg.ToNickName; // ChatType chatType = (ChatType)reqMsg.Type; // if (_selectedChar == null) // { // resMsg.Response.ErrorCode = ServerErrorCode.NotSelectedChar; // Send(RmiContext.ReliableSend, resMsg); // Log.getLogger().error("_selectedChar is null"); // return; // } // if (_selectedChar.map == null) // { // resMsg.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, resMsg); // Log.getLogger().error("_selectedChar.map is null"); // return; // } // if (GameServer.Instance.ChatCommand.isCheatCommand(reqMsg.Message) == true) // { // await GameServer.Instance.ChatCommand.HandleCommand(_selectedChar, reqMsg.Message); // Send(RmiContext.ReliableSend, resMsg); // return; // } //// if (await GameServer.Instance.ChatCommand.HandleCommand(_selectedChar, reqMsg.Message) == true) //// { //// Send(RmiContext.ReliableSend, resMsg); //// return; //// } // string Receiverid = ""; // string receiverGuid = ""; // ClientToGame clientMsg = new(); // clientMsg.Message = new ClientToGameMessage(); // clientMsg.Message.Chat = new(); // string targetServer = ""; // if (chatType == ChatType.WHISPER) // { // resMsg.Response.ChatRes.Message = reqMsg.Message; // resMsg.Response.ChatRes.Sender = getUserNickname(); // resMsg.Response.ChatRes.Receiver = reqMsg.ToNickName; // resMsg.Response.ChatRes.Type = (int)chatType; // if (reqMsg.ToNickName == getUserNickname()) // { // resMsg.Response.ErrorCode = ServerErrorCode.CantSendToSelf; // Send(RmiContext.ReliableSend, resMsg); // Log.getLogger().error("Can't Send Chat to Self."); // return; // } // NickNameEntity? nickNameEntity = await GameServerApp.Instance.MainDB.GetEntityFromNickName(reqMsg.ToNickName); // if (nickNameEntity is null) // { // resMsg.Response.ErrorCode = ServerErrorCode.NotFoundTarget; // Send(RmiContext.ReliableSend, resMsg); // return; // } // Receiverid = nickNameEntity.Attr.AccountId; // receiverGuid = nickNameEntity.Attr.AccountGuid; // LoginInfo? loginInfo = await GameServerApp.Instance.LoginStorage.GetLoginInfo(Receiverid); // if (loginInfo is null) // { // resMsg.Response.ErrorCode = ServerErrorCode.LogOffTarget; // Send(RmiContext.ReliableSend, resMsg); // return; // } // targetServer = loginInfo.CurrentServer; // clientMsg.Message.Chat.Receiverstate = loginInfo.State; // } // clientMsg.Message.Chat.Message = reqMsg.Message; // clientMsg.Message.Chat.Sender = getUserNickname(); // clientMsg.Message.Chat.Receiver = reqMsg.ToNickName; // clientMsg.Message.Chat.Type = (int)chatType; // switch (chatType) // { // case ChatType.NORMAL: // 지역 // { // // TODO // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel) // { // _selectedChar.map.Broadcast(_selectedChar, clientMsg, true); // } // else // { // _selectedChar.map.Broadcast(_selectedChar, clientMsg, true); // } // break; // } // case ChatType.CHANNEL: // 맵OR 채널채팅 // { // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel) // ClientSessionManager.Instance.Broadcast(_selectedChar, clientMsg); // else // ClientSessionManager.Instance.Broadcast(_selectedChar, clientMsg); // } // break; // case ChatType.NOTICE: // 전체 채팅 // { // if (AccountAuthorityManager.Instance.IsWhiteListUser(Id) == false) // { // resMsg.Response.ErrorCode = ServerErrorCode.NotEnoughAuthority; // Send(RmiContext.ReliableSend, resMsg); // return; // } // GameServer.Instance._rabbitMQ4Game.SendChat(reqMsg.Message, getUserNickname(), (int)chatType); // break; // } // case ChatType.WHISPER: // 귓속말 채팅 // { // //내가 차단한경우 // if (_selectedChar.ownedBlockList.isBlockUser(receiverGuid)) // { // resMsg.Response.ChatRes.Type = clientMsg.Message.Chat.Type; // resMsg.Response.ChatRes.Sender = clientMsg.Message.Chat.Sender; // resMsg.Response.ChatRes.Receiver = clientMsg.Message.Chat.Receiver; // resMsg.Response.ChatRes.Receiverid = Receiverid; // resMsg.Response.ChatRes.Receiverstate = clientMsg.Message.Chat.Receiverstate; // resMsg.Response.ChatRes.Message = clientMsg.Message.Chat.Message; // resMsg.Response.ErrorCode = ServerErrorCode.BlockUserCannotWhisperTo; // Send(RmiContext.ReliableSend, resMsg); // break; // } // //상대방이 차단한경우 상대방에겐 보내지 않고 정상 처리 되도록 // bool isBlocked = await _selectedChar.ownedBlockList.isBlocked(_selectedChar.Guid, receiverGuid); // if (!isBlocked) // { // if (targetServer != GameServer.Instance.ServerName) // { // ServerMessage chatMessage = new(); // chatMessage.Chat = new(); // chatMessage.Chat.Type = clientMsg.Message.Chat.Type; // chatMessage.Chat.Sender = clientMsg.Message.Chat.Sender; // chatMessage.Chat.Receiver = clientMsg.Message.Chat.Receiver; // chatMessage.Chat.Receiverid = Receiverid; // chatMessage.Chat.Receiverstate = clientMsg.Message.Chat.Receiverstate; // chatMessage.Chat.Message = clientMsg.Message.Chat.Message; // GameServer.Instance._rabbitMQ4Game.SendMessage(targetServer, chatMessage); // } // else // { // ClientSession? session = ClientSessionManager.Instance.GetSessionByName(Receiverid); // if (session == null) // { // return; // } // session.Send(RmiContext.ReliableSend, clientMsg); // } // } // Send(RmiContext.ReliableSend, clientMsg); // break; // } // case ChatType.PARTY: // { // if (PartyGuid == string.Empty) // { // resMsg.Response.ErrorCode = ServerErrorCode.NotParty; // Send(RmiContext.ReliableSend, resMsg); // return; // } // PartyManager.Instance.SendPartyChat(PartyGuid, clientMsg); // break; // } // default: // { // resMsg.Response.ErrorCode = ServerErrorCode.InvalidArgument; // Send(RmiContext.ReliableSend, resMsg); // return; // } // } // } // async Task HandleCreateChatRoomReq(CreateChatRoomReq message) // { // ChatRoomInfo? chatRoom = await ChatRoomHandler.CreateRoom(message.AllowList.ToList()); // if (chatRoom == null) // { // ClientToGame errorClientToGame = new ClientToGame(); // errorClientToGame.Response = new ClientToGameRes(); // errorClientToGame.Response.ErrorCode = ServerErrorCode.JoinRoomFail; // errorClientToGame.Response.CreateChatRoomRes = new(); // Send(RmiContext.ReliableSend, errorClientToGame); // return; // } // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.CreateChatRoomRes = new(); // clientToGame.Response.CreateChatRoomRes.ChatServerAddr = chatRoom.ChatAddress; // clientToGame.Response.CreateChatRoomRes.ChatServerPort = chatRoom.ChatPort; // clientToGame.Response.CreateChatRoomRes.RoomId = chatRoom.Id; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleJoinChatRoomReq(JoinChatRoomReq message) // { // if (_selectedChar == null) // return; // ChatRoomInfo? chatRoom = await ChatRoomHandler.JoinRoom(message.RoomId, _selectedChar.accountId); // if (chatRoom == null) // { // ClientToGame errorClientToGame = new(); // errorClientToGame.Response = new(); // errorClientToGame.Response.ErrorCode = ServerErrorCode.JoinRoomFail; // errorClientToGame.Response.JoinChatRoomRes = new(); // Send(RmiContext.ReliableSend, errorClientToGame); // return; // } // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.JoinChatRoomRes = new(); // clientToGame.Response.JoinChatRoomRes.ChatServerAddr = chatRoom.ChatAddress; // clientToGame.Response.JoinChatRoomRes.ChatServerPort = chatRoom.ChatPort; // clientToGame.Response.JoinChatRoomRes.RoomId = chatRoom.Id; // Send(RmiContext.ReliableSend, clientToGame); // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleLeaveChatRoomReq(LeaveChatRoomReq message) // { // } // async Task HandleMoveReq(MoveReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // if (_selectedChar == null || _selectedChar.map == null || _selectedChar.IsCESConcert) // return false; // return _selectedChar.Move(message.Pos); // } // async Task HandleJoinInstanceReq(JoinInstanceReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.JoinInstanceRes = new(); // if (!MapManager.Instance.GetLandMapTree(message.LandId, out var landMapTree)) // { // Log.getLogger().error($"{Id} Not Found LandMapTree. landId:{message.LandId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundLandData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var buildingMapTree = landMapTree.ChildBuildingMap; // if (buildingMapTree == null) // { // Log.getLogger().error($"{Id} Not Exist Land ChildBuilding"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundBuildingData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (message.BuildingId != buildingMapTree.BuildingId) // { // Log.getLogger().error($"{Id} Not Correct BuildingId"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundBuildingData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!buildingMapTree.ChildRoomMaps.TryGetValue(message.Floor, out var roomMapTree)) // { // Log.getLogger().error($"{Id} Not Found FloorInfo. floodId:{message.Floor}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundFloorInfo; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._IndunTable.TryGetValue(roomMapTree.InstanceId, out var indunData)) // { // Log.getLogger().error($"{Id} Not Found IndunData. instanceId:{roomMapTree.InstanceId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundIndunData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.JoinInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var error = _selectedChar.CheckInstanceAccess(roomMapTree.InstanceId); // if (error.isFail()) // { // Log.getLogger().error($"{Id} CheckInstanceAccess Error({error.ToString()})"); // clientToGame.Response.ErrorCode = error; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string? reJoinRoomId = null; // if (indunData.PlaceType == EPlaceType.Concert) // { // _selectedChar.instanceLastRoomEntity.Attr.LastRoomIds.TryGetValue(roomMapTree.InstanceId, out reJoinRoomId); // } // string roomId = await InstanceRoomHandler.JoinInstance(roomMapTree.InstanceId, Id, reJoinRoomId); // if (roomId == string.Empty) // { // Log.getLogger().error("Join fail !!! instance"); // clientToGame.Response.ErrorCode = ServerErrorCode.JoinInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // InstanceRoomInfo? instanceRoom = await GameServerApp.Instance.InstanceRoomStorage.GetInstanceRoomInfo(roomId); // if (instanceRoom == null) // { // Log.getLogger().error($"{Id} Not found InstanceRoomInfo. roomId:{roomId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistRoomInfoForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.StageExit); // StageLogInfo? stage_log_info = null; // _selectedChar.getCurrentStateInfo(this, out stage_log_info); // _selectedChar.LastPositionInfo.m_last_stage_exit_tran_guid = log_action.getTranId(); // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel) // { // _selectedChar.SetLastGameServerPosition(GameServer.Instance.ServerName, GameServer.Instance.myServerInfo.worldId, _selectedChar.CharPos.Pos); // } // else // { // _selectedChar.AddLastInstancePosition(InstanceId, InstanceRoomId, _selectedChar.CharPos.Pos); // } // var startPos = MapManager.Instance.GetStartPos(indunData.RoomFile); // _selectedChar.SetEnterInstancePosition(roomMapTree.InstanceId, roomId, startPos); // if (!await GameServerApp.Instance.LastPositionStorage.SetLastPositionInfo(AccountGuid, _selectedChar.LastPositionInfo)) // { // Log.getLogger().error($"{Id} Fail Position Save."); // clientToGame.Response.ErrorCode = ServerErrorCode.PositionSaveFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await MoveServerSaveInfo(indunData.PlaceType) == false) // { // Log.getLogger().error($"MovePlace Failed. PlaceType : {indunData.PlaceType}"); // clientToGame.Response.ErrorCode = ServerErrorCode.JoinInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string serverName = ServerUtil.CreateServerName(ServerType.Indun, instanceRoom.InstanceAddress, instanceRoom.InstancePort); // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, serverName); // if (otp == string.Empty) // { // Log.getLogger().error($"{Id} Fail make otp."); // clientToGame.Response.ErrorCode = ServerErrorCode.MakeFailOtp; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _StartMoving = true; // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.JoinInstanceRes.InstanceServerAddr = instanceRoom.InstanceAddress; // clientToGame.Response.JoinInstanceRes.InstanceServerPort = instanceRoom.InstancePort; // clientToGame.Response.JoinInstanceRes.Otp = otp; // clientToGame.Response.JoinInstanceRes.RoomId = instanceRoom.roomId; // //join instance 가 채널에서 발생한 것이 아니면 인스턴스간 이동으로 보고 leave 체크한다. 상태관리가 안되서 우선 먼저 보낸다. 수정필요 // if (GameServerApp.Instance.Config.GameServerType != EGameServerType.Channel) // { // if (indunData.PlaceType == EPlaceType.Instance) // { // } // Send(RmiContext.ReliableSend, clientToGame); // if (stage_log_info != null) // { // invokers.Add(new StageLog( stage_log_info)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // } // /// // /// *인스턴스 나가기 요청 패킷 처리*
// /// 인스턴스(인스턴스 룸, 마이홈, 피팅룸 등)에서 게임 서버로 이동시 사용
// /// 접속할 게임 서버 정보 얻어서 레디스에 이동 정보 등록 후 클라에 정보 전송 // ///
// /// // /// // async Task HandleLeaveInstanceReq(LeaveInstanceReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.LeaveInstanceRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.LeaveInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // int current_instance_id = InstanceId; // var gameServerInfo = await GetGameServerInfoToConnect(_selectedChar.LastPositionInfo.LastGameServerWorldId, _loginInfo.Language); // if (gameServerInfo == null) // { // Log.getLogger().error($"{Id} Need GameServer !!! GameServer is full or not exsit"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistGameServerForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.StageExit); // StageLogInfo? stage_log_info = null; // _selectedChar.getCurrentStateInfo(this, out stage_log_info); // _selectedChar.LastPositionInfo.m_last_stage_exit_tran_guid = log_action.getTranId(); // if (!await GameServerApp.Instance.LastPositionStorage.SetLastPositionInfo(AccountGuid, _selectedChar.LastPositionInfo)) // { // Log.getLogger().error($"{Id} Fail Position Save."); // clientToGame.Response.ErrorCode = ServerErrorCode.PositionSaveFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await MoveServerSaveInfo(EPlaceType.World) == false) // { // Log.getLogger().error($"MovePlace Failed. World"); // clientToGame.Response.ErrorCode = ServerErrorCode.LeaveInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, gameServerInfo.Name); // if (otp == String.Empty) // { // Log.getLogger().error($"{Id} Fail make otp."); // clientToGame.Response.ErrorCode = ServerErrorCode.MakeFailOtp; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (InstanceRoomId != string.Empty) // { // await InstanceRoomManager.Instance.LeaveRoom(this, InstanceRoomId); // } // _StartMoving = true; // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.LeaveInstanceRes.GameServerAddr = gameServerInfo.Address; // clientToGame.Response.LeaveInstanceRes.GameServerPort = gameServerInfo.Port; // clientToGame.Response.LeaveInstanceRes.Otp = otp; // //퀘스트와 관련된 정보로만 사용중 // if (!TableData.Instance._IndunTable.TryGetValue(current_instance_id, out var indunData)) // { // Log.getLogger().error($"{Id} Not Found IndunData. instanceId:{InstanceId}"); // } // else // { // if (indunData.PlaceType == EPlaceType.Concert) // { // } // } // Send(RmiContext.ReliableSend, clientToGame); // if (stage_log_info != null) // { // invokers.Add(new StageLog(stage_log_info)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // } // async Task HandleJoinInstanceRoomReq(JoinInstanceRoomReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.JoinInstanceRoomRes = new JoinInstanceRoomRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"Not Exist SelectedCharacter accountId:{Id}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var roomInfo = await GameServerApp.Instance.InstanceRoomStorage.GetInstanceRoomInfo(message.RoomId); // if (roomInfo == null) // { // Log.getLogger().error("Not Exist InstanceRoom in Redis"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistInstanceRoom; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var serverName = ServerUtil.CreateServerName(ServerType.Indun, roomInfo.InstanceAddress, roomInfo.InstancePort); // if (serverName != GameServer.Instance.ServerName) // { // Log.getLogger().error("Not Correct Server"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotCorrectServer; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await GameServerApp.Instance.InstanceRoomStorage.IsReservedInstanceRoom(message.RoomId, Id) == false) // { // Log.getLogger().error("Not Reserved InstanceRoom"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotCorrectInstanceRoom; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // //if (InstanceRoomManager.Instance.JoinRoom(this, message.RoomId, roomInfo.InstanceId, out var joinedRoom) == false) // //{ // // clientToGame.Response.ErrorCode = ServerErrorCode.JoinRoomFail; // // Send(RmiContext.ReliableSend, clientToGame); // // return; // //} // //joinedRoom.SendJoinSuccess(this); // } // async Task HandleLeaveInstanceRoomReq(ClientToGameReq.Types.LeaveInstanceRoomReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.LeaveInstanceRoomRes = new ClientToGameRes.Types.LeaveInstanceRoomRes(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // if (!await InstanceRoomManager.Instance.LeaveRoom(this, InstanceRoomId)) // { // Log.getLogger().error($"fail LeaveRoom : {InstanceRoomId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistInstanceRoom; // } // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleEnterMyHomeReq(ClientToGameReq.Types.EnterMyHomeReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.EnterMyHomeRes = new ClientToGameRes.Types.EnterMyHomeRes(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string roomId = await InstanceRoomHandler.JoinMyHomeInstance(Id, myHome.GetMyHomeId()); // if (roomId == String.Empty) // { // Log.getLogger().error("Join fail !!! MyHome Instance"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // InstanceRoomInfo? instanceRoom = await GameServerApp.Instance.InstanceRoomStorage.GetInstanceRoomInfo(roomId); // if (instanceRoom == null) // { // Log.getLogger().error("Instance room info is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await MoveServerSaveInfo(EPlaceType.MyHome) == false) // { // Log.getLogger().error($"MovePlace Failed. Myhome"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string serverName = ServerUtil.CreateServerName(ServerType.Indun, instanceRoom.InstanceAddress, instanceRoom.InstancePort); // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, serverName); // if (otp == String.Empty) // { // Log.getLogger().error("otp is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _StartMoving = true; // _selectedChar.LeaveWorld(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.EnterMyHomeRes.InstanceServerAddr = instanceRoom.InstanceAddress; // clientToGame.Response.EnterMyHomeRes.InstanceServerPort = instanceRoom.InstancePort; // clientToGame.Response.EnterMyHomeRes.Otp = otp; // clientToGame.Response.EnterMyHomeRes.RoomId = instanceRoom.roomId; // Send(RmiContext.ReliableSend, clientToGame); // } // /// // /// *마이홈 나가기 요청 패킷 처리*
// /// 마이홈에서 게임 서버로 이동시 사용
// /// 접속할 게임 서버 정보 얻어서 레디스에 이동 정보 등록 후 클라에 정보 전송 // ///
// /// // /// // async Task HandleLeaveMyHomeReq(ClientToGameReq.Types.LeaveMyHomeReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.LeaveMyHomeRes = new ClientToGameRes.Types.LeaveMyHomeRes(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.LeaveMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (InstanceRoomId != string.Empty) // { // await InstanceRoomManager.Instance.LeaveRoom(this, InstanceRoomId); // } // var gameServerInfo = await GetGameServerInfoToConnect(1, _loginInfo.Language); //임시 // if (gameServerInfo == null) // { // Log.getLogger().error("Need GameServer !!! GameServer is full or not exsit"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistGameServerForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await MoveServerSaveInfo(EPlaceType.World) == false) // { // Log.getLogger().error($"MovePlace Failed. World"); // clientToGame.Response.ErrorCode = ServerErrorCode.LeaveMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, gameServerInfo.Name); // if (otp == String.Empty) // { // Log.getLogger().error("StartMoving fail"); // clientToGame.Response.ErrorCode = ServerErrorCode.LeaveMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _StartMoving = true; // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.LeaveMyHomeRes.GameServerAddr = gameServerInfo.Address; // clientToGame.Response.LeaveMyHomeRes.GameServerPort = gameServerInfo.Port; // clientToGame.Response.LeaveMyHomeRes.Otp = otp; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleExchangeMyHomeReq(ExchangeMyHomeReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.ExchagneMyHomeRes = new ExchagneMyHomeRes(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.LeaveMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (InstanceRoomId != $"myhome:{Id}") // { // Log.getLogger().error($"{Id} Not MyHome Owner !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotMyHomeOwner; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._MyHomeTable.TryGetValue(message.MyHomeId, out var myHomeData)) // { // Log.getLogger().error($"{Id} MyHomeId : {message.MyHomeId} Not found !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundMyHomeData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var startPos = MapManager.Instance.GetStartPos(myHomeData.RoomFile); // if (!myHome.ExchangeMyHome(message.MyHomeId, out var changedDocument)) // { // Log.getLogger().error($"{Id} Fail Exchange MyHome !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeMyHomeFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var error_code = InstanceRoomManager.Instance.ExchangeMyHome(InstanceRoomId, message.MyHomeId); // if (error_code.isFail()) // { // myHome.RollBackMyHome(); // Log.getLogger().error($"{Id} Fail Exchange MyHome !!!"); // clientToGame.Response.ErrorCode = error_code; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // await GameServerApp.Instance.MainDB.UpdateDocument(changedDocument); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.ExchagneMyHomeRes.NewStartPos = startPos; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleExchangeMyHomePropReq(ExchangeMyHomePropReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.ExchagneMyHomePropRes = new ExchagneMyHomePropRes(); // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map == null) // { // Log.getLogger().error($"Not Exist Map", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar._inventory.GetItem(message.ItmeGuid, out var item)) // { // Log.getLogger().error($"{Id} Not Found Item. itemGuid:{message.ItmeGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundItem; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._ItemTable.TryGetValue(item.Attr.ItemId, out var itemData)) // { // Log.getLogger().error($"{Id} Not Found ItemTableId. itemTableId:{item.Attr.ItemId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundItemTableId; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (InstanceRoomId != $"myhome:{Id}") // { // Log.getLogger().error($"{Id} Not MyHome Owner !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotMyHomeOwner; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.map.Anchors.TryGetValue(message.AnchorGuid, out var anchorInfo)) // { // Log.getLogger().error($"{Id} Not Found AnchorData. anchorGuid:{message.AnchorGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundAnchorGuid; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!myHome.ExchangeMyHomeProp(message.AnchorGuid, message.ItmeGuid, item.Attr.ItemId, out var changedDocument)) // { // Log.getLogger().error($"{Id} Fail ExchangeMyHomeProp. anchorGuid:{message.AnchorGuid} itemGuid:{message.ItmeGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeMyHomePropFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var error_code = InstanceRoomManager.Instance.ExchangeMyHomeProp(InstanceRoomId, message.AnchorGuid, item.Attr.ItemId, item.Attr.ItemGuid); // if (error_code.isFail()) // { // myHome.RollBackMyHome(); // Log.getLogger().error($"{Id} Fail Exchange MyHomeProp !!!"); // clientToGame.Response.ErrorCode = error_code; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // await GameServerApp.Instance.MainDB.UpdateDocument(changedDocument); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.ExchagneMyHomePropRes.AnchorGuid = message.AnchorGuid; // clientToGame.Response.ExchagneMyHomePropRes.ItmeGuid = message.ItmeGuid; // Send(RmiContext.ReliableSend, clientToGame); // _selectedChar.map.PropModifyNoti(message.AnchorGuid); // } // async Task HandleExchangeLandPropReq(ClientToGameReq.Types.ExchangeLandPropReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.ExchangeLandPropRes = new ClientToGameRes.Types.ExchangeLandPropRes(); // { // // TODO: message.AnchorGuid 확인 // // TODO: message.ItemGuid 확인 // if (!ownedLand.IsOwnedLand(message.LandId)) // { // Log.getLogger().error($"{Id} Not Owned Land. landId:{message.LandId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeLandPropFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!LandManager.Instance.ExchangeLandProp(message.LandId, message.AnchorGuid, message.ItemGuid, out var oldItemGuid, out var changedLandEntity)) // { // Log.getLogger().error($"{Id} Fail ExchangeLandProp. landId:{message.LandId} anchorGuid:{message.AnchorGuid} itemGuid:{message.ItemGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeLandPropFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (oldItemGuid != null) // { // // TODO: oldItemGuid 처리 // } // await GameServerApp.Instance.MainDB.UpdateLand(changedLandEntity); // } // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleExchangeBuildingReq(ClientToGameReq.Types.ExchangeBuildingReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.ExchangeBuildingRes = new ClientToGameRes.Types.ExchangeBuildingRes(); // { // if (!ownedLand.IsOwnedLand(message.LandId)) // { // Log.getLogger().error($"Not Owned Land : {message.LandId} !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!ownedBuilding.GetBuildingEntity(message.BuildingId, out var newBuildingEntity)) // { // Log.getLogger().error($"Not Owned Building : {message.BuildingId} !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (LandManager.Instance.IsBuildingOnLand(message.BuildingId)) // { // Log.getLogger().error($"On Land Building : {message.BuildingId} !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!LandManager.Instance.ExchangeBuilding(message.LandId, message.BuildingId, out var oldBuildingId, out var changedLandEntity)) // { // Log.getLogger().error("Fail Exchange Building on LandManager !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!BuildingManager.Instance.ExchangeBuilding(newBuildingEntity, oldBuildingId, out var oldBuildingEntity)) // { // LandManager.Instance.RollBackExchangeBuilding(changedLandEntity, oldBuildingId); // Log.getLogger().error("Fail Exchange Building on BuildingManager !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!ownedBuilding.ClearBuildingPropAndInstance(oldBuildingId, out var changedBuildingEntity)) // { // LandManager.Instance.RollBackExchangeBuilding(changedLandEntity, oldBuildingId); // if (!BuildingManager.Instance.ExchangeBuilding(oldBuildingEntity, newBuildingEntity.PK_Id, out _)) // { // Log.getLogger().error("******* Critical Error Rollback failed *******"); // } // Log.getLogger().error("Fail Clear Building Prop and Instance !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // await GameServerApp.Instance.MainDB.UpdateLand(changedLandEntity); // await GameServerApp.Instance.MainDB.UpdateBuilding(changedBuildingEntity); // } // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleExchangeBuildingLFPropReq(ClientToGameReq.Types.ExchangeBuildingLFPropReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ExchangeBuildingLFPropRes = new(); // { // if (!LandManager.Instance.IsBuildingOnLand(message.BuildingId)) // { // Log.getLogger().error($"Not On Land Building : {message.BuildingId} !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingLfpropFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!BuildingManager.Instance.GetBuildingEntity(message.BuildingId, out _)) // { // Log.getLogger().error($"Not Land Building : {message.BuildingId} !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingLfpropFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // // TODO: message.AnchorGuid 확인 // // TODO: message.ItemGuid 확인 // if (!ownedBuilding.ExchangeProp(message.BuildingId, message.AnchorGuid, message.ItemGuid, out var changedBuildingEntity)) // { // Log.getLogger().error("Fail Change Building LF Prop !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingLfpropFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // // 1 // // BuildingManager.Instance.ForcedUpdateBuilding(changedBuildingEntity); // // 2 // //if (!BuildingManager.Instance.UpdateLFProp(message.BuildingId, message.AnchorGuid, message.ItemGuid)) // //{ // // ownedBuilding.RollBackExchangeProp(changedBuildingEntity, message.AnchorGuid, oldItemGuid); // // Log.getLogger().error("Fail Update Building LF Prop !!!"); // // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeBuildingLfpropFail; // // Send(RmiContext.ReliableSend, clientToGame); // // return; // //} // // TODO: 1, 2번 중에 선택 // // TODO: oldItemGuid 처리 // await GameServerApp.Instance.MainDB.UpdateBuilding(changedBuildingEntity); // } // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleExchangeInstanceReq(ClientToGameReq.Types.ExchangeInstanceReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.ExchangeInstanceRes = new ClientToGameRes.Types.ExchangeInstanceRes(); // { // if (GameServerApp.Instance.MainDB == null) // { // Log.getLogger().error("MainDB is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!LandManager.Instance.IsBuildingOnLand(message.BuildingId)) // { // Log.getLogger().error($"Not On Land Building : {message.BuildingId} !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!ownedBuilding.GetBuildingEntity(message.BuildingId, out var buildingEntity)) // { // Log.getLogger().error($"Not Owned Building : {message.BuildingId} !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!ownedBuilding.ExchangeInstance(message.BuildingId, message.Floor, message.InstanceId, out var oldInstanceId, out var changedBuildingEntity)) // { // Log.getLogger().error("Fail Change Instance !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // // 1 // // BuildingManager.Instance.ForcedUpdateBuilding(changedBuildingEntity); // // 2 // if (!BuildingManager.Instance.UpdateInstance(message.BuildingId, message.Floor, message.InstanceId)) // { // ownedBuilding.RollBackExchangeInstance(changedBuildingEntity, message.Floor, oldInstanceId); // Log.getLogger().error("Fail Update Building Instance !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // // TODO: 1, 2번 중에 선택 // // TODO: oldInstanceId 처리 // await GameServerApp.Instance.MainDB.UpdateBuilding(changedBuildingEntity); // } // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleExchangeSocialActionSlotReq(ClientToGameReq.Types.ExchangeSocialActionSlotReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.ExchangeSocialActionSlotRes = new ClientToGameRes.Types.ExchangeSocialActionSlotRes(); // { // if (message.SocialActionSlot < 0 || message.SocialActionSlot >= ServerCommon.Constant.MAX_SOCIAL_ACTION_SLOT) // { // Log.getLogger().error($"{Id} Out Of Range(0~{Constant.MAX_SOCIAL_ACTION_SLOT - 1}). SocialActionSlot:{message.SocialActionSlot}"); // clientToGame.Response.ErrorCode = ServerErrorCode.SocialActionSlotOutOfRange; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._SocialActionTable.TryGetValue(message.SocialActionId, out _)) // { // if (message.SocialActionId != 0) // { // Log.getLogger().error($"{Id} Not Found SocialActionId. socialActionId:{message.SocialActionId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundSocialActionData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // if (!ownedSocialAction.ExchangeSocialActionSlot(message.SocialActionSlot, message.SocialActionId, out var changedDocument)) // { // Log.getLogger().error($"{Id} Fail ExchangeSocialActionSlot. slot:{message.SocialActionSlot} socialActionId:{message.SocialActionId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeSocialActionSlotFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // await GameServerApp.Instance.MainDB.UpdateDocument(changedDocument); // } // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleExchangeEmotionSlotReq(ClientToGameReq.Types.ExchangeEmotionSlotReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.ExchangeEmotionSlotRes = new ClientToGameRes.Types.ExchangeEmotionSlotRes(); // { // if (message.EmotionSlot < 0 || message.EmotionSlot >= ServerCommon.Constant.MAX_EMOTION_SLOT) // { // Log.getLogger().error($"{Id} Out Of Range(0~{Constant.MAX_EMOTION_SLOT - 1}). EmotionSlot:{message.EmotionSlot}"); // clientToGame.Response.ErrorCode = ServerErrorCode.EmotionSlotOutOfRange; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._EmotionTable.TryGetValue(message.EmotionId, out _)) // { // if (message.EmotionId != 0) // { // Log.getLogger().error($"{Id} Not Found EmotionData. emotionId:{message.EmotionId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundEmotionData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // if (!ownedEmotion.ExchangeEmotionSlot(message.EmotionSlot, message.EmotionId, out var updatedDocument)) // { // Log.getLogger().error($"{Id} Fail ExchangeEmotionSlot. slot:{message.EmotionSlot} emotionId:{message.EmotionId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ExchangeEmotionSlotFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // await GameServerApp.Instance.MainDB.UpdateDocument(updatedDocument); // } // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleEnterFittingRoomReq(ClientToGameReq.Types.EnterFittingRoomReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.EnterFittingRoomRes = new ClientToGameRes.Types.EnterFittingRoomRes(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterFittingRoomFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string roomId = await InstanceRoomHandler.JoinFittingRoomInstance(Id); // if (roomId == String.Empty) // { // Log.getLogger().error("Join fail !!! FittingRoom Instance"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterFittingRoomFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // InstanceRoomInfo? instanceRoom = await GameServerApp.Instance.InstanceRoomStorage.GetInstanceRoomInfo(roomId); // if (instanceRoom == null) // { // Log.getLogger().error("Instance room info is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterFittingRoomFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await MoveServerSaveInfo(EPlaceType.DressRoom) == false) // { // Log.getLogger().error($"MovePlace Failed. DressRoom"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterFittingRoomFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string serverName = ServerUtil.CreateServerName(ServerType.Indun, instanceRoom.InstanceAddress, instanceRoom.InstancePort); // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, serverName); // if (otp == String.Empty) // { // Log.getLogger().error("otp is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterFittingRoomFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _StartMoving = true; // _selectedChar.LeaveWorld(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.EnterFittingRoomRes.InstanceServerAddr = instanceRoom.InstanceAddress; // clientToGame.Response.EnterFittingRoomRes.InstanceServerPort = instanceRoom.InstancePort; // clientToGame.Response.EnterFittingRoomRes.Otp = otp; // clientToGame.Response.EnterFittingRoomRes.RoomId = instanceRoom.roomId; // Send(RmiContext.ReliableSend, clientToGame); // } // /// // /// *프랍 사용 요청 패킷 처리*
// ///
// /// // /// // Task HandleUseMountPropReq(UseMountPropReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.UseMountPropRes = new UseMountPropRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return Task.CompletedTask; // } // if (_selectedChar.map is null) // { // Log.getLogger().error($"{Id} Not Exist Map."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return Task.CompletedTask; // } // if (!_selectedChar.map.Anchors.TryGetValue(message.AnchorGuid, out var anchorInfo)) // { // Log.getLogger().error($"{Id} Not Found AnchorData. anchorGuid:{message.AnchorGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundAnchorGuid; // Send(RmiContext.ReliableSend, clientToGame); // return Task.CompletedTask; // } // //if (ClientSessionManager.Instance.GetSessionByName(anchorInfo.OccupyingAccountId) == null) // //{ // // anchorInfo.OccupyingUserGuid = string.Empty; // //} // if (anchorInfo.OccupyingUserGuid != string.Empty) // { // Log.getLogger().error($"{Id} Prop is Occupied"); // clientToGame.Response.ErrorCode = ServerErrorCode.PropIsOccupied; // Send(RmiContext.ReliableSend, clientToGame); // return Task.CompletedTask; // } // // 프랍 사용 처리 // _selectedChar.OccupiedAnchorGuid = message.AnchorGuid; // anchorInfo.OccupyingUserGuid = AccountGuid; // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.UseMountPropRes.AnchorGuid = message.AnchorGuid; // Send(RmiContext.ReliableSend, clientToGame); // { // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.UseMountPropNoti = new(); // clientToGameNoti.Message.UseMountPropNoti.AnchorGuid = message.AnchorGuid; // clientToGameNoti.Message.UseMountPropNoti.ActorGuid = AccountGuid; // _selectedChar.map.Broadcast(_selectedChar, clientToGameNoti); // } // return Task.CompletedTask; // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleEndUseMountPropReq(EndUseMountPropReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.EndUseMountPropRes = new ClientToGameRes.Types.EndUseMountPropRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map is null) // { // Log.getLogger().error($"{Id} Not Exist Map."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.map.Anchors.TryGetValue(message.AnchorGuid, out var anchorInfo)) // { // Log.getLogger().error($"{Id} Not Found AnchorData. anchorGuid:{message.AnchorGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundAnchorGuid; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar.OccupiedAnchorGuid = string.Empty; // anchorInfo.OccupyingUserGuid = string.Empty; // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.EndUseMountPropRes.AnchorGuid = message.AnchorGuid; // Send(RmiContext.ReliableSend, clientToGame); // } // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Message = new ClientToGameMessage(); // clientToGame.Message.EndUseMountPropNoti = new ClientToGameMessage.Types.EndUseMountPropNoti(); // clientToGame.Message.EndUseMountPropNoti.AnchorGuid = message.AnchorGuid; // clientToGame.Message.EndUseMountPropNoti.ActorGuid = AccountGuid; // _selectedChar.map.Broadcast(_selectedChar, clientToGame); // } // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleUseSocialActionReq(UseSocialActionReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.UseSocialActionRes = new ClientToGameRes.Types.UseSocialActionRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map is null) // { // Log.getLogger().error($"{Id} Not Exist Map"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._SocialActionTable.TryGetValue(message.SocialActionId, out _)) // { // Log.getLogger().error($"{Id} Not Found SocialActionData. socialActionId:{message.SocialActionId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundSocialActionData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!ownedSocialAction.IsSocialActionOnSlot(message.SocialActionId)) // { // Log.getLogger().error($"{Id} Not in SocialActionSlot. socialActionId:{message.SocialActionId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotInSocialActionSlot; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedSocialAction.SetPlaySocialAction(message.SocialActionId); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.UseSocialActionRes.SocialActionId = message.SocialActionId; // Send(RmiContext.ReliableSend, clientToGame); // } // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Message = new ClientToGameMessage(); // clientToGame.Message.PlaySocialActionNoti = new ClientToGameMessage.Types.PlaySocialActionNoti(); // clientToGame.Message.PlaySocialActionNoti.ActorGuid = AccountGuid; // clientToGame.Message.PlaySocialActionNoti.SocialActionId = ownedSocialAction.PlayingSocialActionId; // clientToGame.Message.PlaySocialActionNoti.StartTime = ownedSocialAction.SocialActionStartTime.ToTimestamp(); // _selectedChar.map.Broadcast(_selectedChar, clientToGame); // } // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleStopSocialActionReq(StopSocialActionReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.StopSocialActionRes = new ClientToGameRes.Types.StopSocialActionRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map is null) // { // Log.getLogger().error($"{Id} Not Exist Map"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedSocialAction.RemovePlaySocialAction(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Message = new ClientToGameMessage(); // clientToGame.Message.StopSocialActionNoti = new ClientToGameMessage.Types.StopSocialActionNoti(); // clientToGame.Message.StopSocialActionNoti.ActorGuid = AccountGuid; // _selectedChar.map.Broadcast(_selectedChar, clientToGame); // } // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleUseEmotionReq(UseEmotionReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.UseEmotionRes = new ClientToGameRes.Types.UseEmotionRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map is null) // { // Log.getLogger().error($"{Id} Not Exist Map"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._EmotionTable.TryGetValue(message.EmotionId, out _)) // { // Log.getLogger().error($"{Id} Not Found EmotionData. emotionId:{message.EmotionId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundEmotionData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!ownedEmotion.IsEmotionOnSlot(message.EmotionId)) // { // Log.getLogger().error($"{Id} Not in EmotionSlot. emotionId:{message.EmotionId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotInEmotionSlot; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedEmotion.SetPlayEmotion(message.EmotionId); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.UseEmotionRes.EmotionId = message.EmotionId; // Send(RmiContext.ReliableSend, clientToGame); // } // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Message = new ClientToGameMessage(); // clientToGame.Message.PlayEmotionNoti = new ClientToGameMessage.Types.PlayEmotionNoti(); // clientToGame.Message.PlayEmotionNoti.ActorGuid = AccountGuid; // clientToGame.Message.PlayEmotionNoti.EmotionId = ownedEmotion.PlayingEmotionId; // clientToGame.Message.PlayEmotionNoti.StartTime = ownedEmotion.EmotionStartTime.ToTimestamp(); // _selectedChar.map.Broadcast(_selectedChar, clientToGame); // } // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleStopEmotionReq(StopEmotionReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.StopEmotionRes = new ClientToGameRes.Types.StopEmotionRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map is null) // { // Log.getLogger().error($"{Id} Not Exist Map"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedEmotion.RemovePlayEmotion(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Message = new ClientToGameMessage(); // clientToGame.Message.StopEmotionNoti = new ClientToGameMessage.Types.StopEmotionNoti(); // clientToGame.Message.StopEmotionNoti.ActorGuid = AccountGuid; // _selectedChar.map.Broadcast(_selectedChar, clientToGame); // } // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleSocialActionTogetherReq(ClientToGameReq.Types.SocialActionTogetherReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.SocialActionTogetherRes = new ClientToGameRes.Types.SocialActionTogetherRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map is null) // { // Log.getLogger().error($"{Id} Not Exist Map"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var targetSession = ClientSessionManager.Instance.GetSessionByName(message.Name); // if (targetSession == null) // { // Log.getLogger().error($"{Id} Not Found Target Character. accountId:{message.Name}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var socialActionId = targetSession.ownedSocialAction.PlayingSocialActionId; // var startTime = targetSession.ownedSocialAction.SocialActionStartTime; // ownedSocialAction.SetPlaySocialAction(socialActionId, startTime); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.UseSocialActionRes.SocialActionId = ownedSocialAction.PlayingSocialActionId; // Send(RmiContext.ReliableSend, clientToGame); // } // { // ClientToGame clientToGame = new(); // clientToGame.Message = new(); // clientToGame.Message.PlaySocialActionNoti = new(); // clientToGame.Message.PlaySocialActionNoti.ActorGuid = AccountGuid; // clientToGame.Message.PlaySocialActionNoti.SocialActionId = ownedSocialAction.PlayingSocialActionId; // clientToGame.Message.PlaySocialActionNoti.StartTime = ownedSocialAction.SocialActionStartTime.ToTimestamp(); // _selectedChar.map.Broadcast(_selectedChar, clientToGame); // } // } // async Task HandleReadyToFoecedMoveReq(ReadyToForcedMoveReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ReadyToFoecedMoveRes = new(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!GameServerApp.Instance.GetForecedMoveInfoFromGM(message.GMName, out var forcedMoveConnectInfo)) // { // Log.getLogger().error($"{Id} GM: {message.GMName} Not Exist ForecedMoveInfo"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistForecedMoveInfo; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // int x = ServerUtil.rnd.Next(-1000, 1000); // int y = ServerUtil.rnd.Next(-1000, 1000); // Pos newPos = ServerUtil.MakePos(forcedMoveConnectInfo.Pos.X + x, forcedMoveConnectInfo.Pos.Y + y, forcedMoveConnectInfo.Pos.Z, 0); // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.StageExit); // StageLogInfo? stage_log_info = null; // _selectedChar.getCurrentStateInfo(this, out stage_log_info); // _selectedChar.LastPositionInfo.m_last_stage_exit_tran_guid = log_action.getTranId(); // //같은 서버 // if (forcedMoveConnectInfo.ServerName == GameServer.Instance.ServerName) // { // _selectedChar.Teleport(newPos); // clientToGame.Response.ReadyToFoecedMoveRes.Pos = newPos; // stage_log_info = null; // } // else if (forcedMoveConnectInfo.RoomId == string.Empty)//채널로 이동 // { // var gameServerInfo = await GameServerApp.Instance.ServerCUStorage.getServerCU(forcedMoveConnectInfo.ServerName); // if (gameServerInfo == null) // { // Log.getLogger().error("NotFound GameServer !!!"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistGameServerForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // await GameServerApp.Instance.LastPositionStorage.SetLastPositionInfo(AccountGuid, _selectedChar.LastPositionInfo); // if (await MoveServerSaveInfo(EPlaceType.World) == false) // { // Log.getLogger().error($"MovePlace Failed. World"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistGameServerForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, forcedMoveConnectInfo.ServerName); // if (otp == String.Empty) // { // Log.getLogger().error($"{Id} Fail make otp."); // clientToGame.Response.ErrorCode = ServerErrorCode.MakeFailOtp; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _StartMoving = true; // clientToGame.Response.ReadyToFoecedMoveRes.ServerConnectInfo = new ServerConnectInfo // { // ServerAddr = gameServerInfo.Address, // ServerPort = gameServerInfo.Port, // Otp = otp // }; // } // else//인던으로 이동 // { // var roomInfo = await GameServerApp.Instance.InstanceRoomStorage.GetInstanceRoomInfo(forcedMoveConnectInfo.RoomId); // if (roomInfo == null) // { // Log.getLogger().error("Not Exist InstanceRoom in Redis"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistInstanceRoom; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string roomId = await InstanceRoomHandler.JoinInstance(roomInfo.InstanceId, Id); // if (roomId == String.Empty) // { // Log.getLogger().error($"{Id} Fail JoinInstance. instanceId:{roomInfo.InstanceId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.JoinInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // InstanceRoomInfo? instanceRoom = await GameServerApp.Instance.InstanceRoomStorage.GetInstanceRoomInfo(roomId); // if (instanceRoom == null) // { // Log.getLogger().error($"{Id} Not found InstanceRoomInfo. roomId:{roomId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistRoomInfoForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // await GameServerApp.Instance.LastPositionStorage.SetLastPositionInfo(AccountGuid, _selectedChar.LastPositionInfo); // //myhome과 fittingroom같은곳은 해당하지 않음. // if (await MoveServerSaveInfo(EPlaceType.Instance) == false) // { // Log.getLogger().error($"MovePlace Failed. Instance"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistInstanceRoom; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, forcedMoveConnectInfo.ServerName); // if (otp == String.Empty) // { // Log.getLogger().error($"{Id} Fail make otp."); // clientToGame.Response.ErrorCode = ServerErrorCode.MakeFailOtp; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _StartMoving = true; // clientToGame.Response.ReadyToFoecedMoveRes.ServerConnectInfo = new ServerConnectInfo // { // ServerAddr = instanceRoom.InstanceAddress, // ServerPort = instanceRoom.InstancePort, // Otp = otp, // RoomId = roomId, // }; // } // Send(RmiContext.ReliableSend, clientToGame); // if (stage_log_info != null) // { // invokers.Add(new StageLog(stage_log_info)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleEnterCESConcertReq(EnterCESConcertReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.EnterCESConcertRes = new EnterCESConcertRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (TableData.Instance._IndunTable.TryGetValue(message.InstanceId, out var instanceData) == false) // { // Log.getLogger().error($"not found IndunTable id:{1}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (TableData.Instance._ConcertTable.TryGetValue(instanceData.MapId, out var concertInfo) == false) // { // Log.getLogger().error($"not found Concert id:{instanceData.MapId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (concertInfo.BuffID != 0) // { // StartBuff(concertInfo.BuffID); // } // _selectedChar.IsCESConcert = true; // LastPosBeforeCESConcert = _selectedChar.CharPos.Pos; // if (instanceData.PlaceType != EPlaceType.Concert && instanceData.PlaceType != EPlaceType.Movie) // { // Log.getLogger().error($"Invalid IndunType type:{instanceData.PlaceType}"); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidType; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await MoveServerSaveInfo(instanceData.PlaceType) == false) // { // Log.getLogger().error($"MovePlace Failed. EPlaceType : {instanceData.PlaceType}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundIndunData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar.LeaveMap(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleLeaveCESConcertReq(LeaveCESConcertReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.LeaveCESConcertRes = new ClientToGameRes.Types.LeaveCESConcertRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar.IsCESConcert = false; // _selectedChar.CharPos.Pos = LastPosBeforeCESConcert; // if (await MoveServerSaveInfo(EPlaceType.World) == false) // { // Log.getLogger().error($"MovePlace Failed. World"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistGameServerForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar.EnterMap(); // clientToGame.Response.LeaveCESConcertRes.Pos = LastPosBeforeCESConcert; // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleChangeNickNameReq(ChangeNickNameReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ChangeNickNameRes = new(); // if (_selectedChar is null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var errorCode = await _selectedChar.changeNickName(message.NickName); // if(errorCode != ServerErrorCode.Success) // { // Log.getLogger().error($"change NickName Failed.", ToString()); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // clientToGame.Response.ChangeNickNameRes.NickName = message.NickName; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleChangeGameOptionReq(ChangeGameOptionReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ChangeGameOptionRes = new(); // if (await SaveGameOption(message.ValuesList) == false) // { // Log.getLogger().error($"HandleChangeGameOptionReq DB Failed"); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleSendMailReq(SendMailReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.SendMailRes = new(); // if (_selectedChar is null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string receiverId = string.Empty; // string receiverGuid = string.Empty; // if (message.ToGuid == string.Empty) // { // if (message.ToNickName == getUserNickname()) // { // Log.getLogger().error($"InvalidTarget. Same NickName with Sender"); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidTarget; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // NickNameEntity? nickNameEntity = await GameServerApp.Instance.MainDB.GetEntityFromNickName(message.ToNickName); // if (nickNameEntity is null) // { // Log.getLogger().error($"InvalidTarget. ToNickNameINfo is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidTarget; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // receiverGuid = nickNameEntity.Attr.AccountGuid; // receiverId = nickNameEntity.Attr.AccountId; // } // else // { // if (message.ToGuid == _selectedChar.Guid) // { // Log.getLogger().info($"InvalidTarget. Same NickName with Sender"); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidTarget; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List? list = await GameServerApp.Instance.MainDB.ListChar(message.ToGuid); // if (list == null || list.Count == 0) // { // Log.getLogger().info($"list is null AccountGuid : {message.ToGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidTarget; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (list[0].CharInfo.DisplayName != message.ToNickName) //닉네임 변경 // { // Log.getLogger().info($"list is null AccountGuid : {message.ToGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ChangedNickName; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // receiverGuid = list[0].PK_Guid; // receiverId = list[0].Id; // } // //내가 차단한 유저면 보내지 않는다. // if (_selectedChar.ownedBlockList.isBlockUser(receiverGuid)) // { // Log.getLogger().error($"CannotSendMailToBlockUser. "); // clientToGame.Response.ErrorCode = ServerErrorCode.BlockUserCannotSendMailTo; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // //상대방이 나를 차단한거면 이것도 보내지 않는다. // if (await _selectedChar.ownedBlockList.isBlocked(_selectedChar.Guid, receiverGuid)) // { // //그냥 에러 리턴 // clientToGame.Response.ErrorCode = ServerErrorCode.BlockedByOther; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // CharMetaDataEntity MetaDataEntity = new CharMetaDataEntity(ownedCharMetaDataEntity.DocumentForUpdate()); // if (MetaDataEntity.Attr.MailSendUpdateDay < DateTime.UtcNow.Date.Ticks) // { // MetaDataEntity.Attr.MailSendCount = 0; // MetaDataEntity.Attr.MailSendUpdateDay = DateTime.UtcNow.Date.Ticks; // } // if (MetaDataEntity.Attr.MailSendCount >= ServerCommon.Constant.MAX_MAILSEND_COUNT) // { // Log.getLogger().error($"Send Mail Over The Max Count."); // clientToGame.Response.ErrorCode = ServerErrorCode.MailSendCountOver; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var (errorCode, mailInfo) = await SendMailProcess(message.ToNickName, // receiverId, // receiverGuid, // message.Title, // message.MailText, // MetaDataEntity); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error($"HandleSendMailReq Failed."); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // clientToGame.Response.SendMailRes.MailInfo = mailInfo; // Send(RmiContext.ReliableSend, clientToGame); // } // public async Task<(ServerErrorCode, MailInfo)> SendMailProcess(string receiverNickName, string receiverId, string receiverGuid, string title, string mailText, CharMetaDataEntity MetaDataEntity) // { // MailInfo sendedMailInfo = new(); // if (_selectedChar == null) // { // return (ServerErrorCode.MailSystemError, sendedMailInfo); // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.MailDestroy); // DateTime now = DateTime.UtcNow; // string mailKey = ServerUtil.MakeMailKey(now.ToString("yyyy/MM/dd/HH:mm:ss"), ServerUtil.rnd.Next(99999999)); // List dBDocumentInfos = new(); // DateTime expireDate = now.AddDays(ServerCommon.Constant.MAIL_EXPIRE_TIME); // MailEntityAttr attr = new MailEntityAttr(); // attr.mailKey = mailKey; // attr.isRead = false; // attr.isGetItem = false; // attr.senderNickName = getUserNickname(); // attr.senderGuid = _selectedChar.Guid; // attr.receiverNickName = receiverNickName; // attr.receiverGuid = receiverGuid; // attr.title = title; // attr.text = mailText; // attr.createTime = Timestamp.FromDateTime(now); // attr.expireTime = Timestamp.FromDateTime(expireDate); // attr.isSystemMail = false; // Document ReceivedMailDocument = MainDB.DocumentForInsertWithTTL(EEntityType.ReceivedMail, receiverGuid, mailKey, expireDate, attr); // MailEntity ReceivedMailEntity = new ReceivedMailEntity(ReceivedMailDocument); // dBDocumentInfos.Add(new DBDocumentInfo(ReceivedMailDocument, EDBExecuteType.Insert)); // Document SendedMailDocument = MainDB.DocumentForInsertWithTTL(EEntityType.SendedMail, AccountGuid, mailKey, expireDate, attr); // MailEntity SendedMailEntity = new SendedMailEntity(SendedMailDocument); // dBDocumentInfos.Add(new DBDocumentInfo(SendedMailDocument, EDBExecuteType.Insert)); // MetaDataEntity.Attr.MailSendCount += 1; // dBDocumentInfos.Add(new DBDocumentInfo(MetaDataEntity.DocumentForUpdate(), EDBExecuteType.Update)); // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"DB UpdateInventory Failed."); // return (ServerErrorCode.DbUpdateFailed, sendedMailInfo); // } // ownedCharMetaDataEntity.ReadFrom(MetaDataEntity.DocumentForUpdate()); // ownedMail.AddSendedMailToMemory(mailKey, SendedMailEntity); // sendedMailInfo.setMailInfo(SendedMailEntity, EMailType.SENDED_MAIL); // LoginInfo? loginInfo = await GameServerApp.Instance.LoginStorage.GetLoginInfo(receiverId); // if (loginInfo != null) // { // ServerMessage notiMessage = new(); // notiMessage.ReceiveMailNoti = new() { AccountId = receiverId }; // GameServer.Instance._rabbitMQ4Game.SendMessage(loginInfo.CurrentServer, notiMessage); // } // var sendMailLogData = MailBusinessLogHelper.toMailLogInfo(SendedMailEntity); // invokers.Add(new MailLog(sendMailLogData)); // var receivedMailLogData = MailBusinessLogHelper.toMailLogInfo(ReceivedMailEntity); // invokers.Add(new MailLog(receivedMailLogData)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // return (ServerErrorCode.Success, sendedMailInfo); // } // async Task HandleGetMailReq(GetMailReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.GetMailRes = new ClientToGameRes.Types.GetMailRes(); // EMailType mailType = (EMailType)message.MailType; // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (ownedMail.isNewSystemMail == true) // { // await updateSystemMail(); // } // var mailInfoList = await ownedMail.GetMailListInfo(mailType, getUserNickname()); // if (mailInfoList != null) // { // CharMetaDataEntity MetaDataEntity = new CharMetaDataEntity(ownedCharMetaDataEntity.DocumentForUpdate()); // bool needUpdate = false; // CheckMailSendTime(MetaDataEntity, ref needUpdate); // if (needUpdate == true) // { // if (await GameServerApp.Instance.MainDB.UpdateDocument(MetaDataEntity.DocumentForUpdate()) == false) // { // Log.getLogger().error("DB ownedCharMetaDataEntity UpdateCharMetaData Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedCharMetaDataEntity.ReadFrom(MetaDataEntity.DocumentForUpdate()); // } // clientToGame.Response.GetMailRes.MailType = message.MailType; // clientToGame.Response.GetMailRes.SendCount = ownedCharMetaDataEntity.Attr.MailSendCount; // clientToGame.Response.GetMailRes.MailList.AddRange(mailInfoList); // } // Send(RmiContext.ReliableSend, clientToGame); // } // private async Task updateSystemMail() // { // if (_selectedChar == null) // { // return; // } // DateTime now = DateTime.UtcNow; // int SystemMailId = ownedCharMetaDataEntity.Attr.LastGetSystemMailId; // var systemMailList = SystemMailManager.Instance.GetSystemMail(SystemMailId); // List dBDocumentInfos = new(); // foreach (var mailEntity in systemMailList) // { // if (SystemMailId < mailEntity.Id) // { // SystemMailId = mailEntity.Id; // } // string mailKey = ServerUtil.MakeMailKey(now.ToString("yyyy/MM/dd/HH:mm:ss"), mailEntity.Id); // DateTime expireDate = now.AddDays(100); // MailEntityAttr attr = new MailEntityAttr(); // attr.mailKey = mailKey; // attr.isRead = false; // attr.isGetItem = false; // attr.senderNickName = mailEntity.senderNickName; // attr.receiverNickName = getUserNickname(); // attr.title = mailEntity.title; // attr.text = mailEntity.text; // attr.createTime = Timestamp.FromDateTime(now); // attr.expireTime = Timestamp.FromDateTime(expireDate); // attr.isSystemMail = true; // foreach (var itemInfo in mailEntity.ItemList) // { // attr.ItemList.Add(new MailItem() { ItemId = itemInfo.ItemId, Count = itemInfo.Count }); // } // var ReceivedMailDocument = MainDB.DocumentForInsertWithTTL(EEntityType.ReceivedMail, AccountGuid, mailKey, expireDate, attr); // dBDocumentInfos.Add(new DBDocumentInfo(ReceivedMailDocument, EDBExecuteType.Insert)); // } // if (dBDocumentInfos.Count > 0) // { // CharMetaDataEntity MetaDataEntity = new CharMetaDataEntity(ownedCharMetaDataEntity.DocumentForUpdate()); // MetaDataEntity.Attr.LastGetSystemMailId = SystemMailId; // dBDocumentInfos.Add(new DBDocumentInfo(MetaDataEntity.DocumentForUpdate(), EDBExecuteType.Update)); // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"DB UpdateInventory Failed."); // return; // } // ownedCharMetaDataEntity.ReadFrom(MetaDataEntity.DocumentForUpdate()); // ownedMail.isNewReceivedMail = true; // } // ownedMail.isNewSystemMail = false; // } // async Task HandleReadMailReq(ReadMailReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.ReadMailRes = new ClientToGameRes.Types.ReadMailRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.MailRead); // ServerErrorCode errorCode = ownedMail.ReadReceivedMail(message.MailKey, out var newMailEntity); // if (errorCode != ServerErrorCode.Success || newMailEntity == null) // { // Log.getLogger().error($"HandleReadMailReq Failed"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await GameServerApp.Instance.MainDB.UpdateMail(new List() { newMailEntity }) == false) // { // Log.getLogger().error($"DB UpdateMail Failed. mailKey : {message.MailKey}"); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedMail.UpdateReceivedMailToMemory(message.MailKey, newMailEntity); // Send(RmiContext.ReliableSend, clientToGame); // var mailLogData = MailBusinessLogHelper.toMailLogInfo(newMailEntity); // invokers.Add(new MailLog(mailLogData)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // async Task HandleGetItemsMailReq(GetItemsMailReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.GetItemsMailRes = new ClientToGameRes.Types.GetItemsMailRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ServerErrorCode errorCode = ownedMail.GetItemsReceivedMail(message.MailKey, out var newMailEntity); // if (errorCode != ServerErrorCode.Success || newMailEntity == null) // { // Log.getLogger().error($"HandleGetItemsMailReq Failed"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List dBDocumentInfos = new(); // List itemEntityList = new List(); // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity); // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.MailTaken); // foreach (var mailItem in newMailEntity.Attr.ItemList) // { // if (_selectedChar._inventory.AddItem(mailItem.ItemId, mailItem.Count, newInventoryEntity, out var updateItems, out errorCode, out var itemlogDatas) == false) // { // Log.getLogger().error($"AddItem fail {mailItem.ItemId}"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // itemEntityList.AddRange(updateItems); // foreach (var itemInfoLog in itemlogDatas) // { // invokers.Add(new ItemLog(itemInfoLog)); // } // } // dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update)); // foreach (var item in itemEntityList) // { // dBDocumentInfos.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update)); // } // dBDocumentInfos.Add(new DBDocumentInfo(newMailEntity.DocumentForUpdate(), EDBExecuteType.Update)); // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"DB UpdateInventory Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedMail.UpdateReceivedMailToMemory(message.MailKey, newMailEntity); // _selectedChar._inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate()); // _selectedChar._inventory.UpdateItemDBToMemory(itemEntityList); // foreach (var addedItem in itemEntityList) // { // clientToGame.Response.GetItemsMailRes.Items.Add(addedItem.ConvetToItem()); // } // Send(RmiContext.ReliableSend, clientToGame); // var mailLogData = MailBusinessLogHelper.toMailLogInfo(newMailEntity); // invokers.Add(new MailLog(mailLogData)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // async Task HandleDeleteMailReq(DeleteMailReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.DeleteMailRes = new ClientToGameRes.Types.DeleteMailRes(); // EMailType mailType = (EMailType)message.MailType; // if (_selectedChar is null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.MailDestroy); // ServerErrorCode errorCode = ownedMail.DelMail(message.MailKey, mailType, out var newMailEntity); // if (errorCode != ServerErrorCode.Success || newMailEntity == null) // { // Log.getLogger().error($"HandleDeleteMailReq Failed"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await GameServerApp.Instance.MainDB.DeleteMail(newMailEntity) == false) // { // Log.getLogger().error($"DB DeleteMail Failed. mailKey : {message.MailKey}"); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // } // ownedMail.DeleteMailToMemory(message.MailKey, mailType); // Send(RmiContext.ReliableSend, clientToGame); // var mailLogData = MailBusinessLogHelper.toMailLogInfo(newMailEntity); // invokers.Add(new MailLog(mailLogData)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleGetChannelListReq(GetChannelListReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.GetChannelListRes = new ClientToGameRes.Types.GetChannelListRes(); // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Indun) // { // Log.getLogger().debug($"Indun don't have channel."); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidCondition; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List channelList = GameServer.Instance.GetChannelInfoList(); // clientToGame.Response.GetChannelListRes.ChannelInfoList.AddRange(channelList.ToArray()); // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleMoveChannelReq(MoveChannelReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.MoveChannelRes = new ClientToGameRes.Types.MoveChannelRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} _selectedChar == null {message}"); // return; // } // if (message.Channel == GameServer.Instance.myServerInfo.channel) // { // Log.getLogger().info($"Select Same Channel."); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidArgument; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ServerInfo? serverInfo = await GameServerApp.Instance.ServerCUStorage.GetChannelInfo(GameServer.Instance.WorldServerName, 1, message.Channel); //wordId는 임시 // if (serverInfo == null) // { // Log.getLogger().error($" Failed NotFoundServer WorldServerName : {GameServer.Instance.WorldServerName}, Channel : {message.Channel}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundServer; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if(serverInfo.Sessions >= serverInfo.Capacity) // { // Log.getLogger().error($" Server is Full : {GameServer.Instance.WorldServerName}, Channel : {message.Channel}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerFull; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.StageExit); // StageLogInfo? stage_log_info = null; // _selectedChar.getCurrentStateInfo(this, out stage_log_info); // _selectedChar.LastPositionInfo.m_last_stage_exit_tran_guid = log_action.getTranId(); // _selectedChar.SetLastGameServerPosition(GameServer.Instance.ServerName, GameServer.Instance.myServerInfo.worldId, _selectedChar.CharPos.Pos); // if (!await GameServerApp.Instance.LastPositionStorage.SetLastPositionInfo(AccountGuid, _selectedChar.LastPositionInfo)) // { // Log.getLogger().error($"{Id} Fail Position Save."); // clientToGame.Response.ErrorCode = ServerErrorCode.PositionSaveFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // //채널이동이 월드에서만 있다. // if (await MoveServerSaveInfo(EPlaceType.World) == false) // { // Log.getLogger().error($"MovePlace Failed. World"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundServer; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, serverInfo.Name); // if (otp == String.Empty) // { // Log.getLogger().error("otp is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterFittingRoomFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _StartMoving = true; // clientToGame.Response.MoveChannelRes.GameServerConnectInfo = new ServerConnectInfo // { // ServerAddr = serverInfo.Address, // ServerPort = serverInfo.Port, // Otp = otp, // }; // Send(RmiContext.ReliableSend, clientToGame); // if (stage_log_info != null) // { // invokers.Add(new StageLog(stage_log_info)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // } // async Task HandleMoveWorldReq(MoveWorldReq message) // { // ClientToGame clientToGame = new ClientToGame(); // clientToGame.Response = new ClientToGameRes(); // clientToGame.Response.MoveWorldRes = new ClientToGameRes.Types.MoveWorldRes(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} _selectedChar == null {message}"); // return; // } // if (TableData.Instance._WorldDataTable.TryGetValue(message.WorldId, out var worldData) == false) // { // Log.getLogger().info($"Select Same Channel."); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidArgument; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var gameServerInfo = await GetGameServerInfoToConnect(message.WorldId, _loginInfo.Language); // if (gameServerInfo == null) // { // Log.getLogger().error($"{Id} Need GameServer !!! GameServer is full or not exsit"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistGameServerForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.StageExit); // StageLogInfo? stage_log_info = null; // _selectedChar.getCurrentStateInfo(this, out stage_log_info); // _selectedChar.LastPositionInfo.m_last_stage_exit_tran_guid = log_action.getTranId(); // _selectedChar.SetLastGameServerPosition(GameServer.Instance.ServerName, GameServer.Instance.myServerInfo.worldId, _selectedChar.CharPos.Pos); // if (!await GameServerApp.Instance.LastPositionStorage.SetLastPositionInfo(AccountGuid, _selectedChar.LastPositionInfo)) // { // Log.getLogger().error($"{Id} Fail Position Save."); // clientToGame.Response.ErrorCode = ServerErrorCode.PositionSaveFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await MoveServerSaveInfo(EPlaceType.World) == false) // { // Log.getLogger().error($"MovePlace Failed. World"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistGameServerForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, gameServerInfo.Name); // if (otp == String.Empty) // { // Log.getLogger().error("otp is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.EnterFittingRoomFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _StartMoving = true; // clientToGame.Response.MoveWorldRes.GameServerConnectInfo = new ServerConnectInfo // { // ServerAddr = gameServerInfo.Address, // ServerPort = gameServerInfo.Port, // Otp = otp // }; // Send(RmiContext.ReliableSend, clientToGame); // if (stage_log_info != null) // { // invokers.Add(new StageLog(stage_log_info)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleExchangeMannequinDisplayItemReq(ExchangeMannequinDisplayItemReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ExchangeMannequinDisplayItemRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map == null) // { // Log.getLogger().error($"Not Exist Map", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // // TODO: 추후 land, building, room, mannequin OWNER 확인 처리 // if (_selectedChar.accountId != "ms3master" && _selectedChar.accountId != "ms3qamaster" && _selectedChar.accountId != "lotte50") // { // Log.getLogger().error($"No Permissions", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NoPermissions; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // MapManager.Instance.ExchangeMannequinDisplayItem(message.AnchorGuid, message.DisplayItemidList.ToList()); // Send(RmiContext.ReliableSend, clientToGame); // _selectedChar.map.PropModifyNoti(message.AnchorGuid); // GameServer.Instance._rabbitMQ4Game.SendExchangeMannequinDisplayItemNoti(message.AnchorGuid, message.DisplayItemidList.ToList()); // } // async Task HandleElevatorFloorInfoReq(ElevatorFloorInfoReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ElevatorFloorInfoRes = new(); // if (!MapManager.Instance.GetBuildingMapTree(message.BuildingId, out var buildingMapTree)) // { // Log.getLogger().error($"{Id} Not Found BuildingMapTree. buildingId:{message.BuildingId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundBuildingData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // foreach (var childRoomMap in buildingMapTree.ChildRoomMaps) // { // var floor = childRoomMap.Key; // var roomMapTree = childRoomMap.Value; // if (!TableData.Instance._IndunTable.TryGetValue(roomMapTree.InstanceId, out var indunData)) // continue; // var currentUser = await GameServerApp.Instance.InstanceRoomStorage.GetInstanceRoomUserCount(roomMapTree.InstanceId); // if (currentUser < 0) // continue; // ElevatorFloorInfo elevatorFloorInfo = new(); // elevatorFloorInfo.Floor = floor; // elevatorFloorInfo.InstanceId = roomMapTree.InstanceId; // elevatorFloorInfo.CurrentUser = currentUser; // clientToGame.Response.ElevatorFloorInfoRes.List.Add(elevatorFloorInfo); // } // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleRegisterToolSlotReq(RegisterToolSlotReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.RegisterToolSlotRes = new(); // if (message.SlotIndex < 0 || message.SlotIndex >= ServerCommon.Constant.MAX_TOOL_SLOT) // { // Log.getLogger().error($"{Id} Out Of Range(0~{Constant.MAX_TOOL_SLOT - 1}). ToolSlot:{message.SlotIndex}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ToolSlotOutOfRange; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar._inventory.GetItem(message.ItemGuid, out var item)) // { // Log.getLogger().error($"Not exist Item:{message.ItemGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundItem; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.RegisterToolSlot(message.SlotIndex, message.ItemGuid, out var changedDocument)) // { // Log.getLogger().error($"{Id} Fail RegisterToolSlot. slot:{message.SlotIndex} itemGuid:{message.ItemGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.RegisterToolSlotFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // await GameServerApp.Instance.MainDB.UpdateDocument(changedDocument); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.RegisterToolSlotRes.SlotIndex = message.SlotIndex; // clientToGame.Response.RegisterToolSlotRes.ItemGuid = message.ItemGuid; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleDeregisterToolSlotReq(DeregisterToolSlotReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.DeregisterToolSlotRes = new(); // if (message.SlotIndex < 0 || message.SlotIndex >= ServerCommon.Constant.MAX_TOOL_SLOT) // { // Log.getLogger().error($"{Id} Out Of Range(0~{Constant.MAX_TOOL_SLOT - 1}). ToolSlot:{message.SlotIndex}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ToolSlotOutOfRange; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.DeregisterToolSlot(message.SlotIndex, out var changedDocument)) // { // Log.getLogger().error($"{Id} Fail RegisterToolSlot. slot:{message.SlotIndex}"); // clientToGame.Response.ErrorCode = ServerErrorCode.DeregisterToolSlotFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // await GameServerApp.Instance.MainDB.UpdateDocument(changedDocument); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.DeregisterToolSlotRes.SlotIndex = message.SlotIndex; // clientToGame.Response.DeregisterToolSlotRes.ItemGuid = message.ItemGuid; // Send(RmiContext.ReliableSend, clientToGame); // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleActivateToolItemReq(ActivateToolItemReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ActivateToolItemRes = new(); // ServerErrorCode errorCode = ServerErrorCode.Success; // if (message.SlotIndex < 0 || message.SlotIndex >= ServerCommon.Constant.MAX_TOOL_SLOT) // { // Log.getLogger().error($"{Id} Out Of Range(0~{Constant.MAX_TOOL_SLOT - 1}). ToolSlot:{message.SlotIndex}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ToolSlotOutOfRange; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // int toolItemId = _selectedChar._charEntity.EquipInfo.ToolItemId; // if (toolItemId != 0) // { // if (TableData.Instance._ToolDataTable.TryGetValue(toolItemId, out var oldToolData) == false) // { // Log.getLogger().error($"Not Exisxt ToolItem : {toolItemId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.TableError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if(oldToolData.ActivateBuffID != 0) // { // if (TableData.Instance._BuffTable.TryGetValue(oldToolData.ActivateBuffID, out var BuffData) == false) // { // Log.getLogger().error($"Not Exisxt Buff : {oldToolData.ActivateBuffID}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.TableError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (BuffData.DurationTime == 0) // { // errorCode = StopBuff(oldToolData.ActivateBuffID); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error($"StopBuff Buff Failed ActivateBuffID : {oldToolData.ActivateBuffID}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.StartBuffFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // } // } // _selectedChar.GetToolItem(message.SlotIndex, out toolItemId); // if (TableData.Instance._ToolDataTable.TryGetValue(toolItemId, out var newToolData) == false) // { // Log.getLogger().error($"Not Exisxt ToolItem : {toolItemId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.TableError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if(newToolData.ActivateBuffID != 0) // { // errorCode = StartBuff(newToolData.ActivateBuffID); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error($"StopBuff Buff Failed ActivateBuffID : {newToolData.ActivateBuffID}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.StartBuffFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // if (!_selectedChar.ActivateToolItem(message.SlotIndex, out var activateItem, out errorCode)) // { // Log.getLogger().error($"{Id} ActivateToolItem Fail"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // clientToGame.Response.ActivateToolItemRes.SlotIndex = message.SlotIndex; // Send(RmiContext.ReliableSend, clientToGame); // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.ActivateToolItemNoti = new(); // clientToGameNoti.Message.ActivateToolItemNoti.ActorGuid = AccountGuid; // clientToGameNoti.Message.ActivateToolItemNoti.ToolItemId = activateItem.Attr.ItemId; // _selectedChar.map?.Broadcast(_selectedChar, clientToGameNoti); // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleDeactivateToolItemReq(DeactivateToolItemReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.DeactivateToolItemRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (TableData.Instance._ToolDataTable.TryGetValue(_selectedChar._charEntity.EquipInfo.ToolItemId, out var toolData) == false) // { // Log.getLogger().error($"Not Exisxt ToolItem : {_selectedChar._charEntity.EquipInfo.ToolItemId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.TableError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if(toolData.ActivateBuffID != 0) // { // if (TableData.Instance._BuffTable.TryGetValue(toolData.ActivateBuffID, out var BuffData) == false) // { // Log.getLogger().error($"Not Exisxt Buff : {toolData.ActivateBuffID}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.TableError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (BuffData.DurationTime == 0) // { // var errorCode = StopBuff(toolData.ActivateBuffID); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error($"Stop Buff Failed ActivateBuffID : {toolData.ActivateBuffID}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.StopBuffFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // } // _selectedChar.DeactivateToolItem(); // Send(RmiContext.ReliableSend, clientToGame); // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.DeactivateToolItemNoti = new(); // clientToGameNoti.Message.DeactivateToolItemNoti.ActorGuid = AccountGuid; // _selectedChar?.map?.Broadcast(_selectedChar, clientToGameNoti); // } // async Task HandleUseToolItemReq(UseToolItemReq useToolItemReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.UseToolItemRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (TableData.Instance._ToolDataTable.TryGetValue(_selectedChar._charEntity.EquipInfo.ToolItemId, out var toolData) == false) // { // Log.getLogger().error($"Not Exisxt ToolItem : {_selectedChar._charEntity.EquipInfo.ToolItemId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.TableError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if(toolData.ActionBuffID != 0) // { // var errorCode = StartBuff(toolData.ActionBuffID); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error($"Start Buff Failed ActivateBuffID : {toolData.ActivateBuffID}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.StartBuffFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // _selectedChar._charEntity.EquipInfo.ToolItemStep = useToolItemReq.EquipedToolItemStep; // _selectedChar._charEntity.EquipInfo.ToolItemRandomState = useToolItemReq.EquipedToolItemRandomState; // _selectedChar._charEntity.EquipInfo.ActionStartTime = useToolItemReq.ActionStartTime; // await GameServerApp.Instance.MainDB.SaveChar(_selectedChar._charEntity); // Send(RmiContext.ReliableSend, clientToGame); // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.UseToolItemNoti = new(); // clientToGameNoti.Message.UseToolItemNoti.ActorGuid = AccountGuid; // clientToGameNoti.Message.UseToolItemNoti.ToolItemId = _selectedChar._charEntity.EquipInfo.ToolItemId; // clientToGameNoti.Message.UseToolItemNoti.ToolItemStep = _selectedChar._charEntity.EquipInfo.ToolItemStep; // clientToGameNoti.Message.UseToolItemNoti.ToolItemRandomState = _selectedChar._charEntity.EquipInfo.ToolItemRandomState; // clientToGameNoti.Message.UseToolItemNoti.ActionStartTime = _selectedChar._charEntity.EquipInfo.ActionStartTime; // _selectedChar.map?.Broadcast(_selectedChar, clientToGameNoti); // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleUseEquipedBuffReq(UseEquipedBuffReq useEquipedBuffReq) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.UseEquipedBuffRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._BuffTable.TryGetValue(useEquipedBuffReq.EquopedBuffId, out var buffData)) // { // Log.getLogger().error($"Not Exisxt BuffId : {useEquipedBuffReq.EquopedBuffId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundBuffTableId; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (buffData.BuffCategory != EBuffCategory.TOOL) // { // Log.getLogger().error($"BuffType is not TOOL : {buffData.BuffId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.BuffTypeIsWrong; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar._ownedBuff.getBuff(buffData.BuffCategory, buffData.BuffChannel, out var buff)) // { // Log.getLogger().error($"Not Found Buff : {useEquipedBuffReq.EquopedBuffId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundBuff; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (buff == null || buff.BuffId != useEquipedBuffReq.EquopedBuffId) // { // Log.getLogger().error($"Not Found Buff : {useEquipedBuffReq.EquopedBuffId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundBuff; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (buffData.ActionBuffId != 0) // { // var errorCode = StartBuff(buffData.ActionBuffId); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error($"Start Buff Failed ActionBuffId : {buffData.ActionBuffId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.StartBuffFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // buff.Step = useEquipedBuffReq.EquipedBuffStep; // buff.RandomState = useEquipedBuffReq.EquipedBuffRandomState; // buff.ActionStartTime = useEquipedBuffReq.ActionStartTime; // Send(RmiContext.ReliableSend, clientToGame); // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.UseEquipedBuffNoti = new(); // clientToGameNoti.Message.UseEquipedBuffNoti.ActorGuid = AccountGuid; // clientToGameNoti.Message.UseEquipedBuffNoti.EquipedBuffId = buff.BuffId; // clientToGameNoti.Message.UseEquipedBuffNoti.EquipedBuffStep = buff.Step; // clientToGameNoti.Message.UseEquipedBuffNoti.EquipedBuffRandomState = buff.RandomState; // clientToGameNoti.Message.UseEquipedBuffNoti.ActionStartTime = buff.ActionStartTime; // _selectedChar.map?.Broadcast(_selectedChar, clientToGameNoti); // } // async Task HandleChangeStateReq(ChangeStateReq changeStateReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ChangeStateRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await _selectedChar.ChangeState(changeStateReq.State) == false) // { // clientToGame.Response.ErrorCode = ServerErrorCode.StateChangeFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Send(RmiContext.ReliableSend, clientToGame); // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel) // { // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.ChangeStateNoti = new(); // clientToGameNoti.Message.ChangeStateNoti.ActorGuid = AccountGuid; // clientToGameNoti.Message.ChangeStateNoti.State = changeStateReq.State; // _selectedChar.map?.Broadcast(_selectedChar, clientToGameNoti); // } // } // async Task HandleTaxiReq(TaxiReq taxiReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.TaxiRes = new(); // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Indun) // { // Log.getLogger().error($"Not Correct Server", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotCorrectServer; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._TaxiDataTable.TryGetValue(taxiReq.TaxiId, out var taxiData)) // { // Log.getLogger().error($"Not Found TaxiId : {taxiReq.TaxiId}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundTaxiId; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar == null) // { // Log.getLogger().error($"Not Exist SelectedCharacter", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map == null) // { // Log.getLogger().error($"Not Exist Map.", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!MapManager.Instance.GetWorldMapTree(_selectedChar.map.MapFileName, out var curWorldMapTree)) // { // Log.getLogger().error($"Not Found Map {_selectedChar.map.MapFileName}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.TaxiMove); // var errorCode = _selectedChar.CurrencySubtract(ECurrencyType.GOLD, taxiData.UnloadingCost, ref invokers, out var changeCurrencyDocument); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error("CurrencySubtract is failed."); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // StageLogInfo? stage_log_info = null; // PositionInfo departure_position_info = new(); // PositionInfo arrival_position_info = new(); // _selectedChar.getCurrentStateInfo(this, out stage_log_info); // _selectedChar.LastPositionInfo.m_last_stage_exit_tran_guid = log_action.getTranId(); // departure_position_info.ServerName = GameServer.Instance.ServerName; // departure_position_info.MapFileType = MapHelper.getMapFileType(_selectedChar.map.MapFileName); // departure_position_info.MapMid = _selectedChar.map.MapMId; // departure_position_info.pos = _selectedChar._charEntity.CharPos.Pos.Clone(); // switch (taxiData.Type) // { // case TaxiType.WAYPOINT: // { // if (taxiData.WaypointWorld != curWorldMapTree.WorldId) // { // Log.getLogger().error($"Not Usable Place", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotUsablePlace; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (taxiData.UnloadingWorldId != curWorldMapTree.WorldId) // { // Log.getLogger().error($"Not Usable Place", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotUsablePlace; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Pos newPos = ServerUtil.MakePos(taxiData.UnloadingPositionX, taxiData.UnloadingPositionY, taxiData.UnloadingPositionZ, taxiData.UnloadingRotate); // _selectedChar.Teleport_Taxi(newPos, ref changeCurrencyDocument); // clientToGame.Response.TaxiRes.Pos = newPos; // arrival_position_info.ServerName = GameServer.Instance.ServerName; // arrival_position_info.MapFileType = MapHelper.getMapFileType(_selectedChar.map.MapFileName); // arrival_position_info.MapMid = _selectedChar.map.MapMId; // arrival_position_info.pos = newPos.Clone(); // break; // } // case TaxiType.INSTANCE: // { // if (!TableData.Instance._WorldDataTable.TryGetValue(taxiData.UnloadingWorldId, out var worldData)) // { // Log.getLogger().error($"{Id} Not Found WorldData. worldId:{taxiData.UnloadingWorldId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!MapManager.Instance.GetWorldMapTree(worldData.MapPath, out var worldMapTree)) // { // Log.getLogger().error($"{Id} Not Found WorldMapTree. mapName:{worldData.MapPath}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!worldMapTree.ChildLandMaps.TryGetValue(taxiData.UnloadingLandId, out var landMapTree)) // { // Log.getLogger().error($"{Id} Not Found LandMapTree. landId:{taxiData.UnloadingLandId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundLandData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var buildingMapTree = landMapTree.ChildBuildingMap; // if (buildingMapTree == null) // { // Log.getLogger().error($"{Id} Not Exist Land ChildBuilding"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundBuildingData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!buildingMapTree.ChildRoomMaps.TryGetValue(taxiData.UnloadingFloorId, out var roomMapTree)) // { // Log.getLogger().error($"{Id} Not Found FloorInfo. floodId:{taxiData.UnloadingFloorId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundFloorInfo; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._IndunTable.TryGetValue(roomMapTree.InstanceId, out var indunData)) // { // Log.getLogger().error($"{Id} Not Found IndunData. instanceId:{roomMapTree.InstanceId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundIndunData; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var error = _selectedChar.CheckInstanceAccess(roomMapTree.InstanceId); // if (error.isFail()) // { // Log.getLogger().error($"{Id} CheckInstanceAccess Error({error.ToString()})"); // clientToGame.Response.ErrorCode = error; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string? reJoinRoomId = null; // if (indunData.PlaceType == EPlaceType.Concert) // { // _selectedChar.instanceLastRoomEntity.Attr.LastRoomIds.TryGetValue(roomMapTree.InstanceId, out reJoinRoomId); // } // string roomId = await InstanceRoomHandler.JoinInstance(roomMapTree.InstanceId, Id, reJoinRoomId); // if (roomId == String.Empty) // { // Log.getLogger().error($"{Id} Fail JoinInstance. instanceId:{roomMapTree.InstanceId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.JoinInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // InstanceRoomInfo? instanceRoom = await GameServerApp.Instance.InstanceRoomStorage.GetInstanceRoomInfo(roomId); // if (instanceRoom == null) // { // Log.getLogger().error($"{Id} Not found InstanceRoomInfo. roomId:{roomId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistRoomInfoForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (instanceRoom.InstanceAddress == string.Empty || instanceRoom.InstancePort == 0) // { // Log.getLogger().error($"{Id} InstanceAddress:Empty or InstancePort:0"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistRoomInfoForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Channel) // { // _selectedChar.SetLastGameServerPosition(GameServer.Instance.ServerName, GameServer.Instance.myServerInfo.worldId, _selectedChar.CharPos.Pos); // } // else // { // _selectedChar.AddLastInstancePosition(InstanceId, InstanceRoomId, _selectedChar.CharPos.Pos); // } // var startPos = MapManager.Instance.GetStartPos(indunData.RoomFile); // _selectedChar.SetEnterInstancePosition(roomMapTree.InstanceId, roomId, startPos); // if (!await GameServerApp.Instance.LastPositionStorage.SetLastPositionInfo(AccountGuid, _selectedChar.LastPositionInfo)) // { // Log.getLogger().error($"{Id} Fail Position Save."); // clientToGame.Response.ErrorCode = ServerErrorCode.PositionSaveFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await MoveServerSaveInfo(indunData.PlaceType) == false) // { // Log.getLogger().error($"MovePlace Failed. PlaceType : {indunData.PlaceType}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistRoomInfoForEnter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string serverName = ServerUtil.CreateServerName(ServerType.Indun, instanceRoom.InstanceAddress, instanceRoom.InstancePort); // string otp = await GameServerApp.Instance.LoginStorage.StartMoving(Id, serverName); // if (otp == String.Empty) // { // Log.getLogger().error($"{Id} Fail make otp."); // clientToGame.Response.ErrorCode = ServerErrorCode.MakeFailOtp; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _StartMoving = true; // clientToGame.Response.TaxiRes.InstanceServerConnectInfo = new ServerConnectInfo // { // ServerAddr = instanceRoom.InstanceAddress, // ServerPort = instanceRoom.InstancePort, // Otp = otp, // RoomId = roomId, // }; // arrival_position_info.ServerName = serverName; // arrival_position_info.MapFileType = MapFileType.Instance; // arrival_position_info.MapMid = indunData.Id; // arrival_position_info.pos = startPos.Clone(); // break; // } // default: // { // Log.getLogger().error($"{Id} NotImplemented Taxi Type Case. taxiId:{taxiData.TaxiId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotImplemented; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // await GameServerApp.Instance.MainDB.UpdateDocument(changeCurrencyDocument); // _selectedChar._charEntity.ReadFrom(changeCurrencyDocument); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.TaxiRes.CurrencyInfo = _selectedChar._charEntity.CharInfo; // Send(RmiContext.ReliableSend, clientToGame); // var taxi_log_info = TaxiBusinessLogHelper.toTaxiLogInfo(taxiReq.TaxiId, departure_position_info, arrival_position_info); // invokers.Add(new TaxiLog(taxi_log_info)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // if (stage_log_info != null) // { // BusinessLogger.collectLogs( new LogActionEx(LogActionType.StageExit, log_action.getTranId()) // , _selectedChar // , new List() { new StageLog(stage_log_info) } ); // } // } // void HandleGetCartReq(GetCartReq getCartReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.GetCartRes = new(); // Dictionary> itemCartInfo = ownedCart.GetCart(); // foreach (var itemCartInfoList in itemCartInfo) // { // clientToGame.Response.GetCartRes.ItemList.AddRange(itemCartInfoList.Value); // } // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleAddCartReq(AddCartReq addCartReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.AddCartRes = new(); // var errorCode = ownedCart.AddCart(addCartReq.ItemInfo, out var newCartEntity, out var newCartItemInfo); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error("AddCart Failed."); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await GameServerApp.Instance.MainDB.UpdateDocument(newCartEntity.DocumentForUpdate()) == false) // { // Log.getLogger().error("UpdateCart Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedCart.UpdateDBToMemory(newCartEntity.DocumentForUpdate()); // clientToGame.Response.AddCartRes.ChangeItem = newCartItemInfo; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleDelCartReq(DelCartReq delCartReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.DelCartRes = new(); // ownedCart.DelCart(delCartReq.ItemInfos.ToList(), out var document, out bool isRemoveItem); // if (document == null) // { // Log.getLogger().error("DelCart Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidArgument; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await GameServerApp.Instance.MainDB.UpdateDocument(document) == false) // { // Log.getLogger().error("UpdateCart Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedCart.UpdateDBToMemory(document); // clientToGame.Response.DelCartRes.IsRemoveItem = isRemoveItem ? 1 : 0; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleBuyCartReq(BuyCartReq buyCartReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.BuyCartRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotSelectedChar; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List dBDocumentInfos = new(); // Dictionary currencyInfos = new(); // foreach (var itemInfo in buyCartReq.ItemInfos) // { // if (TableData.Instance._ItemTable.TryGetValue(itemInfo.ItemId, out var itemData) == false) // { // Log.getLogger().error($"Not Found Table. itemID : {itemInfo.ItemId}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundItemTableId; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (currencyInfos.TryGetValue(itemData.BuyType, out var price) == false) // { // currencyInfos.TryAdd(itemData.BuyType, itemData.BuyPrice * itemInfo.Count); // } // else // { // currencyInfos[itemData.BuyType] += itemData.BuyPrice * itemInfo.Count; // } // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.CartPurchase); // var errorCode = _selectedChar.CurrenciesSubtract(currencyInfos, ref invokers, out var currencyDocument); // if (errorCode != ServerErrorCode.Success) // { // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // dBDocumentInfos.Add(new DBDocumentInfo(currencyDocument, EDBExecuteType.Update)); // ownedCart.BuyCart(buyCartReq.ItemInfos.ToList(), out var cartDocument); // if (cartDocument == null) // { // Log.getLogger().error("BuyCart Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidArgument; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // dBDocumentInfos.Add(new DBDocumentInfo(cartDocument, EDBExecuteType.Update)); // List itemEntityList = new List(); // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity); // foreach (var itemInfo in buyCartReq.ItemInfos) // { // if (itemInfo.ItemGuid != "") // { // //todo 상점 기획 나오면 추가함 // Log.getLogger().error($"NotImplemented."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotImplemented; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar._inventory.AddItem(itemInfo.ItemId, itemInfo.Count, newInventoryEntity, out var Items, out var errCode, out var itemlogDatas) == false) // { // Log.getLogger().error($"{_selectedChar.accountId} AddItem Fail"); // clientToGame.Response.ErrorCode = errCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // itemEntityList.AddRange(Items); // foreach (var itemInfoLog in itemlogDatas) // { // invokers.Add(new ItemLog(itemInfoLog)); // } // } // dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update)); // foreach (var item in itemEntityList) // { // dBDocumentInfos.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update)); // } // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"DB UpdateInventory Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedCart.UpdateDBToMemory(cartDocument); // _selectedChar._charEntity.ReadFrom(currencyDocument); // _selectedChar._inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate()); // _selectedChar._inventory.UpdateItemDBToMemory(itemEntityList); // List itemids = new(); // foreach (var addedItem in itemEntityList) // { // clientToGame.Response.BuyCartRes.Items.Add(addedItem.ConvetToItem()); // itemids.Add(addedItem.Attr.ItemId); // } // clientToGame.Response.BuyCartRes.CurrencyInfo = _selectedChar._charEntity.CharInfo; // Send(RmiContext.ReliableSend, clientToGame); // foreach (var addedItem in itemEntityList) // { // } // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // async Task HandleRegisterTattooReq(RegisterTattooReq registerTattooReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.RegisterTattooRes = new(); // if (registerTattooReq.SlotIndex < 0 || registerTattooReq.SlotIndex >= ServerCommon.Constant.MAX_TATTOO_SLOT) // { // Log.getLogger().error($"{Id} Out Of Range(0~{Constant.MAX_TOOL_SLOT - 1}). ToolSlot:{registerTattooReq.SlotIndex}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ToolSlotOutOfRange; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.RegisterTattooSlot(registerTattooReq.SlotIndex, registerTattooReq.ItemGuid, out var changedDocument) == false) // { // Log.getLogger().error($"{Id} Fail RegisterToolSlot. slot:{registerTattooReq.SlotIndex} itemGuid:{registerTattooReq.ItemGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.RegisterToolSlotFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await GameServerApp.Instance.MainDB.UpdateDocument(changedDocument) == false) // { // Log.getLogger().error("HandleRegisterTattooReq Document update Fail", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // } // _selectedChar.UpdateTattooAttribute(registerTattooReq.SlotIndex, registerTattooReq.ItemGuid); // _selectedChar.UpdateTattooSlotDBToMemory(changedDocument); // clientToGame.Response.RegisterTattooRes.ItemGuid = registerTattooReq.ItemGuid; // clientToGame.Response.RegisterTattooRes.SlotIndex = registerTattooReq.SlotIndex; // Send(RmiContext.ReliableSend, clientToGame); // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.ChangeTattooNoti = new(); // clientToGameNoti.Message.ChangeTattooNoti.AccountGuid = AccountGuid; // clientToGameNoti.Message.ChangeTattooNoti.TattooInfoList.AddRange(_selectedChar.MakeTattooInfoForPacket()); // _selectedChar.map?.Broadcast(_selectedChar, clientToGameNoti); // if (_selectedChar._inventory.GetItem(registerTattooReq.ItemGuid, out var item) == true) // { // } // } // async Task HandleDeregisterTattooReq(DeregisterTattooReq deregisterTattooReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.DeregisterTattooRes = new(); // if (deregisterTattooReq.SlotIndex < 0 || deregisterTattooReq.SlotIndex >= ServerCommon.Constant.MAX_TATTOO_SLOT) // { // Log.getLogger().error($"{Id} Out Of Range(0~{Constant.MAX_TATTOO_SLOT - 1}). TATTOOSlot:{deregisterTattooReq.SlotIndex}"); // clientToGame.Response.ErrorCode = ServerErrorCode.ToolSlotOutOfRange; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.DeregisterTattooSlot(deregisterTattooReq.SlotIndex, out var changedDocument)) // { // Log.getLogger().error($"{Id} Fail RegisterToolSlot. slot:{deregisterTattooReq.SlotIndex}"); // clientToGame.Response.ErrorCode = ServerErrorCode.DeregisterToolSlotFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await GameServerApp.Instance.MainDB.UpdateDocument(changedDocument) == false) // { // Log.getLogger().error("HandleDeregisterTattooReq Document update Fail", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar.UpdateTattooAttribute(deregisterTattooReq.SlotIndex, string.Empty); // _selectedChar.UpdateTattooSlotDBToMemory(changedDocument); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.DeregisterTattooRes.SlotIndex = deregisterTattooReq.SlotIndex; // Send(RmiContext.ReliableSend, clientToGame); // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.ChangeTattooNoti = new(); // clientToGameNoti.Message.ChangeTattooNoti.AccountGuid = AccountGuid; // clientToGameNoti.Message.ChangeTattooNoti.TattooInfoList.AddRange(_selectedChar.MakeTattooInfoForPacket()); // _selectedChar.map?.Broadcast(_selectedChar, clientToGameNoti); // } // async Task HandleLevelUpTattooReq(LevelUpTattooReq levelUpTattooReq) // { // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // return; // } // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.ItemTattooLevelUp); // var itemlogDatas = await LevelUpTattoo(levelUpTattooReq.ItemGuid); // if(itemlogDatas == null) // { // return; // } // foreach (var itemInfoLog in itemlogDatas) // { // invokers.Add(new ItemLog(itemInfoLog)); // } // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // public async Task?> LevelUpTattoo(string ItemGuid) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.LevelUpTattooRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return null; // } // if (!_selectedChar._inventory.GetItem(ItemGuid, out var itemEntity)) // { // Log.getLogger().error($"Not exist Item:{ItemGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundItem; // Send(RmiContext.ReliableSend, clientToGame); // return null; // } // bool isRegisterTattoo = false; // isRegisterTattoo = _selectedChar.isRegisterTattoo(ItemGuid); // List? changeAttributeList = null; // List dBDocumentInfos = new(); // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity); // if (_selectedChar._inventory.LevelUpItem(ItemGuid, newInventoryEntity, isRegisterTattoo, // out var updateItems, out var errorCode, out bool isEnchantSuccess, out changeAttributeList, out var itemlogDatas) == false) // { // Log.getLogger().error($"Failed LevelUp Item ItemGuid : {ItemGuid}"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return null; // } // dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update)); // foreach (var item in updateItems) // { // dBDocumentInfos.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update)); // } // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"DB UpdateInventory Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return null; // } // _selectedChar._inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate()); // _selectedChar._inventory.UpdateItemDBToMemory(updateItems); // if (isEnchantSuccess == true && changeAttributeList != null) // { // _selectedChar.ApplyAttribute(changeAttributeList); // } // clientToGame.Response.ErrorCode = errorCode; // clientToGame.Response.LevelUpTattooRes.IsSuccess = isEnchantSuccess == true ? 1 : 0; // clientToGame.Response.LevelUpTattooRes.ItemInfos.AddRange(updateItems.ConvertAll(o => o.ConvetToItem())); // Send(RmiContext.ReliableSend, clientToGame); // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.ChangeTattooNoti = new(); // clientToGameNoti.Message.ChangeTattooNoti.AccountGuid = AccountGuid; // clientToGameNoti.Message.ChangeTattooNoti.TattooInfoList.AddRange(_selectedChar.MakeTattooInfoForPacket()); // _selectedChar.map?.Broadcast(_selectedChar, clientToGameNoti); // return itemlogDatas; // } // async Task HandleChangeAttributeTattooReq(ChangeAttributeTattooReq changeAttributeTattooReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.ChangeAttributeTattooRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectChar is null", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotSelectedChar; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // bool isRegisterTattoo = false; // isRegisterTattoo = _selectedChar.isRegisterTattoo(changeAttributeTattooReq.ItemGuid); // List? changeAttributeList = null; // List dBDocumentInfos = new(); // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity); // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.ItemTattooChangeAttribute); // if (_selectedChar._inventory.ChangeAttribute( // changeAttributeTattooReq.ItemGuid, // changeAttributeTattooReq.SlotIndex, // newInventoryEntity, // isRegisterTattoo, // out var updateItems, // out var errorCode, // out changeAttributeList, // out var itemlogDatas) == false) // { // Log.getLogger().error($"Failed Change Attribute Item ItemGuid : {changeAttributeTattooReq.ItemGuid}"); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update)); // foreach (var item in updateItems) // { // dBDocumentInfos.Add(new DBDocumentInfo(item.DocumentForUpdate(), EDBExecuteType.Update)); // } // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"DB UpdateInventory Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar._inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate()); // _selectedChar._inventory.UpdateItemDBToMemory(updateItems); // if (changeAttributeList != null) // { // _selectedChar.ApplyAttribute(changeAttributeList); // } // clientToGame.Response.ErrorCode = errorCode; // clientToGame.Response.ChangeAttributeTattooRes.ItemInfos.AddRange(updateItems.ConvertAll(o => o.ConvetToItem())); // Send(RmiContext.ReliableSend, clientToGame); // ClientToGame clientToGameNoti = new(); // clientToGameNoti.Message = new(); // clientToGameNoti.Message.ChangeTattooNoti = new(); // clientToGameNoti.Message.ChangeTattooNoti.AccountGuid = AccountGuid; // clientToGameNoti.Message.ChangeTattooNoti.TattooInfoList.AddRange(_selectedChar.MakeTattooInfoForPacket()); // _selectedChar.map?.Broadcast(_selectedChar, clientToGameNoti); // if (_selectedChar._inventory.GetItem(changeAttributeTattooReq.ItemGuid, out var itemEntity)) // { // } // foreach (var itemInfoLog in itemlogDatas) // { // invokers.Add(new ItemLog(itemInfoLog)); // } // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // async Task HandleSaveVisibleTattooSlotReq(SaveVisibleTattooSlotReq saveVisibleTattooSlotReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.SaveVisibleTattooSlotRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectChar is null", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotSelectedChar; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var errorCode = await _selectedChar.saveVisibleTattooSlot(saveVisibleTattooSlotReq.SlotIndex, saveVisibleTattooSlotReq.IsVisible == 1 ? true : false); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error("saveVisibleTattooSlot is null", ToString()); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // clientToGame.Response.SaveVisibleTattooSlotRes.IsVisible = saveVisibleTattooSlotReq.IsVisible; // clientToGame.Response.SaveVisibleTattooSlotRes.SlotIndex = saveVisibleTattooSlotReq.SlotIndex; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleBlockUserReq(BlockUserReq blockUserReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.BlockUserRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectChar is null", ToString()); // return; // } // string targetNickName = blockUserReq.TargetNickName; // clientToGame.Response.BlockUserRes.NickName = targetNickName; // string myGuid = _selectedChar.Guid; // NickNameEntity? nickNameEntity = await GameServerApp.Instance.MainDB.GetEntityFromNickName(targetNickName); // if (nickNameEntity is null) // { // Log.getLogger().error($"BlockUser NotExistCharacter, targetNickName : {targetNickName}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // string targetGuid = nickNameEntity.Attr.AccountGuid; // var blockList = _selectedChar.ownedBlockList.GetBlockList(); // int userMaxCount = MetaHelper.GameConfigMeta.MaxBlockUserNum; // if (blockList.Count >= userMaxCount) // { // Log.getLogger().warn($"BlockUser MaxCount, targetNickName : {targetNickName}, Count : {blockList.Count}, userMaxCount : {userMaxCount}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.BlockUserMaxCount; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // //이미 차단한 유저 // if (_selectedChar.ownedBlockList.CheckBlockUser(targetGuid)) // { // Log.getLogger().info($"{myGuid} waw blocked {targetGuid}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.BlockUserAlreadyBlock; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.ownedBlockList.BlockUser(myGuid, targetGuid, targetNickName, out var document)) // { // Log.getLogger().error($"BlockUser return false targetNickName : {targetNickName}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.DbError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (document is not null) // { // List documents = new List() { document }; // if (!await GameServerApp.Instance.MainDB.UpdateDocuments(documents)) // { // Log.getLogger().error("Add BlockList Fail", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.DbError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // //차단한 유저가 친구일경우 삭제 처리 // if (ownedFriendList.CheckExistFriend(targetGuid)) // { // clientToGame.Response.ErrorCode = errorCode; // } // //차단한 유저가 초대 보낸 유저이거나, 초대받은 유저 인경우 삭제 처리 // if (ownedFriendList.CheckExistReceivedRequest(targetGuid)) // { // ServerErrorCode errorCode = await ownedFriendList.deleteReceivedRequest(myGuid, targetGuid); // clientToGame.Response.ErrorCode = errorCode; // } // else if (ownedFriendList.CheckExistSendedRequest(targetGuid)) // { // ServerErrorCode errorCode = await ownedFriendList.deleteSendedRequest(myGuid, targetGuid); // clientToGame.Response.ErrorCode = errorCode; // } // Send(RmiContext.ReliableSend, clientToGame); // } // void HandleGetBlockListReq() // { // if (_selectedChar == null) // { // Log.getLogger().error("_selectChar is null", ToString()); // return; // } // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.GetBlockListRes = new(); // List list = _selectedChar.ownedBlockList.GetBlockList(); // clientToGame.Response.GetBlockListRes.BlockList.AddRange(list); // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleCancelBlockReq(CancelBlockReq cancelBlockReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.CancelBlockRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectChar is null", ToString()); // return; // } // string guid = cancelBlockReq.Guid; // string myGuid = _selectedChar.Guid; // var blockInfo = _selectedChar.ownedBlockList.GetBlockInfo(guid); // if (blockInfo is null) // { // clientToGame.Response.ErrorCode = ServerErrorCode.BlockInfoEmpty; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // clientToGame.Response.CancelBlockRes.NickName = blockInfo.NickName; // if (!_selectedChar.ownedBlockList.CancelBlock(myGuid, guid, out var document)) // { // Log.getLogger().error($"Document is null or At targetGuid : {guid}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.DbError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (document is not null) // { // List documents = new List() { document }; // if (!await GameServerApp.Instance.MainDB.DeleteDocuments(documents)) // { // Log.getLogger().error("Document Delete Fail", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.DbError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // Send(RmiContext.ReliableSend, clientToGame); // } // public async Task HandleUserReportReq(UserReportReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.UserReportRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"{Id} _selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var errorCode = await _selectedChar.UserReport(message.TargetNickName, message.Reason, message.Title, message.Detail); // if (errorCode != ServerErrorCode.Success) // { // Log.getLogger().error("UserReport Failed."); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Send(RmiContext.ReliableSend, clientToGame); // } // public async Task HandleRegisterMinimapMarkerReq(RegisterMinimapMarkerReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.RegisterMinimapMarkerRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"{Id} _selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Indun) // { // Log.getLogger().error($"{Id} Not Usable Place"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotUsablePlace; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._WorldDataTable.ContainsKey(message.MarkerPos.MapId)) // { // Log.getLogger().error($"{Id} mapId:{message.MarkerPos.MapId} is not worldmap"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.RegisterMinimapMarker(message.MarkerPos, out var changedDocument, out var oldDocument)) // { // Log.getLogger().error($"{Id} RegisterMinimapMarker fail"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!await GameServerApp.Instance.MainDB.UpdateDocument(changedDocument)) // { // _selectedChar.RollBackMinimapMarker(oldDocument); // Log.getLogger().error($"{Id} UpdateDocument fail"); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Send(RmiContext.ReliableSend, clientToGame); // } // public async Task HandleDeregisterMinimapMarkerReq(DeregisterMinimapMarkerReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.DeregisterMinimapMarkerRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"{Id} _selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (GameServerApp.Instance.Config.GameServerType == EGameServerType.Indun) // { // Log.getLogger().error($"{Id} Not Usable Place"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotUsablePlace; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!TableData.Instance._WorldDataTable.ContainsKey(message.MapId)) // { // Log.getLogger().error($"{Id} mapId:{message.MapId} is not worldmap"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.DeregisterMinimapMarker(message.MapId, out var changedDocument, out var oldDocument)) // { // Log.getLogger().error($"{Id} DeregisterMinimapMarker fail"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!await GameServerApp.Instance.MainDB.UpdateDocument(changedDocument)) // { // _selectedChar.RollBackMinimapMarker(oldDocument); // Log.getLogger().error($"{Id} UpdateDocument fail"); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Send(RmiContext.ReliableSend, clientToGame); // } // private async Task MoveServerSaveInfo(EPlaceType placeType) // { // if (_selectedChar == null) // { // Log.getLogger().error($"{Id} _selectedChar is null"); // return false; // } // if (await GameServerApp.Instance.moveServerPlayerInfoStorage.SavePlayerInfo(Id, ownedMail.MakeMovePlayerInfo()) == false) // { // return false; // } // if (await _selectedChar._ownedBuff.MovePlace(placeType) == false) // { // Log.getLogger().error($"MovePlace Failed. placeType : {placeType}"); // return false; // } // return true; // } // private async Task MoveServerSaveInfo(ClientSession session, EPlaceType placeType) // { // if (session._selectedChar == null) // { // Log.getLogger().error($"{session.Id} _selectedChar is null"); // return false; // } // if (await GameServerApp.Instance.moveServerPlayerInfoStorage.SavePlayerInfo(session.Id, session.ownedMail.MakeMovePlayerInfo()) == false) // { // return false; // } // if (await session._selectedChar._ownedBuff.MovePlace(placeType) == false) // { // Log.getLogger().error($"MovePlace Failed. placeType : {placeType}"); // return false; // } // return true; // } // async Task HandleSaveCharProfileReq(SaveCharProfileReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.SaveCharProfileRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (await _selectedChar.SaveCharProfile(message.SNSLink, message.Message) == false) // { // Log.getLogger().error("SaveCharProfile is failed"); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleGetCharProfileReq(GetCharProfileReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.GetCharProfileRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // NickNameEntity? nickNameEntity = await GameServerApp.Instance.MainDB.GetEntityFromNickName(message.NickName); // if (nickNameEntity is null) // { // Log.getLogger().error($"InvalidTarget. ToNickNameINfo is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidTarget; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var targetSession = ClientSessionManager.Instance.GetSessionByName(nickNameEntity.Attr.AccountId); // if (targetSession != null && targetSession._selectedChar != null) // { // var charProfileEntity = targetSession._selectedChar.GetCharProfileEntity(); // clientToGame.Response.GetCharProfileRes.PublicGuid = EncryptHelper.EncryptTextToMemory(nickNameEntity.Attr.AccountGuid); // clientToGame.Response.GetCharProfileRes.NickName = message.NickName; // clientToGame.Response.GetCharProfileRes.Language = targetSession._selectedChar._charEntity.CharInfo.LanguageInfo; // clientToGame.Response.GetCharProfileRes.SNSLink = charProfileEntity.Attr.SNSLick; // clientToGame.Response.GetCharProfileRes.Message = charProfileEntity.Attr.Message; // var attributeList = targetSession._selectedChar.getAttributeList(); // clientToGame.Response.GetCharProfileRes.Attributeinfo.AddRange(attributeList); // } // else // { // CharEntity? charEntity = await GameServerApp.Instance.MainDB.GetChar(nickNameEntity.Attr.AccountGuid); // if (charEntity is null) // { // Log.getLogger().error($"InvalidTarget. charEntity is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidTarget; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // CharProfileEntity? profileEntity = await GameServerApp.Instance.MainDB.GetCharProfile(nickNameEntity.Attr.AccountGuid); // if(profileEntity is null) // { // Log.getLogger().error($"InvalidTarget. CharProfileEntity is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidTarget; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // clientToGame.Response.GetCharProfileRes.PublicGuid = EncryptHelper.EncryptTextToMemory(nickNameEntity.Attr.AccountGuid); // clientToGame.Response.GetCharProfileRes.NickName = message.NickName; // clientToGame.Response.GetCharProfileRes.Language = charEntity.CharInfo.LanguageInfo; // clientToGame.Response.GetCharProfileRes.SNSLink = profileEntity.Attr.SNSLick; // clientToGame.Response.GetCharProfileRes.Message = profileEntity.Attr.Message; // } // Send(RmiContext.ReliableSend, clientToGame); // return; // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleSaveLanguageReq(SaveLanguageReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.SaveLanguageRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar._charEntity.CharInfo.LanguageInfo = message.Language; // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleSaveChatTapReq(SaveChatTapReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.SaveChatTapRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // CharMetaDataEntity MetaDataEntity = new CharMetaDataEntity(ownedCharMetaDataEntity.DocumentForUpdate()); // MetaDataEntity.Attr.chatTapInfoList.AddRange(message.TapInfoList); // if(await GameServerApp.Instance.MainDB.UpdateCharMetaData(MetaDataEntity) == false) // { // Log.getLogger().error("DB ownedCharMetaDataEntity UpdateCharMetaData Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // ownedCharMetaDataEntity.ReadFrom(MetaDataEntity.DocumentForUpdate()); // Send(RmiContext.ReliableSend, clientToGame); // } //#pragma warning disable CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // async Task HandleGetChatTapReq(GetChatTapReq message) //#pragma warning restore CS1998 // 이 비동기 메서드에는 'await' 연산자가 없으며 메서드가 동시에 실행됩니다. // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.GetChatTapRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.ServerLogicError; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // clientToGame.Response.GetChatTapRes.TapInfoList.AddRange(ownedCharMetaDataEntity.Attr.chatTapInfoList); // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleUseRewardPropReq(UseRewardPropReq message) // { // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.UseRewardPropRes = new(); // if (_selectedChar is null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar.map is null) // { // Log.getLogger().error($"{Id} Not Exist Map."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!MapDataTable.Instance.getMapData(_selectedChar.map.MapFileName, out var mapData)) // { // Log.getLogger().error($"{Id} Not Exist Map."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // var anchors = mapData.Anchors.Where(x => x.GUID == message.AnchorGuid).ToList(); // if (anchors.Count != 1) // { // Log.getLogger().error($"{Id} Not Exist Anchor."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundAnchorGuid; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!MapHelper.isRewardProp(anchors[0].GUID) && !MapHelper.isGroupProp(anchors[0].GUID)) // { // Log.getLogger().error($"{Id} Not Exist Anchor."); // clientToGame.Response.ErrorCode = ServerErrorCode.PropTypeisWrong; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!_selectedChar.map.Anchors.TryGetValue(message.AnchorGuid, out var anchorInfo)) // { // Log.getLogger().error($"{Id} Not Found AnchorData. anchorGuid:{message.AnchorGuid}"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundAnchorGuid; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (anchorInfo.PropState != PropState.Activation) // { // Log.getLogger().error($"{Id} Prop is not usable"); // clientToGame.Response.ErrorCode = ServerErrorCode.PropIsUsed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // // 리워드 지급 // if (!TableData.Instance._RewardPropDataTable.TryGetValue(anchorInfo.AnchorProp.TableId, out var rewardPropData)) // { // Log.getLogger().error($"{Id} RewardPropData Not Found"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundTable; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (rewardPropData.UseRequired != 0) // { // if (!TableData.Instance._RequireUseAnchor.TryGetValue(rewardPropData.UseRequired, out var requireData)) // { // Log.getLogger().error($"{Id} RequireUseAnchorData Not Found"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundTable; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // foreach (var requireAttribute in requireData.RequireAttributes) // { // var attribute_value = _selectedChar.getAttribute((int)requireAttribute.AttributeType); // if (attribute_value < requireAttribute.RequireValue) // { // Log.getLogger().error($"{Id} Not Require Attribute Value"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotRequireAttributeValue; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // } // } // if (!TableData.Instance._RewardDataTable.TryGetValue(rewardPropData.UsedReward, out var rewardDatas)) // { // Log.getLogger().error($"_RewardDataTable not exist info rewardGroupId = {rewardPropData.UsedReward}", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.RewardInfoNotExist; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // IReward reward_proc = new RewardUseProp(_selectedChar, clientToGame, message.AnchorGuid, rewardDatas); // if (error_code != ServerErrorCode.Success) // { // clientToGame.Response.ErrorCode = error_code; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // // 프랍 사용 처리 // if (MapHelper.isRewardProp(anchorInfo.AnchorGuid)) // { // anchorInfo.PropState = PropState.Respawning; // anchorInfo.respawnTime = Timestamp.FromDateTime(DateTime.UtcNow.AddSeconds(rewardPropData.Respawntime)); // } // if (MapHelper.isGroupProp(anchorInfo.AnchorGuid)) // { // anchorInfo.PropState = PropState.Deactivated; // } // //로그처리 // var invokers = new List(); // var log_action = new LogActionEx(LogActionType.RewardProp); // UseRewardPropInfo info = new UseRewardPropInfo(message.AnchorGuid, anchorInfo.AnchorProp.TableId, rewardPropData.UsedReward, rewardDatas); // invokers.Add(new UseRewardPropBusinessLog(info)); // invokers.AddRange(reward_proc.getItemLogInvokers()); // invokers.AddRange(reward_proc.getCurrencyLogInvokers()); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // { // ClientToGame clientToGame = new(); // clientToGame.Message = new(); // clientToGame.Message.RewardPropStateNoti = new(); // clientToGame.Message.RewardPropStateNoti.AnchorGuid = message.AnchorGuid; // clientToGame.Message.RewardPropStateNoti.IsUsable = 0; // _selectedChar.map.Broadcast(_selectedChar, clientToGame); // } // return; // } // private async Task HandleUseMegaPhoneItemReq(UseMegaPhoneItemReq useMegaPhoneItemReq) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.UseMegaPhoneItemRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error($"{Id} Not Exist SelectedCharacter"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistSelectedCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (_selectedChar._inventory.GetItem(useMegaPhoneItemReq.ItemGuid, out var item) == false) // { // Log.getLogger().error($"{Id} Not Enough MegaPhone Item."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotEnoughItem; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if(TableData.Instance._ItemTable.TryGetValue(item.Attr.ItemId, out var itemData) == false) // { // Log.getLogger().error($"{Id} Table Error."); // clientToGame.Response.ErrorCode = ServerErrorCode.NotFoundTable; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if(itemData.TypeLarge != EItemLargeType.EXPENDABLE || itemData.TypeSmall != EItemSmallType.MEGAPHONE) // { // Log.getLogger().error($"{Id} Invalid Item."); // clientToGame.Response.ErrorCode = ServerErrorCode.InvalidItem; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // List dBDocumentInfos = new(); // _selectedChar._inventory.CopyInventoryEntityForTransaction(out var newInventoryEntity); // List invokers = new List(); // var log_action = new LogActionEx(LogActionType.ItemUse); // if (!_selectedChar._inventory.DeleteItem(item.Attr.ItemGuid, 1, newInventoryEntity, out var deletedItem, out var errorCode, out var itemlogData)) // { // Log.getLogger().error($"{Id} DeleteItem Fail."); // clientToGame.Response.ErrorCode = errorCode; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // dBDocumentInfos.Add(new DBDocumentInfo(newInventoryEntity.DocumentForUpdate(), EDBExecuteType.Update)); // dBDocumentInfos.Add(new DBDocumentInfo(deletedItem.DocumentForUpdate(), EDBExecuteType.Update)); // if (await GameServerApp.Instance.MainDB.Transaction(dBDocumentInfos, 2) == false) // { // Log.getLogger().error($"{Id} DB UpdateInventory Failed."); // clientToGame.Response.ErrorCode = ServerErrorCode.DbUpdateFailed; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar._inventory.UpdateInventoryDBToMemory(newInventoryEntity.DocumentForUpdate()); // _selectedChar._inventory.UpdateItemDBToMemory(new List() { deletedItem }); // ClientToGame clientMsg = new(); // clientMsg.Message = new ClientToGameMessage(); // clientMsg.Message.Chat = new(); // clientMsg.Message.Chat.Message = useMegaPhoneItemReq.Message; // clientMsg.Message.Chat.Sender = getUserNickname(); // clientMsg.Message.Chat.Type = (int)ChatType.CHANNEL; // ClientSessionManager.Instance.Broadcast(_selectedChar, clientMsg); // clientToGame.Response.UseMegaPhoneItemRes.ItemGuid = deletedItem.Attr.ItemGuid; // clientToGame.Response.UseMegaPhoneItemRes.Count = deletedItem.Attr.Count; // Send(RmiContext.ReliableSend, clientToGame); // invokers.Add(new ItemLog(itemlogData)); // invokers.Add(new ItemUseLog(deletedItem.Attr.ItemGuid, itemData.TypeSmall.ToString(), 0)); // BusinessLogger.collectLogs(log_action, _selectedChar, invokers); // } // async Task HandleIntroCompleteReq(IntroCompleteReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.IntroCompleteRes = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.JoinInstanceFail; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // _selectedChar._charEntity.CharInfo.IsIntroComplete = 1; // await SaveDB(); // Send(RmiContext.ReliableSend, clientToGame); // } // async Task HandleGameGuardAuthReq(GameGuardAuthReq message) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.GameGuardAuthRes = new(); // if(GameServerApp.Instance.Config.GameGuard == true) // { // byte[] byteOptions = Array.ConvertAll(message.AuthValue.ToArray(), Convert.ToByte); // if (GameGuardHelper.AuthCheck(GameGuardInstance, byteOptions, message.AuthValueSize) == false) // { // Log.getLogger().error("GameGuard AuthCheck is Failed"); // clientToGame.Response.ErrorCode = ServerErrorCode.GameGuardAuthFailed; // Send(RmiContext.ReliableSend, clientToGame); // await Close(); // return; // } // } // Send(RmiContext.ReliableSend, clientToGame); // } // public async Task handleEscapePosition(C2GS_REQ_ESCAPE_POSITION req) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.AckEscapePosition = new(); // clientToGame.Response.AckEscapePosition.RemainTime = 0; // clientToGame.Response.AckEscapePosition.MovePosition = new(); // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // EscapePositionAttr origin_attr = _selectedChar.m_escape_position_time_info.m_escape_postion_entity.Attr; // Timestamp origin_available_time = origin_attr.m_escape_available_time; // DateTime nowDT = DateTime.UtcNow; // Timestamp nowTS = nowDT.ToTimestamp(); // if (nowTS < origin_available_time) // { // Log.getLogger().debug($"handleEscapePosition time remain availableTime : {origin_available_time.Seconds}, now : {nowTS.Seconds}", ToString()); // long remainTime = ((origin_available_time.Seconds - nowTS.Seconds) / 60) + 1; // clientToGame.Response.AckEscapePosition.RemainTime = remainTime; // clientToGame.Response.ErrorCode = ServerErrorCode.EscapePositionNotAvailableTime; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // //이동할 Pos 가져올것 // if (GameServer.Instance.Map is null) // { // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // if (!GameServer.Instance.Map.GetNearestStartPoint(_selectedChar._charEntity.CharPos.Pos, out var startPointPos)) // { // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistMap; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Timestamp next_available_time = nowDT.AddMinutes(MetaHelper.GameConfigMeta.EscapeCoolTime).ToTimestamp(); // origin_attr.m_escape_available_time = next_available_time; // if (!await GameServerApp.Instance.MainDB.SaveEscapePositionTime(_selectedChar.m_escape_position_time_info.m_escape_postion_entity)) // { // Log.getLogger().error("SaveEscapePositionTime return false", ToString()); // clientToGame.Response.ErrorCode = ServerErrorCode.DynamoDbQueryException; // Send(RmiContext.ReliableSend, clientToGame); // origin_attr.m_escape_available_time = origin_available_time; // return; // } // clientToGame.Response.AckEscapePosition.MovePosition = startPointPos; // Send(RmiContext.ReliableSend, clientToGame); // } // public async Task handleNPCDialogue(C2GS_REQ_NPC_DIALOGUE req) // { // ClientToGame clientToGame = new(); // clientToGame.Response = new(); // clientToGame.Response.ErrorCode = ServerErrorCode.Success; // clientToGame.Response.AckNPCDialogue = new(); // clientToGame.Response.AckNPCDialogue.NpcId = req.NpcId; // clientToGame.Response.AckNPCDialogue.Dialogue = req.Dialogue; // clientToGame.Response.AckNPCDialogue.DialogueResult = req.DialogueResult; // if (_selectedChar == null) // { // Log.getLogger().error("_selectedChar is null"); // clientToGame.Response.ErrorCode = ServerErrorCode.NotExistCharacter; // Send(RmiContext.ReliableSend, clientToGame); // return; // } // Send(RmiContext.ReliableSend, clientToGame); // //퀘스트 관련 처리 // } // } //}