using System.Collections.Generic; using Sog; using ProtoCSStruct; using Org.BouncyCastle.Bcpg; namespace World { public class WorldMsgHandler : BaseReloadableService { private ServerApp m_app; public override int GetServiceType() { return WorldServiceType.WorldMsgHandler; } //销毁的时候置空 public override void Dispose() { m_app = null; } public WorldMsgHandler(ServerApp app) { m_app = app; } public ServerApp GetApp() { return m_app; } public void HandlerMessage(uint remoteAppID, MessageData message) { //role保存直接透传给gamedb,不解包了 if(message.Header.Type == (int)SSGameMsgID.SaveRoleReq) { TraceLog.Debug("WorldMsgHandler.HandlerMessage tran saverole objId {0}", message.Header.ObjectID); uint dbServerID = DBServerIDUtils.GetGameDBServerID(message.Header.ObjectID); message = message.Clone(); WorldServerUtils.GetPacketSender().SendToServerByID(dbServerID, message); return; } StructPacket packet; bool bSuccess = WorldServerUtils.GetProtoPacker().UnpackMessage(message,out packet); if (bSuccess) { //预先判断,提高效率 if (TraceLog.GetLogLevel() <= (int)Sog.Log.LogLevel.TraceDetail) { if(TraceLog.IsSkipLogMsgID(packet.MsgID)) { // log message TraceLog.TraceDetail("WorldMsgHandler.HandlerMessage recv from {0}, message type {1} length {2} {3}" , ServerIDUtils.IDToString(remoteAppID) , message.Header.Type , message.Header.Length , packet.MessageName()); } else { // log message TraceLog.TraceDetail("WorldMsgHandler.HandlerMessage recv from {0}, message type {1} length {2} {3}->{4}" , ServerIDUtils.IDToString(remoteAppID) , message.Header.Type , message.Header.Length , packet.MessageName() , packet.ToString()); } } } switch (packet.MsgID) { case (int) SSGameMsgID.GmStopServerNotify: WorldServerUtils.GetApp().PrepareStop(); break; case (int) SSGameMsgID.ServerStopNotify: OnServerStopNotify(remoteAppID, packet); break; case (int) SSGameMsgID.GameReportReq: GameReportSvc.OnGameReportReq(remoteAppID, packet); break; case (int)SSGameMsgID.OnlineReport: GameReportSvc.OnRealmOnlineReport(remoteAppID, packet); break; case (int)SSMsgID.GameReportRealmlistRes: GameReportSvc.OnGameReportRealmlistRes(remoteAppID, packet); break; //case (int) SSGameMsgID.RandomTaskReq: // OnRandomTaskReq(remoteAppID, packet); // break; #region login case (int)SSGameMsgID.GametoworldConnectnotify: LoginSvc.OnGameConnectNotify(remoteAppID, packet); break; case (int)CSGameMsgID.LoginReq: LoginSvc.OnLoginCheckReq(remoteAppID, packet); break; // gamesvr发来的请求 case (int)CSMsgID.GameListReq: LoginSvc.OnGameListReq(remoteAppID, packet); break; // accountsvr发来的应答 case (int)CSMsgID.GameListRes: ref var gameres = ref packet.GetMessage(); WorldServerUtils.GetPacketSender().SendToServerByID(gameres.FromGameSvr, packet); break; case (int)CSGameMsgID.QueryRoleReq: LoginSvc.OnCheckLoginQueryRoleReq(remoteAppID, packet); break; case (int) SSMsgID.LoginCheckValidRes: LoginSvc.OnLoginCheckRes(remoteAppID, packet); break; case (int) SSGameMsgID.QueryRoleDbReq: LoginSvc.OnQueryRoleReq(remoteAppID, packet); break; case (int) SSGameMsgID.QueryRoleDbRes: LoginSvc.OnQueryRoleRes(remoteAppID, packet); break; case (int)SSGameMsgID.QueryRoleDropDbRes: LoginSvc.QueryRoleDropDbRes(remoteAppID, packet); break; //case (int) SSGameMsgID.SaveRoleReq: // LoginSvc.OnSaveRoleReq(remoteAppID, packet); // break; case (int)SSGameMsgID.SaveRoleNotify: LoginSvc.OnSaveRoleNotify(remoteAppID, packet); break; case (int) SSGameMsgID.SaveRoleRes: LoginSvc.OnSaveRoleRes(remoteAppID, packet); break; case (int) SSGameMsgID.GamePlayerDestroy: LoginSvc.OnGamePlayerDestroy(remoteAppID, packet); break; case (int) SSGameMsgID.RoleLoginSuccessNotify: LoginSvc.OnRoleLoginSuccessNotify(remoteAppID, packet); break; case (int) CSMsgID.BindGuestFacebookReq: LoginSvc.OnBindGuestFacebookReq(remoteAppID, packet); break; case (int) CSMsgID.BindGuestFacebookRes: LoginSvc.OnBindGuestFacebookRes(remoteAppID, packet); break; case (int)CSMsgID.UnbindGuestFacebookReq: LoginSvc.OnUnBindGuestFacebookReq(remoteAppID, packet); break; case (int)CSMsgID.UnbindGuestFacebookRes: LoginSvc.OnUnBindGuestFacebookRes(remoteAppID, packet); break; case (int) SSMsgID.QueryUidByFbuseridReq: LoginSvc.OnQueryUidByFbuseridReq(remoteAppID, packet); break; case (int) SSMsgID.QueryUidByFbuseridRes: LoginSvc.OnQueryUidByFbuseridRes(remoteAppID, packet); break; case (int)SSMsgID.QueryUidByWxidReq: LoginSvc.OnQueryUidByWxidReq(remoteAppID, packet); break; case (int)SSMsgID.QueryUidByWxidRes: LoginSvc.OnQueryUidByWxidRes(remoteAppID, packet); break; case (int)CSMsgID.UpdateAccountGradeReq: LoginSvc.OnUpdateAccountGradeReq(remoteAppID, packet); break; case (int)CSMsgID.UpdateAccountGradeRes: LoginSvc.OnUpdateAccountGradeRes(remoteAppID, packet); break; case (int)CSGameMsgID.DownloadResourceReq: LoginSvc.OnDownloadResourceReq(remoteAppID, packet); break; case (int)CSGameMsgID.DownloadResourceRes: LoginSvc.OnDownloadResourceRes(remoteAppID, packet); break; #endregion #region gm case (int) SSGameMsgID.GmSetFreezeTime: LoginSvc.OnGmSetFreezeTime(remoteAppID, packet); break; case (int) SSGameMsgID.GmSetFreezeTimeRes: LoginSvc.OnGmSetFreezeTimeRes(remoteAppID, packet); break; case (int) SSGameMsgID.GmQueryUserPayRecordReq: { uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID); WorldServerUtils.GetPacketSender().SendToServerByID(dbServerID, packet); break; } case (int)SSGameMsgID.OperationFakepay: { uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID); WorldServerUtils.GetPacketSender().SendToServerByID(gameServerId, packet); break; } case (int)SSGameMsgID.OperationFakepayRes: WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); break; case (int)SSGameMsgID.OperationCostItemReq: { var msg = packet.GetMessage(); if (msg.Model == 0) { uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID); WorldServerUtils.GetPacketSender().SendToServerByID(gameServerId, packet); } else { uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID); WorldServerUtils.GetPacketSender().SendToServerByID(dbServerID, packet); } break; } case (int)SSGameMsgID.OperationCostItemRes: { WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); break; } case (int)SSGameMsgID.OperationMailDeleteReq: { uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID); WorldServerUtils.GetPacketSender().SendToServerByID(gameServerId, packet); } break; case (int)SSGameMsgID.OperationMonitorReq: { uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID); WorldServerUtils.GetPacketSender().SendToServerByID(gameServerId, packet); } break; case (int)SSGameMsgID.OperationMonitorRes: { WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); } break; case (int)SSGameMsgID.OperationUpdateTaskReq: { var msg = packet.GetMessage(); if (msg.Model == 0) { uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID); WorldServerUtils.GetPacketSender() .SendToServerByID(gameServerId, packet); } else { uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID); WorldServerUtils.GetPacketSender() .SendToServerByID(dbServerID, packet); } } break; case (int)SSGameMsgID.GmUpdateUserRoleReq: { var msg = packet.GetMessage(); if (msg.Model == 0) { uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID); WorldServerUtils.GetPacketSender() .SendToServerByID(gameServerId, packet); } else { uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID); WorldServerUtils.GetPacketSender() .SendToServerByID(dbServerID, packet); } } break; case (int)SSGameMsgID.GmImportUserRoleReq: { ref var msg = ref packet.GetMessage(); if (msg.Model == 0) { uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID); WorldServerUtils.GetPacketSender() .SendToServerByID(gameServerId, packet); } else { uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID); WorldServerUtils.GetPacketSender() .SendToServerByID(dbServerID, packet); } } break; case (int)SSGameMsgID.OperationUpdateTaskRes: { WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); } break; case (int)SSGameMsgID.OperationMailDeleteRes: WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); break; case (int)SSGameMsgID.SyncPresetReq: WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); break; case (int)SSGameMsgID.SyncPresetRes: { var res = packet.GetMessage(); WorldServerUtils.GetPacketSender().SendToServerByID((uint)res.GId, packet); } break; //case (int) SSGameMsgID.GmQueryUserPayRecordRes: // ref var gmres = ref packet.GetMessage(); // WorldServerUtils.GetPacketSender().SendToServerByID(gmres.FromServerID, packet); // break; case (int) SSGameMsgID.GmPlayerPhoneInfo: LoginSvc.OnGmPlayerPhoneInfo(remoteAppID, packet); break; case (int) SSGameMsgID.GmLinkClickCount: LoginSvc.OnGmLinkClickCount(remoteAppID, packet); break; case (int)SSGameMsgID.NotifyworldBroadcastgmcmd: GmCmdSvc.OnNotifyWorldBroadCastGMCmd(remoteAppID, packet); break; #endregion #region Pay case (int) SSGameMsgID.PayGoogleReq: PaySvc.OnGooglePayReq(remoteAppID, packet); break; case (int)CSGameMsgID.PayWsjsapiReq: { ref CSWXJSPayReq jsreq = ref packet.GetMessage(); jsreq.Gsid = (int)remoteAppID; WorldServerUtils.GetPacketSender().SendToHttpProxyPayServer(packet); break; } case (int)CSGameMsgID.PayWsjsapiRes: { ref CSWXJSPayReS res = ref packet.GetMessage(); WorldServerUtils.GetPacketSender().SendToServerByID((uint)res.Gsid,packet); break; } case (int) SSGameMsgID.PayGoogleRes: PaySvc.OnGooglePayRes(remoteAppID, packet); break; case (int) SSGameMsgID.PayGoogleSuccessReq: WorldServerUtils.GetPacketSender().SendToHttpProxyPayServer(packet); break; case (int) SSGameMsgID.PayGoogleSuccessRes: PaySvc.OnGooglePaySuccessRes(remoteAppID, packet); break; case (int) SSGameMsgID.PayDbAddDiamondStatusReq: PaySvc.OnPayAddDiamondSuccReq(remoteAppID, packet); break; case (int)SSGameMsgID.PayDbAddDiamondStatusRes: PaySvc.OnPayAddDiamondSuccRes(remoteAppID, packet); break; case (int)SSGameMsgID.QueryPayGoogleSuccOrder: WorldServerUtils.GetPacketSender().SendToHttpProxyPayServer(packet); break; case (int)SSGameMsgID.GmTestHeroPaySucc: WorldServerUtils.GetPacketSender().SendToHttpProxyPayServer(packet); break; case (int)SSGameMsgID.PayAddPlayerItemNotify: WorldServerUtils.GetPacketSender().SendToHttpProxyPayServer(packet); break; case (int)SSGameMsgID.PayDiamondHolderQueryReq: DiamondHolderSvc.OnPayDiamondHolderQueryReq(remoteAppID, packet); break; case (int)SSGameMsgID.PayDiamondHolderQueryRes: DiamondHolderSvc.OnPayDiamondHolderQueryRes(remoteAppID, packet); break; case (int)SSGameMsgID.PayDiamondHolderAddReq: DiamondHolderSvc.OnPayDiamondHolderAddReq(remoteAppID, packet); break; case (int)SSGameMsgID.PayDiamondHolderAddRes: DiamondHolderSvc.OnPayDiamondHolderAddRes(remoteAppID, packet); break; case (int)SSGameMsgID.PayDiamondHolderCostReq: DiamondHolderSvc.OnPayDiamondHolderCostReq(remoteAppID, packet); break; case (int)SSGameMsgID.PayDiamondHolderCostRes: DiamondHolderSvc.OnPayDiamondHolderCostRes(remoteAppID, packet); break; case (int)SSGameMsgID.PayDiamondHolderCostCancelReq: DiamondHolderSvc.OnPayDiamondHolderCostCancelReq(remoteAppID, packet); break; #endregion #region Friend case (int)SSGameMsgID.QueryFriendListReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)SSGameMsgID.QueryBlacklistReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)SSGameMsgID.QueryFriendListRes: SendToGameSvr(packet); break; case (int)SSGameMsgID.QueryBlacklistRes: SendToGameSvr(packet); break; case (int)CSGameMsgID.FriendSelfChgNotify: SendToGameSvr(packet); break; case (int)CSGameMsgID.FriendListChgNotify: SendToGameSvr(packet); break; case (int)CSGameMsgID.FriendOpReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)CSGameMsgID.FriendOpRes: SendToGameSvr(packet); break; case (int)CSGameMsgID.FriendOpListChgNotify: SendToGameSvr(packet); break; case (int)CSGameMsgID.QueryFriendOpReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)CSGameMsgID.QueryFriendOpRes: SendToGameSvr(packet); break; //case (int)CSGameMsgID.QueryFriendStatusRes: // SendToGameSvr(packet); // break; case (int)CSGameMsgID.FriendQueryInfoByUidRes: SendToGameSvr(packet); break; case (int)CSGameMsgID.FriendGetRecommenderReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)CSGameMsgID.FriendGetRecommenderRes: SendToGameSvr(packet); break; case (int)CSGameMsgID.SetPersonalizedSignatureRes: SendToGameSvr(packet); break; case (int)CSGameMsgID.FriendSetSettingRes: SendToGameSvr(packet); break; case (int)CSGameMsgID.FriendGiftOpReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)CSGameMsgID.FriendGiftOpRes: SendToGameSvr(packet); break; case (int)CSGameMsgID.FriendSendGiftNotify: SendToGameSvr(packet); break; case (int)CSGameMsgID.FriendGiftAutoOpReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)CSGameMsgID.FriendGiftAutoOpRes: SendToGameSvr(packet); break; case (int)CSGameMsgID.GetFriendGiftDataReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)CSGameMsgID.GetFriendGiftDataRes: SendToGameSvr(packet); break; case (int)CSGameMsgID.QueryFriendStatusReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)CSGameMsgID.FriendQueryInfoByUidReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)CSGameMsgID.SetPersonalizedSignatureReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; case (int)CSGameMsgID.FriendSetSettingReq: WorldServerUtils.GetPacketSender().SendToFriendServer(packet, packet.ObjectID); break; #endregion #region Mail case (int)SSGameMsgID.SendMailWithRule: ref var req = ref packet.GetMessage(); WorldServerUtils.GetPacketSender().SendToMailServer((int)SSGameMsgID.SendMailWithRule, ref req, 0); break; case (int)SSGameMsgID.SendMailWithRuleRes: WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); break; case (int)SSGameMsgID.DiscardMailWithRuleReq: uint mailServerID = WorldServerUtils.GetPacketSender().GetMailServerID(); WorldServerUtils.GetPacketSender().SendToServerByID(mailServerID, packet); break; case (int)SSGameMsgID.GetMailWithRuleReq: WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); break; case (int)SSGameMsgID.GetMailWithRuleRes: uint mailServerIDWithRuleRes = WorldServerUtils.GetPacketSender().GetMailServerID(); WorldServerUtils.GetPacketSender().SendToServerByID(mailServerIDWithRuleRes, packet); break; break; #endregion #region Sys case (int) SSGameMsgID.UpdateRolebaseToWorld: SysSvc.OnUpdateRolebaseToWorld(remoteAppID, packet); break; case (int) SSGameMsgID.UpdateRoleDataToWorld: SysSvc.OnUpdateRoleDataToWorld(remoteAppID, packet); break; case (int) SSGameMsgID.AddServerTimeSync: SysSvc.OnAddServerTimeSync(remoteAppID, packet); break; case (int) CSGameMsgID.TipOffPlayerReq: SysSvc.OnTipOffPlayerReq(remoteAppID, packet); break; case (int) CSGameMsgID.SetLanguageReq: SysSvc.OnSetLanguageReq(remoteAppID, packet); break; case (int)CSGameMsgID.ChatReq: ChatSvc.OnChatReq(remoteAppID, packet); break; case (int)CSGameMsgID.ChatloginReq: ChatSvc.OnChatLoginReq(remoteAppID, packet); break; case (int)SSGameMsgID.ChatConsumeRes: ChatSvc.OnChatConsumeRes(remoteAppID, packet); break; case (int)SSGameMsgID.NoticeBackgroundsRes: SysSvc.OnNoticeBackgroundsRes(remoteAppID, packet); break; case (int)SSGameMsgID.NoticeBackgroundsReq: SysSvc.OnNoticeBackgroundsReq(remoteAppID, packet); break; case (int)SSGameMsgID.SysNoticeLampReq: SysSvc.OnSysNoticeLampReq(remoteAppID, packet); break; case (int)SSGameMsgID.SysNoticeLamp: //新加,之前没用到这个通知 SysSvc.OnSysNoticeLampNotify(remoteAppID, packet); break; case (int)SSGameMsgID.ChatNoticeReq: //公告 SysSvc.OnSysNotice(remoteAppID, packet); break; case (int)SSGameMsgID.ChatDelNotice: //删除或隐藏公告 SysSvc.OnDelSysNotice(remoteAppID, packet); break; case (int)SSGameMsgID.PlayerShowinfoUpdate: SysSvc.OnPlayerShowInfoUpdate(remoteAppID, packet); break; case (int)SSGameMsgID.EnableSendMsgReq: SysSvc.OnHandlePlayerEnableMsg(remoteAppID, packet); break; case (int)SSGameMsgID.EnableSendMsgRes: SysSvc.OnHandlePlayerEnableMsgRes(remoteAppID, packet); break; #endregion #region PlayerQueryOtherRoleInfo case (int)CSGameMsgID.PlayerQueryOtherRoleInfoReq: QueryRoleInfoSvc.OnPlayerQueryOtherRoleInfoReq(remoteAppID, packet); break; case (int)SSGameMsgID.PlayerQueryOfflineRoleRes: QueryRoleInfoSvc.OnPlayerQueryOfflineRoleRes(packet); break; case (int)CSGameMsgID.PlayerSearchRoleBynameReq: QueryRoleInfoSvc.OnPlayerSearchRoleBynameReq(packet); break; case (int)SSGameMsgID.PlayerSearchRoledbBynameRes: QueryRoleInfoSvc.OnPlayerSearchRoledbBynameRes(packet); break; #endregion case (int)SSMsgID.RealmBriefReq: OnRealmBriefReq(remoteAppID, packet); break; case (int)SSMsgID.RealmBriefRes: OnRealmBriefRes(remoteAppID, packet); break; case (int)SSGameMsgID.RankRealmlistReq: OnRankRealmlistReq(remoteAppID, packet); break; // 发给dbmaccount更新tbacc_realmuid_link表 case (int)SSMsgID.UpdateRealmRoleBrief: WorldServerUtils.GetPacketSender().SendToServerByID(AccountServerSelect.SelectFirstAccountServer(), packet, packet.ObjectID); break; //查询角色信息 case (int)SSGameMsgID.GmQueryUserRoleReq: { uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID); WorldServerUtils.GetPacketSender().SendToServerByID(dbServerID, packet); break; } case (int)SSGameMsgID.GmQueryUserRoleRes: { WorldServerUtils.GetPacketSender().SendToServerByID(WorldServerUtils.GetPacketSender().GetOperationServerIDServerID(), packet); } break; case (int)SSGameMsgID.OperationMailSearchReq: { SSOperationSearchMailReq msg = packet.GetMessage(); WorldServerUtils.GetPacketSender().SendToMailServer((int)packet.MsgID, ref msg, 0); } break; case (int)SSGameMsgID.OperationMailSearchRes: { WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); } break; case (int)SSGameMsgID.GmUpdateUserRoleRes: { WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); } break; case (int)SSGameMsgID.GmImportUserRoleRes: { WorldServerUtils.GetPacketSender().SendToOperationServer(packet, 0); } break; case (int)SSGameMsgID.GmChangeRoleNameReq: { LoginSvc.OnGMChanageRoleNameReq(remoteAppID, packet); } break; case (int)SSGameMsgID.GmChangeRoleNameRes: { WorldServerUtils.GetPacketSender().SendToServerByID(WorldServerUtils.GetPacketSender().GetOperationServerIDServerID(), packet); } break; #region 战斗简要统计记录 case (int)SSGameMsgID.SaveBattleReplayDbRes: //暂时没做任何处理 break; #endregion 战斗简要统计记录 case (int)SSGameMsgID.DeleteBattleReplayDbRes: break; case (int)SSGameMsgID.ExchangeCodeSynNotify: WorldServerUtils.GetPacketSender().Broadcast((int)ServerType.Game, packet); break; case (int)SSGameMsgID.ExchangeCodeTakeReq: WorldServerUtils.GetPacketSender().SendToPlayerOpServer(packet, packet.ObjectID, remoteAppID); break; case (int)SSGameMsgID.ExchangeCodeTakeRes: WorldServerUtils.GetPacketSender().SendToServerByID(packet.Header.ServerID, packet); break; case (int)SSGameMsgID.PlaydataOpReq: WorldServerUtils.GetPacketSender().SendToOperationServer(packet, packet.ObjectID, remoteAppID); break; case (int)SSGameMsgID.PlaydataOpRes: WorldServerUtils.GetPacketSender().SendToServerByID(packet.Header.ServerID, packet); break; case (int)SSMsgID.SyncRoleinfoToOpsvr: WorldServerUtils.GetPacketSender().Broadcast((int)ServerType.Operation, packet); break; case (int)SSGameMsgID.WorldglobaldataDbOpReq: WorldGlobalDataHandler.OnWorldglobaldataDbOpReq(remoteAppID, packet); break; case (int)SSGameMsgID.WorldglobaldataDbOpRes://查询或操作返回 WorldGlobalDataHandler.OnWorldglobaldataDbOpRes(remoteAppID, packet); break; case (int)SSGameMsgID.WorldglobaldataDbOpNewReq: WorldGlobalDataHandler.OnWorldglobaldataDbOpNewReq(remoteAppID, packet); break; case (int)SSGameMsgID.WorldglobaldataDbOpNewRes://查询或操作返回 WorldGlobalDataHandler.OnWorldglobaldataDbOpRes(remoteAppID, packet); break; case (int)SSGameMsgID.QueryRoleBaseInfoListReq: QueryRoleInfoSvc.OnQueryRoleBaseInfoListReq(remoteAppID, packet); break; case (int)SSGameMsgID.HomeAdSendHttpSyn: AdScv.OnHomeAdSendHttpSyn(remoteAppID, packet); break; case (int)SSGameMsgID.HomeAdSendAwardSyn: AdScv.OnHomeAdSendAwardSyn(remoteAppID, packet); break; case (int)SSGameMsgID.Reward: { uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID); WorldServerUtils.GetPacketSender().SendToServerByID(gameServerId, packet); break; } case (int)SSGameMsgID.RewardRes: WorldServerUtils.GetPacketSender().SendToOperationServer(packet, packet.ObjectID); break; case (int)SSMsgID.SsRealmNewPlayer: WorldServerUtils.GetPacketSender().SendToRealmlistServer(packet, packet.ObjectID, 0); break; case (int)SSMsgID.SendGifts: SSSendGift(remoteAppID, packet); break; default: TraceLog.Error("WorldMsgHandler unknow MsgID {0}", packet.MsgID); break; } } private void SendToGameSvr(StructPacket packet) where T : struct, IStructMessage { PlayerInfoWorld player = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(packet.ObjectID); if (player == null) { TraceLog.Error("WorldMsgHandler.SendToGameSvr uid {0} no player", packet.ObjectID); return; } TraceLog.Trace("WorldMsgHandler.SendToGameSvr uid {0} gamesvr {1} msgId {2} {3}" , player.UserID, player.GameServerID, packet.MsgID, packet.MessageName()); WorldServerUtils.GetPacketSender().SendToServerByID(player.GameServerID, packet, player.UserID); } private void OnServerStopNotify(uint remoteAppID,StructPacket packet) { // world还是人工执行Stop安全一些,所以收到gamesvr的正式停服通知时,另设一个标志用来做正式停服前的准备。 // 如果这里调用了StopServer,可能在gamesvr数据存完前,world就处理完本地数据退出了。 // 后期可以考虑修改为gamesvr确认可以退出前再发送ServerStopNotify,这样world就可以在这里调用StopServer了。 WorldServerUtils.GetWorldServerData().m_serverStopFlag = 1; //WorldServerUtils.GetEventHandlerMgr().TriggerServerStop(); } private void OnRealmBriefReq(uint remoteAppID, StructPacket packet) { ref var req = ref packet.GetMessage(); req.WorldSvrId = WorldServerUtils.GetAppID(); WorldServerUtils.GetPacketSender().SendToRealmlistServer(packet, packet.ObjectID, req.WorldSvrId); } private void OnRealmBriefRes(uint remoteAppID, StructPacket packet) { ref var res = ref packet.GetMessage(); WorldServerUtils.GetPacketSender().SendToServerByID(res.GameSvrId, packet); } public static void OnRankRealmlistReq(uint remoteAppID, StructPacket packet) { var configRealm = WorldServerUtils.GetWorldServerData().m_configRealm; SSRankRealmlistRes res = new SSRankRealmlistRes(); foreach (RealmBriefInfo info in configRealm) { var brief = new CSRealmBrief { OpenTime = info.openTime, RealmId = info.realmId, LogicWorldId = info.logicWorldId, State = info.state, BigRealmId = info.bigRealmId }; brief.RealmName.SetString(info.realmName); brief.RealmBdcName.SetString(info.realmBdcName); res.Realms.Add(ref brief); if (res.Realms.Count >= res.Realms.GetMaxCount()) { WorldServerUtils.GetPacketSender().SendToServerByID(remoteAppID, (int)SSGameMsgID.RankRealmlistRes, ref res, 0); res.Realms.Clear(); } } if (res.Realms.Count > 0) { WorldServerUtils.GetPacketSender().SendToServerByID(remoteAppID, (int)SSGameMsgID.RankRealmlistRes, ref res, 0); } } public static void SSSendGift(uint serverId, StructPacket packet) { ref SSSendGift req = ref packet.GetMessage(); if (req.Uid > 0) { List res = new List(); for (int i = 0; i < req.Goods.Count; i++) { RewardItemRW item = new RewardItemRW(); item.type = req.Goods[i].Type; item.code = req.Goods[i].Id.GetString(); item.amount = req.Goods[i].Value; res.Add(item); } MailSender.SendNewMailToPlayer(req.Uid, 1, res); TraceLog.Trace("SSSendGift send to {0}, goodssize={1}", req.Uid, req.Goods.Count); } } } }