static private SendNodeMessage ( int handle, |
||
handle | int | |
msg | ||
리턴 | void |
internal void GMLoadUser(string gmAccount, ulong userGuid, LobbyGmMessageDefine jsonMsgId, int nodeHandle) { string key = userGuid.ToString(); Msg_LD_Load msg = new Msg_LD_Load(); msg.MsgId = (int)DataEnum.TableUserInfo; msg.PrimaryKeys.Add(key); Msg_LD_SingleLoadRequest reqUser = new Msg_LD_SingleLoadRequest(); reqUser.MsgId = (int)DataEnum.TableUserInfo; reqUser.LoadType = Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadSingle; reqUser.Keys.Add(key); msg.LoadRequests.Add(reqUser); RequestLoad(msg, (ret) => { JsonMessage resultMsg = new JsonMessage(jsonMsgId, gmAccount); GameFrameworkMessage.Msg_LC_GmQueryUser protoData = new GameFrameworkMessage.Msg_LC_GmQueryUser(); protoData.m_Result = GameFrameworkMessage.GmResultEnum.Failed; protoData.m_Info = null; KeyString primaryKey = KeyString.Wrap(ret.PrimaryKeys); if (Msg_DL_LoadResult.ErrorNoEnum.Success == ret.ErrorNo) { LogSys.Log(LOG_TYPE.INFO, "DataCache Load Success: Msg:{0}, Key:{1}", "GmUser", primaryKey); TableUserInfo dataUser = null; foreach (var result in ret.Results) { object _msg; if (DbDataSerializer.Decode(result.Data, DataEnum2Type.Query(result.MsgId), out _msg)) { DataEnum msgEnum = (DataEnum)result.MsgId; switch (msgEnum) { case DataEnum.TableUserInfo: dataUser = _msg as TableUserInfo; break; default: LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Decode user data ERROR. Wrong message id. UserGuid:{0}, WrongId:{1}", userGuid, msgEnum); break; } } } protoData.m_Result = GameFrameworkMessage.GmResultEnum.Success; protoData.m_Info = CreateGmUserInfo(dataUser); } else if (Msg_DL_LoadResult.ErrorNoEnum.NotFound == ret.ErrorNo) { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "DataCache Load NotFound: Msg:{0}, Key:{1}", "GmUser", primaryKey); } else { LogSys.Log(LOG_TYPE.ERROR, "DataCache Load Failed: Msg:{0}, Key:{1}, ERROR:{2}", "GmUser", primaryKey, ret.ErrorInfo); } resultMsg.m_ProtoData = protoData; JsonGmMessageDispatcher.SendNodeMessage(nodeHandle, resultMsg); }); }
// internal void GMLoadAccount(string gmAccount, string accountId, int nodeHandle) { Msg_LD_Load msg = new Msg_LD_Load(); msg.MsgId = (int)DataEnum.TableAccount; msg.PrimaryKeys.Add(accountId); Msg_LD_SingleLoadRequest reqAccount = new Msg_LD_SingleLoadRequest(); reqAccount.MsgId = (int)DataEnum.TableAccount; reqAccount.LoadType = Msg_LD_SingleLoadRequest.LoadTypeEnum.LoadSingle; reqAccount.Keys.Add(accountId); msg.LoadRequests.Add(reqAccount); RequestLoad(msg, (ret) => { JsonMessage resultMsg = new JsonMessage(LobbyGmMessageDefine.Msg_CL_GmQueryAccount, gmAccount); GameFrameworkMessage.Msg_LC_GmQueryAccount protoData = new GameFrameworkMessage.Msg_LC_GmQueryAccount(); protoData.m_Result = GameFrameworkMessage.GmResultEnum.Failed; protoData.m_QueryAccount = accountId; protoData.m_AccountState = GameFrameworkMessage.GmStateEnum.Offline; resultMsg.m_ProtoData = protoData; KeyString primaryKey = KeyString.Wrap(ret.PrimaryKeys); if (Msg_DL_LoadResult.ErrorNoEnum.Success == ret.ErrorNo) { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Green, "DataCache Load Success: Msg:{0}, Key:{1}", "GmAccount", primaryKey); TableAccount dataAccount = null; foreach (var result in ret.Results) { object _msg; if (DbDataSerializer.Decode(result.Data, DataEnum2Type.Query(result.MsgId), out _msg)) { DataEnum msgEnum = (DataEnum)result.MsgId; switch (msgEnum) { case DataEnum.TableAccount: dataAccount = _msg as TableAccount; break; default: LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "Decode account data ERROR. Wrong message id. Account:{0}, WrongId:{1}", result.PrimaryKeys[0], msgEnum); break; } } } protoData.m_Result = GameFrameworkMessage.GmResultEnum.Success; protoData.m_QueryAccount = dataAccount.AccountId; protoData.m_AccountState = GameFrameworkMessage.GmStateEnum.Online; if (dataAccount.IsBanned) { protoData.m_AccountState = GameFrameworkMessage.GmStateEnum.Banned; } } else if (Msg_DL_LoadResult.ErrorNoEnum.NotFound == ret.ErrorNo) { LogSys.Log(LOG_TYPE.INFO, ConsoleColor.Yellow, "DataCache Load NotFound: Msg:{0}, Key:{1}", "GmAccount", primaryKey); } else { LogSys.Log(LOG_TYPE.ERROR, ConsoleColor.Red, "DataCache Load Failed: Msg:{0}, Key:{1}, ERROR:{2}", "GmAccount", primaryKey, ret.ErrorInfo); } resultMsg.m_ProtoData = protoData; JsonGmMessageDispatcher.SendNodeMessage(nodeHandle, resultMsg); }); }