You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
835 lines
39 KiB
835 lines
39 KiB
1 month ago
|
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<CSGameListRes>();
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<CSGameListRes>(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<SSGmQueryUserPayRecordReq>(dbServerID, packet);
|
||
|
break;
|
||
|
}
|
||
|
case (int)SSGameMsgID.OperationFakepay:
|
||
|
{
|
||
|
uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSOperationFakePay>(gameServerId, packet);
|
||
|
break;
|
||
|
}
|
||
|
case (int)SSGameMsgID.OperationFakepayRes:
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSOperationFakePayRes>(packet, 0);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.OperationCostItemReq:
|
||
|
{
|
||
|
var msg = packet.GetMessage<SSOperationCostItemReq>();
|
||
|
if (msg.Model == 0)
|
||
|
{
|
||
|
uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSOperationCostItemReq>(gameServerId, packet);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSOperationCostItemReq>(dbServerID, packet);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
case (int)SSGameMsgID.OperationCostItemRes:
|
||
|
{
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSOperationCostItemRes>(packet, 0);
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
case (int)SSGameMsgID.OperationMailDeleteReq:
|
||
|
{
|
||
|
uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSOperationDeleteMailReq>(gameServerId, packet);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.OperationMonitorReq:
|
||
|
{
|
||
|
uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSOperationMonitorReq>(gameServerId, packet);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.OperationMonitorRes:
|
||
|
{
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSOperationMonitorRes>(packet, 0);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.OperationUpdateTaskReq:
|
||
|
{
|
||
|
var msg = packet.GetMessage<SSOperationUpdateTaskReq>();
|
||
|
if (msg.Model == 0)
|
||
|
{
|
||
|
uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender()
|
||
|
.SendToServerByID<SSOperationUpdateTaskReq>(gameServerId, packet);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender()
|
||
|
.SendToServerByID<SSOperationUpdateTaskReq>(dbServerID, packet);
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.GmUpdateUserRoleReq:
|
||
|
{
|
||
|
var msg = packet.GetMessage<SSGmUpdateUserRoleInfoReq>();
|
||
|
if (msg.Model == 0)
|
||
|
{
|
||
|
uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender()
|
||
|
.SendToServerByID<SSGmUpdateUserRoleInfoReq>(gameServerId, packet);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender()
|
||
|
.SendToServerByID<SSGmUpdateUserRoleInfoReq>(dbServerID, packet);
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.GmImportUserRoleReq:
|
||
|
{
|
||
|
ref var msg = ref packet.GetMessage<SSGmImportUserRoleInfoReq>();
|
||
|
if (msg.Model == 0)
|
||
|
{
|
||
|
uint gameServerId = GameServerSelect.SelectGameServer(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender()
|
||
|
.SendToServerByID<SSGmImportUserRoleInfoReq>(gameServerId, packet);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender()
|
||
|
.SendToServerByID<SSGmImportUserRoleInfoReq>(dbServerID, packet);
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.OperationUpdateTaskRes:
|
||
|
{
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSOperationUpdateTaskRes>(packet, 0);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.OperationMailDeleteRes:
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSOperationDeleteMailRes>(packet, 0);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.SyncPresetReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSSyncPresetDataReq>(packet, 0);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.SyncPresetRes:
|
||
|
{
|
||
|
var res = packet.GetMessage<SSSyncPresetDataRes>();
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSSyncPresetDataRes>((uint)res.GId, packet);
|
||
|
}
|
||
|
break;
|
||
|
//case (int) SSGameMsgID.GmQueryUserPayRecordRes:
|
||
|
// ref var gmres = ref packet.GetMessage<SSGmQueryUserPayRecordRes>();
|
||
|
// WorldServerUtils.GetPacketSender().SendToServerByID<SSGmQueryUserPayRecordRes>(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<CSWXJSPayReq>();
|
||
|
jsreq.Gsid = (int)remoteAppID;
|
||
|
WorldServerUtils.GetPacketSender().SendToHttpProxyPayServer<CSWXJSPayReq>(packet);
|
||
|
break;
|
||
|
}
|
||
|
case (int)CSGameMsgID.PayWsjsapiRes:
|
||
|
{
|
||
|
ref CSWXJSPayReS res = ref packet.GetMessage<CSWXJSPayReS>();
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<CSWXJSPayReS>((uint)res.Gsid,packet);
|
||
|
break;
|
||
|
}
|
||
|
case (int) SSGameMsgID.PayGoogleRes:
|
||
|
PaySvc.OnGooglePayRes(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int) SSGameMsgID.PayGoogleSuccessReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToHttpProxyPayServer<SSPayGoogleSuccessReq>(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<SSQueryPayGoogleSuccOrder>(packet);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.GmTestHeroPaySucc:
|
||
|
WorldServerUtils.GetPacketSender().SendToHttpProxyPayServer<SSGMTestHeroPaySucc>(packet);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.PayAddPlayerItemNotify:
|
||
|
WorldServerUtils.GetPacketSender().SendToHttpProxyPayServer<SSPayAddPlayerItemNotify>(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<SSQueryFriendListReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)SSGameMsgID.QueryBlacklistReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<SSQueryBlacklistReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.QueryFriendListRes:
|
||
|
SendToGameSvr<SSQueryFriendListRes>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)SSGameMsgID.QueryBlacklistRes:
|
||
|
SendToGameSvr<SSQueryBlacklistRes>(packet);
|
||
|
break;
|
||
|
case (int)CSGameMsgID.FriendSelfChgNotify:
|
||
|
SendToGameSvr<CSFriendSelfChgNotify>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendListChgNotify:
|
||
|
SendToGameSvr<CSFriendListChgNotify>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendOpReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSFriendOpReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendOpRes:
|
||
|
SendToGameSvr<CSFriendOpRes>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendOpListChgNotify:
|
||
|
SendToGameSvr<CSFriendOpListChgNotify>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.QueryFriendOpReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSQueryFriendOpReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.QueryFriendOpRes:
|
||
|
SendToGameSvr<CSQueryFriendOpRes>(packet);
|
||
|
break;
|
||
|
|
||
|
//case (int)CSGameMsgID.QueryFriendStatusRes:
|
||
|
// SendToGameSvr<CSQueryFriendStatusRes>(packet);
|
||
|
// break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendQueryInfoByUidRes:
|
||
|
SendToGameSvr<CSFriendQueryInfoByUidRes>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendGetRecommenderReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSFriendGetRecommenderReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendGetRecommenderRes:
|
||
|
SendToGameSvr<CSFriendGetRecommenderRes>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.SetPersonalizedSignatureRes:
|
||
|
SendToGameSvr<CSSetPersonalizedSignatureRes>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendSetSettingRes:
|
||
|
SendToGameSvr<CSFriendSetSettingRes>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendGiftOpReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSFriendGiftOpReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendGiftOpRes:
|
||
|
SendToGameSvr<CSFriendGiftOpRes>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendSendGiftNotify:
|
||
|
SendToGameSvr<CSFriendSendGiftNotify>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendGiftAutoOpReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSFriendGiftAutoOpReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendGiftAutoOpRes:
|
||
|
SendToGameSvr<CSFriendGiftAutoOpRes>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.GetFriendGiftDataReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSGetFriendGiftDataReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.GetFriendGiftDataRes:
|
||
|
SendToGameSvr<CSGetFriendGiftDataRes>(packet);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.QueryFriendStatusReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSQueryFriendStatusReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendQueryInfoByUidReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSFriendQueryInfoByUidReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.SetPersonalizedSignatureReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSSetPersonalizedSignatureReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
case (int)CSGameMsgID.FriendSetSettingReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToFriendServer<CSFriendSetSettingReq>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Mail
|
||
|
case (int)SSGameMsgID.SendMailWithRule:
|
||
|
ref var req = ref packet.GetMessage<SSSendMailWithRule>();
|
||
|
WorldServerUtils.GetPacketSender().SendToMailServer((int)SSGameMsgID.SendMailWithRule, ref req, 0);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.SendMailWithRuleRes:
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSSendMailWithRuleRes>(packet, 0);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.DiscardMailWithRuleReq:
|
||
|
uint mailServerID = WorldServerUtils.GetPacketSender().GetMailServerID();
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSDiscardMailWithRuleReq>(mailServerID, packet);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.GetMailWithRuleReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSGetMailWithRuleReq>(packet, 0);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.GetMailWithRuleRes:
|
||
|
uint mailServerIDWithRuleRes = WorldServerUtils.GetPacketSender().GetMailServerID();
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSGetMailWithRuleRes>(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<SSUpdateRealmRoleBrief>(AccountServerSelect.SelectFirstAccountServer(),
|
||
|
packet, packet.ObjectID);
|
||
|
break;
|
||
|
|
||
|
//查询角色信息
|
||
|
case (int)SSGameMsgID.GmQueryUserRoleReq:
|
||
|
{
|
||
|
uint dbServerID = DBServerIDUtils.GetGameDBServerID(packet.ObjectID);
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSGmQueryUserRoleInfoReq>(dbServerID, packet);
|
||
|
break;
|
||
|
}
|
||
|
case (int)SSGameMsgID.GmQueryUserRoleRes:
|
||
|
{
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSGmQueryUserRoletInfoRes>(WorldServerUtils.GetPacketSender().GetOperationServerIDServerID(), packet);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.OperationMailSearchReq:
|
||
|
{
|
||
|
SSOperationSearchMailReq msg = packet.GetMessage<SSOperationSearchMailReq>();
|
||
|
WorldServerUtils.GetPacketSender().SendToMailServer<SSOperationSearchMailReq>((int)packet.MsgID, ref msg, 0);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.OperationMailSearchRes:
|
||
|
{
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSOperationSearchMailRes>(packet, 0);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.GmUpdateUserRoleRes:
|
||
|
{
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSGmUpdateUserRoleInfoRes>(packet, 0);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.GmImportUserRoleRes:
|
||
|
{
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSGmImportUserRoleInfoRes>(packet, 0);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.GmChangeRoleNameReq:
|
||
|
{
|
||
|
LoginSvc.OnGMChanageRoleNameReq(remoteAppID, packet);
|
||
|
}
|
||
|
break;
|
||
|
case (int)SSGameMsgID.GmChangeRoleNameRes:
|
||
|
{
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSGmChangeRoleNameRes>(WorldServerUtils.GetPacketSender().GetOperationServerIDServerID(), packet);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
#region 战斗简要统计记录
|
||
|
|
||
|
case (int)SSGameMsgID.SaveBattleReplayDbRes:
|
||
|
//暂时没做任何处理
|
||
|
break;
|
||
|
|
||
|
#endregion 战斗简要统计记录
|
||
|
case (int)SSGameMsgID.DeleteBattleReplayDbRes:
|
||
|
break;
|
||
|
|
||
|
case (int)SSGameMsgID.ExchangeCodeSynNotify:
|
||
|
WorldServerUtils.GetPacketSender().Broadcast<SSExchangeCodeSynNotify>((int)ServerType.Game, packet);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.ExchangeCodeTakeReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToPlayerOpServer<SSExchangeCodeTakeReq>(packet, packet.ObjectID, remoteAppID);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.ExchangeCodeTakeRes:
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSExchangeCodeTakeRes>(packet.Header.ServerID, packet);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.PlaydataOpReq:
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSPlayDataOpReq>(packet, packet.ObjectID, remoteAppID);
|
||
|
break;
|
||
|
case (int)SSGameMsgID.PlaydataOpRes:
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSPlayDataOpRes>(packet.Header.ServerID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.SyncRoleinfoToOpsvr:
|
||
|
WorldServerUtils.GetPacketSender().Broadcast<SSSyncRoleInfoToOpSvr>((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<SSGMReward>(gameServerId, packet);
|
||
|
break;
|
||
|
}
|
||
|
case (int)SSGameMsgID.RewardRes:
|
||
|
WorldServerUtils.GetPacketSender().SendToOperationServer<SSGMRewardRes>(packet, packet.ObjectID);
|
||
|
break;
|
||
|
case (int)SSMsgID.SsRealmNewPlayer:
|
||
|
WorldServerUtils.GetPacketSender().SendToRealmlistServer<SSRealmNewPlayer>(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<T>(StructPacket packet) where T : struct, IStructMessage<T>
|
||
|
{
|
||
|
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<T>(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<SSRealmBriefReq>();
|
||
|
req.WorldSvrId = WorldServerUtils.GetAppID();
|
||
|
WorldServerUtils.GetPacketSender().SendToRealmlistServer<SSRealmBriefReq>(packet, packet.ObjectID, req.WorldSvrId);
|
||
|
}
|
||
|
|
||
|
private void OnRealmBriefRes(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var res = ref packet.GetMessage<SSRealmBriefRes>();
|
||
|
WorldServerUtils.GetPacketSender().SendToServerByID<SSRealmBriefRes>(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<SSSendGift>();
|
||
|
if (req.Uid > 0)
|
||
|
{
|
||
|
List<RewardItemRW> res = new List<RewardItemRW>();
|
||
|
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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|