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.
136 lines
5.2 KiB
136 lines
5.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
using Sog.Service;
|
|
using ProtoCSStruct;
|
|
|
|
namespace Rank
|
|
{
|
|
public class RankMsgHandler : BaseReloadableService
|
|
{
|
|
private ServerApp m_app;
|
|
|
|
public override int GetServiceType()
|
|
{
|
|
return RankServiceType.RankMsgHandler;
|
|
}
|
|
|
|
//销毁的时候置空
|
|
public override void Dispose()
|
|
{
|
|
m_app = null;
|
|
}
|
|
|
|
public RankMsgHandler(ServerApp app)
|
|
{
|
|
m_app = app;
|
|
}
|
|
|
|
public ServerApp GetApp()
|
|
{
|
|
return m_app;
|
|
}
|
|
|
|
public void HandlerMessage(uint remoteAppID, MessageData message)
|
|
{
|
|
StructPacket packet;
|
|
bool bSuccess = RankServerUtils.GetProtoPacker().UnpackMessage(message, out packet);
|
|
if (bSuccess == false)
|
|
{
|
|
TraceLog.Error("HandlerMessage ,unpack msg failed {0}, remoteAppID {1}", message.Header.Type, remoteAppID);
|
|
return;
|
|
}
|
|
//因为需要放入每个线程的队列,所以需要clone 一个新的对象,UnpackMessage出来的消息每次其实是同一个
|
|
//如果存在性能问题,可以根据消息类型进行缓冲
|
|
//packet = packet.Clone();
|
|
|
|
//预先判断,提高效率
|
|
if (TraceLog.GetLogLevel() <= (int)Sog.Log.LogLevel.TraceDetail && TraceLog.IsSkipLogMsgID(packet.MsgID) == false)
|
|
{
|
|
|
|
TraceLog.TraceDetail("recv message from server {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)CSGameMsgID.QueryRankListReq:
|
|
RankSvc.OnQueryRankListReq(remoteAppID, packet);
|
|
break;
|
|
case (int)CSGameMsgID.QueryRankSelfReq:
|
|
RankSvc.OnQueryRankSelfReq(remoteAppID, packet);
|
|
break;
|
|
|
|
case (int)CSGameMsgID.QueryRankTopReq:
|
|
RankSvc.OnQueryRankTopReq(remoteAppID, packet);
|
|
break;
|
|
|
|
case (int)SSGameMsgID.AddServerTimeSync:
|
|
SysSvc.OnAddServerTimeSync(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.MailOpRes:
|
|
SysSvc.OnMailOpRes(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.SaveRankDbRes:
|
|
RankSvc.OnSaveRankDbRes(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.QueryRankDbRes:
|
|
RankSvc.OnQueryRankDbRes(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.RankRealmlistRes:
|
|
RankSvc.OnRankRealmlistRanklistRes(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.AddRankDataReq:
|
|
RankSvc.OnAddRankDataReq(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.PlayerShowinfoUpdate:
|
|
RankSvc.OnPlayerShowInfoUpdate(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.SynRoleRankData:
|
|
RankSvc.OnSynRoleRankData(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.SendRankRewardReq:
|
|
RankSvc.OnSendRankRewardReq(remoteAppID, packet);
|
|
break;
|
|
|
|
case (int)SSGameMsgID.ClearRankReq:
|
|
ref SSClearRankReq req1 = ref packet.GetMessage<SSClearRankReq>();
|
|
SSClearRankRes res1 = new SSClearRankRes();
|
|
RankSvc.ClearRank(req1.RankId,req1.RealmID);
|
|
RankServerUtils.GetPacketSender().SendToServerByID(remoteAppID, (int)SSGameMsgID.ClearRankRes, ref res1, packet.ObjectID);
|
|
break;
|
|
|
|
case (int)SSGameMsgID.QueryActRankDbRes:
|
|
ActRankScv.OnSetActRank(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.AddActRankDataReq:
|
|
ActRankScv.OnUpgradeActRankDataReq(remoteAppID, packet);
|
|
break;
|
|
case (int)CSGameMsgID.QueryActRankListReq:
|
|
ActRankScv.OnQueryActRankListReq(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.SaveActRankDataRes:
|
|
ActRankScv.OnSaveActRankDataRes(remoteAppID, packet);
|
|
break;
|
|
case (int)SSGameMsgID.QueryRankOneReq:
|
|
RankSvc.QueryRankOneReq(remoteAppID, packet);
|
|
break;
|
|
case (int)CSGameMsgID.RankPlayerBylevelReq:
|
|
RankSvc.RankPlayerBylevelReq(remoteAppID, packet);
|
|
break;
|
|
default:
|
|
TraceLog.Error("RankMsgHandler unknow MsgID {0}", packet.MsgID);
|
|
break;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|