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.
519 lines
24 KiB
519 lines
24 KiB
1 month ago
|
using System.Collections.Generic;
|
||
|
using Sog;
|
||
|
using ProtoCSStruct;
|
||
|
|
||
|
|
||
|
namespace Account
|
||
|
{
|
||
|
public class AccountMsgHandler : BaseReloadableService
|
||
|
{
|
||
|
private ServerApp m_app;
|
||
|
|
||
|
public override int GetServiceType()
|
||
|
{
|
||
|
return AccountServiceType.AccountMsgHandler;
|
||
|
}
|
||
|
|
||
|
//销毁的时候置空
|
||
|
public override void Dispose()
|
||
|
{
|
||
|
m_app = null;
|
||
|
}
|
||
|
|
||
|
public AccountMsgHandler(ServerApp app)
|
||
|
{
|
||
|
m_app = app;
|
||
|
}
|
||
|
|
||
|
public ServerApp GetApp()
|
||
|
{
|
||
|
return m_app;
|
||
|
}
|
||
|
|
||
|
public void HandlerMessage(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
switch (packet.MsgID)
|
||
|
{
|
||
|
case (int)CSMsgID.BindGuestFacebookReq:
|
||
|
BindGuestFacebookSvc.OnBindGuestFacebookReq(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.BindGuestFacebookHttpCheckRes:
|
||
|
BindGuestFacebookSvc.OnBindGuestFacebookHttpCheckRes(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.BindGuestFacebookDbRes:
|
||
|
BindGuestFacebookSvc.OnBindGuestFacebookDbRes(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)CSMsgID.UnbindGuestFacebookReq:
|
||
|
BindGuestFacebookSvc.OnUnbindGuestFacebookReq(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.UnbindGuestFacebookDbRes:
|
||
|
BindGuestFacebookSvc.OnUnbindGuestFacebookDbRes(remoteAppID, packet);
|
||
|
break;
|
||
|
////
|
||
|
case (int)SSMsgID.QueryHttpSnsFriendListRes:
|
||
|
OnHttpQuerySnsFriendListRes(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.QueryDbSnsFriendAccountRes:
|
||
|
OnQueryDbSnsFriendAccountRes(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.QuerySnsFriendAccountReq:
|
||
|
OnQuerySnsFriendAccountReq(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.GcmGooglePushInfo:
|
||
|
OnGcmGooglePushInfo(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.QueryUidByFbuseridReq:
|
||
|
OnQueryUidByFbuseridReq(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.QueryUidByFbuseridRes:
|
||
|
OnQueryUidByFbuseridRes(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.QueryUidByWxidReq:
|
||
|
OnQueryUidByWxidReq(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.QueryUidByWxidRes:
|
||
|
OnQueryUidByWxidRes(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.ChangeFacebookUidDbRes:
|
||
|
OnChangeFacebookUidDbRes(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)CSMsgID.UpdateAccountGradeReq:
|
||
|
OnUpdateAccountGradeReq(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)SSMsgID.UpdateAccountGradeDbRes:
|
||
|
OnUpdateAccountGradeDbRes(remoteAppID, packet);
|
||
|
break;
|
||
|
case (int)CSGameMsgID.DownloadResourceReq:
|
||
|
OnDownloadResourceReq(remoteAppID, packet);
|
||
|
break;
|
||
|
default:
|
||
|
TraceLog.Error("AccountMsgHandler unknow MsgID {0}", packet.MsgID);
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
private void OnHttpQuerySnsFriendListRes(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref SSQueryHttpSnsFriendListRes httpSnsFriendListRes = ref packet.GetMessage<SSQueryHttpSnsFriendListRes>();
|
||
|
|
||
|
AccountInfoOnAccountServer accountInfo = AccountServerUtils.GetAccountTableOp().GetAccountInfo(
|
||
|
httpSnsFriendListRes.Account.AccountType
|
||
|
, httpSnsFriendListRes.Account.AccountID.GetString());
|
||
|
|
||
|
if (accountInfo == null)
|
||
|
{
|
||
|
TraceLog.Error("OnHttpQuerySnsFriendListRes can not find account info in memory ,type {0} id {1}"
|
||
|
, httpSnsFriendListRes.Account.AccountType
|
||
|
, httpSnsFriendListRes.Account.AccountID);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
string myAccountKey = AccountUtils.CalcAccountKey(accountInfo.AccountType, accountInfo.AccountID);
|
||
|
|
||
|
if (accountInfo.SnsFriendList == null)
|
||
|
{
|
||
|
accountInfo.SnsFriendList = new List<string>();
|
||
|
}
|
||
|
|
||
|
bool isDirty = false;
|
||
|
if (httpSnsFriendListRes.Friends.GetCount() > 0)
|
||
|
{
|
||
|
SnsFriendCacheOp friendCacheOp = AccountServerUtils.GetSnsFriendCacheOp();
|
||
|
|
||
|
for(int i = 0; i < httpSnsFriendListRes.Friends.Count; i++)
|
||
|
{
|
||
|
ref SnsFriendInfoAccount oneFriendInfo = ref httpSnsFriendListRes.Friends[i];
|
||
|
string accountKey = AccountUtils.CalcAccountKey(
|
||
|
oneFriendInfo.AccountType, oneFriendInfo.AccountID.GetString());
|
||
|
|
||
|
if(accountInfo.SnsFriendList.Contains(accountKey) == false)
|
||
|
{
|
||
|
accountInfo.SnsFriendList.Add(accountKey);
|
||
|
isDirty = true;
|
||
|
TraceLog.Trace("OnHttpQuerySnsFriendListRes add one friend type {0} id {1} to SnsFriendList in accountInfo type {2} id {3}"
|
||
|
, oneFriendInfo.AccountType
|
||
|
, oneFriendInfo.AccountID
|
||
|
, accountInfo.AccountType
|
||
|
, accountInfo.AccountID);
|
||
|
}
|
||
|
|
||
|
if(friendCacheOp.NeedQuerySnsFriendInfoFromDB(accountKey))
|
||
|
{
|
||
|
TraceLog.Trace("no account type {0} id {1}in snsFriendInfoCache,query from db"
|
||
|
, oneFriendInfo.AccountType
|
||
|
, oneFriendInfo.AccountID);
|
||
|
|
||
|
SSQueryDBSnsFriendAccountReq queryDBSnsFriendReq = new SSQueryDBSnsFriendAccountReq();
|
||
|
queryDBSnsFriendReq.AccountType = oneFriendInfo.AccountType;
|
||
|
queryDBSnsFriendReq.AccountID = oneFriendInfo.AccountID;
|
||
|
|
||
|
uint iDBServerID = DBServerSelect.GetDBServerID(queryDBSnsFriendReq.AccountType, queryDBSnsFriendReq.AccountID.GetString());
|
||
|
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID(iDBServerID
|
||
|
, (int)SSMsgID.QueryDbSnsFriendAccountReq
|
||
|
, ref queryDBSnsFriendReq
|
||
|
, packet.ObjectID);
|
||
|
}
|
||
|
|
||
|
AccountInfoOnAccountServer friendAccountInfo = AccountServerUtils.GetAccountTableOp().GetAccountInfo(
|
||
|
oneFriendInfo.AccountType, oneFriendInfo.AccountID.GetString());
|
||
|
|
||
|
/// 我是不是在对方的好友列表里,不是的话,需要把我加到对方的好友列表
|
||
|
/// 这种情况完全有可能,比如是他先登录的,我还没注册游戏,后来我注册游戏了,他会在我的好友列表,但是我不在他的好友列表
|
||
|
if (friendAccountInfo != null
|
||
|
&& friendAccountInfo.SnsFriendList != null
|
||
|
&& friendAccountInfo.SnsFriendList.Contains(myAccountKey) == false)
|
||
|
{
|
||
|
TraceLog.Debug("myaccountKey {0} not in his accountKey {1} friend list,so here we need add me to his friend list"
|
||
|
, myAccountKey, accountKey);
|
||
|
|
||
|
friendAccountInfo.SnsFriendList.Add(myAccountKey);
|
||
|
|
||
|
SnsFriendInfoAccountObj snsFriendInfoInCache = friendCacheOp.GetSnsFriendInfo(myAccountKey);
|
||
|
if (snsFriendInfoInCache == null)
|
||
|
{
|
||
|
snsFriendInfoInCache = friendCacheOp.AddNewSnsFriendInfo(accountInfo.AccountType, accountInfo.AccountID);
|
||
|
}
|
||
|
|
||
|
//snsFriendInfoInCache.Info.Uid = accountInfo.GameID;
|
||
|
snsFriendInfoInCache.Info.Gender = accountInfo.Gender;
|
||
|
snsFriendInfoInCache.Info.Icon.SetString(accountInfo.Icon);
|
||
|
snsFriendInfoInCache.Info.Nick.SetString(accountInfo.Nick);
|
||
|
|
||
|
//通知world , friend 这个人 多了一个好友(就是我),
|
||
|
//world自己处理了不对称问题,所有这个消息其实必要性不大
|
||
|
if(friendAccountInfo.WorldServerID != 0)
|
||
|
{
|
||
|
NotifyWorldSyncAddFriend(friendAccountInfo, snsFriendInfoInCache);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void NotifyWorldSyncAddFriend(AccountInfoOnAccountServer accountInfo, SnsFriendInfoAccountObj friend)
|
||
|
{
|
||
|
if (accountInfo.WorldServerID == 0)
|
||
|
{
|
||
|
TraceLog.Error("NotifyWorldSyncAddFriend account info in memory ,type {0} id {1} no worldserverid"
|
||
|
, accountInfo.AccountType
|
||
|
, accountInfo.AccountID);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
SSSnsFriendSyncAddFriend sync = new SSSnsFriendSyncAddFriend();
|
||
|
//sync.Uid = accountInfo.GameID;
|
||
|
sync.Friend = friend.Info;
|
||
|
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID(accountInfo.WorldServerID
|
||
|
, (int)SSMsgID.SnsFriendSyncAddFriend
|
||
|
, ref sync
|
||
|
, 0/*accountInfo.GameID*/);
|
||
|
}
|
||
|
|
||
|
private void OnQueryDbSnsFriendAccountRes(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref SSQueryDBSnsFriendAccountRes res = ref packet.GetMessage<SSQueryDBSnsFriendAccountRes>();
|
||
|
|
||
|
TraceLog.Trace("OnQueryDbSnsFriendAccountRes type {0} id {1} uid {2}", res.AccountType, res.AccountID, res.Uid);
|
||
|
|
||
|
//这个表示查询失败了
|
||
|
//失败了也不返回
|
||
|
if(res.Uid == 0)
|
||
|
{
|
||
|
TraceLog.Error("OnQueryDbSnsFriendAccountRes type {0} id {1} uid {2},no info in db", res.AccountType, res.AccountID, res.Uid);
|
||
|
}
|
||
|
|
||
|
SnsFriendCacheOp friendCacheOp = AccountServerUtils.GetSnsFriendCacheOp();
|
||
|
|
||
|
string accountKey = AccountUtils.CalcAccountKey(res.AccountType, res.AccountID.GetString());
|
||
|
|
||
|
SnsFriendInfoAccountObj snsFriendInfoInCache = friendCacheOp.GetSnsFriendInfo(accountKey);
|
||
|
if (snsFriendInfoInCache == null)
|
||
|
{
|
||
|
snsFriendInfoInCache = friendCacheOp.AddNewSnsFriendInfo(res.AccountType, res.AccountID.GetString());
|
||
|
}
|
||
|
|
||
|
snsFriendInfoInCache.LastQueryDBTime = AppTime.GetNowSysMs();
|
||
|
|
||
|
if (res.Uid > 0)
|
||
|
{
|
||
|
snsFriendInfoInCache.Info.Uid = res.Uid;
|
||
|
snsFriendInfoInCache.Info.Gender = res.Gender;
|
||
|
snsFriendInfoInCache.Info.Icon = res.Icon;
|
||
|
snsFriendInfoInCache.Info.Nick = res.Nick;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//world来的消息
|
||
|
private void OnQuerySnsFriendAccountReq(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref SSQuerySnsFriendAccountReq req = ref packet.GetMessage<SSQuerySnsFriendAccountReq>();
|
||
|
|
||
|
AccountInfoOnAccountServer accountInfo = AccountServerUtils.GetAccountTableOp().GetAccountInfo(
|
||
|
req.AccountType
|
||
|
, req.AccountID.GetString());
|
||
|
|
||
|
if (accountInfo == null)
|
||
|
{
|
||
|
TraceLog.Error("OnQuerySnsFriendAccountReq can not find account info in memory ,type {0} id {1}"
|
||
|
, req.AccountType
|
||
|
, req.AccountID);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
AckWorkdSSQuerySnsFriendAccountRes(accountInfo);
|
||
|
}
|
||
|
|
||
|
private void OnGcmGooglePushInfo(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var data = ref packet.GetMessage<SSGoogleFirebasePush>();
|
||
|
|
||
|
uint httpproxyID = HttpProxySelect.GetHttpProxyIDTurns();
|
||
|
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID(httpproxyID,(int)SSMsgID.GcmGooglePushInfo,ref data,0);
|
||
|
}
|
||
|
|
||
|
private void AckWorkdSSQuerySnsFriendAccountRes(AccountInfoOnAccountServer accountInfo)
|
||
|
{
|
||
|
if (accountInfo.SnsFriendList == null)
|
||
|
{
|
||
|
TraceLog.Error("OnQuerySnsFriendAccountReq can not find SnsFriendList in account info in memory ,type {0} id {1}"
|
||
|
, accountInfo.AccountType
|
||
|
, accountInfo.AccountID);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if(accountInfo.WorldServerID == 0)
|
||
|
{
|
||
|
TraceLog.Error("OnQuerySnsFriendAccountReq account info in memory ,type {0} id {1} no worldserverid"
|
||
|
, accountInfo.AccountType
|
||
|
, accountInfo.AccountID);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
ref SSQuerySnsFriendAccountRes res = ref CSStructPool<SSQuerySnsFriendAccountRes>.Instance.GetObjRef();
|
||
|
//res.Uid = accountInfo.GameID;
|
||
|
res.AccountID.SetString(accountInfo.AccountID);
|
||
|
res.AccountType = accountInfo.AccountType;
|
||
|
|
||
|
SnsFriendCacheOp friendCacheOp = AccountServerUtils.GetSnsFriendCacheOp();
|
||
|
|
||
|
foreach (var friendAccountKey in accountInfo.SnsFriendList)
|
||
|
{
|
||
|
SnsFriendInfoAccountObj snsFriendInfoInCache = friendCacheOp.GetSnsFriendInfo(friendAccountKey);
|
||
|
if (snsFriendInfoInCache != null && snsFriendInfoInCache.Info.Uid > 0)
|
||
|
{
|
||
|
res.Friends.Add(snsFriendInfoInCache.Info);
|
||
|
|
||
|
TraceLog.Trace("OnQuerySnsFriendAccountReq add friend id {0} to id {1} uid {2}"
|
||
|
, snsFriendInfoInCache.Info.AccountID
|
||
|
, accountInfo.AccountID
|
||
|
,0 /*accountInfo.GameID*/);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID(
|
||
|
accountInfo.WorldServerID
|
||
|
, (int)SSMsgID.QuerySnsFriendAccountRes
|
||
|
, ref res
|
||
|
,0 /*accountInfo.GameID*/);
|
||
|
}
|
||
|
|
||
|
private void OnQueryUidByFbuseridReq(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var req = ref packet.GetMessage<SSQueryUidByFbuseridReq>();
|
||
|
|
||
|
//转给db处理
|
||
|
uint iDBServerID = DBServerSelect.GetDBServerID((int)AccountType.AccountType_Facebook, req.Fbuserid.GetString());
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID<SSQueryUidByFbuseridReq>(iDBServerID, packet);
|
||
|
}
|
||
|
|
||
|
private void OnQueryUidByFbuseridRes(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var res = ref packet.GetMessage<SSQueryUidByFbuseridRes>();
|
||
|
//转给world
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID<SSQueryUidByFbuseridRes>(res.WorldServerID, packet);
|
||
|
}
|
||
|
private void OnQueryUidByWxidReq(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var req = ref packet.GetMessage<SSQueryUidByWXIDReq>();
|
||
|
|
||
|
//转给db处理
|
||
|
uint iDBServerID = DBServerSelect.GetDBServerID((int)AccountType.AccountType_WX, req.Wxid.GetString());
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID<SSQueryUidByWXIDReq>(iDBServerID, packet);
|
||
|
}
|
||
|
|
||
|
private void OnQueryUidByWxidRes(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var res = ref packet.GetMessage<SSQueryUidByWXIDRes>();
|
||
|
//转给world
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID<SSQueryUidByWXIDRes>(res.WorldServerID, packet);
|
||
|
}
|
||
|
private void OnChangeFacebookUidDbRes(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var res = ref packet.GetMessage<SSChangeFacebookUidDbRes>();
|
||
|
|
||
|
TraceLog.Debug("OnChangeFacebookUidDbRes type {0} id {1} realm {2} new uid {3} ret {4}"
|
||
|
, res.AccountType, res.AccountID, res.RealmId, res.Uid, res.Ret);
|
||
|
|
||
|
if (res.Ret != 0)
|
||
|
{
|
||
|
TraceLog.Error("OnChangeFacebookUidDbRes failed, type {0} id {1} realm {2} new uid {3}"
|
||
|
, res.AccountType, res.AccountID, res.RealmId, res.Uid);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
//AccountInfoOnAccountServer accountInfo = AccountServerUtils.GetAccountTableOp().GetAccountInfo(
|
||
|
// res.AccountType, res.AccountID.GetString());
|
||
|
|
||
|
//if (accountInfo != null)
|
||
|
//{
|
||
|
// //long oldUid = accountInfo.GameID;
|
||
|
// //accountInfo.GameID = res.Uid;
|
||
|
// TraceLog.Debug("OnChangeFacebookUidDbRes type {0} id {1} uid {2}, update AccountInfo obj Uid success old uid {3}"
|
||
|
// , res.AccountType, res.AccountID, res.Uid,0 /*oldUid*/);
|
||
|
//}
|
||
|
|
||
|
//string accountKey = AccountUtils.CalcAccountKey(res.AccountType, res.AccountID.GetString());
|
||
|
|
||
|
//SnsFriendCacheOp friendCacheOp = AccountServerUtils.GetSnsFriendCacheOp();
|
||
|
//SnsFriendInfoAccountObj snsFriendInfoInCache = friendCacheOp.GetSnsFriendInfo(accountKey);
|
||
|
//if (snsFriendInfoInCache != null)
|
||
|
//{
|
||
|
// long oldUid = snsFriendInfoInCache.Info.Uid;
|
||
|
// snsFriendInfoInCache.Info.Uid = res.Uid;
|
||
|
// TraceLog.Debug("OnChangeFacebookUidDbRes type {0} id {1} uid {2}, update SnsFriendInfoAccountObj Uid success old uid {3}"
|
||
|
// , res.AccountType, res.AccountID, res.Uid, oldUid);
|
||
|
//}
|
||
|
}
|
||
|
|
||
|
private void OnUpdateAccountGradeReq(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var req = ref packet.GetMessage<CSUpdateAccountGradeReq>();
|
||
|
|
||
|
string accId_type = req.AccountID.GetString();
|
||
|
string[] accIdtypeArray = accId_type.Split('|');
|
||
|
if(accIdtypeArray.Length != 2)
|
||
|
{
|
||
|
TraceLog.Error("OnUpdateAccountGradeReq accountInfo is null, uid {0} AccountID : {1} ", req.Uid, req.AccountID);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
string accountId = accIdtypeArray[0];
|
||
|
int accountType = int.Parse(accIdtypeArray[1]);
|
||
|
|
||
|
AccountInfoOnAccountServer accountInfo = AccountServerUtils.GetAccountTableOp().GetAccountInfo(
|
||
|
accountType, accountId);
|
||
|
|
||
|
if (accountInfo == null)
|
||
|
{
|
||
|
TraceLog.Error("OnUpdateAccountGradeReq accountInfo is null, uid {0} type {1} accountID : {2} ", req.Uid, accountType, accountId);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// 写入db
|
||
|
var dbReq = new SSUpdateAccountGradeDbReq();
|
||
|
dbReq.AccountInfo.AccountID.SetString(accountInfo.AccountID);
|
||
|
dbReq.AccountInfo.AccountToken.SetString(accountInfo.AccountToken);
|
||
|
dbReq.AccountInfo.AccountType = accountInfo.AccountType;
|
||
|
dbReq.AccountInfo.PlatformType = accountInfo.PlatformType;
|
||
|
dbReq.Grade = req.Grade;
|
||
|
dbReq.IsExData = false;
|
||
|
accountInfo.userGrade = req.Grade;
|
||
|
|
||
|
uint iDBServerID = DBServerSelect.GetDBServerID(accountInfo.AccountType, accountInfo.AccountID);
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID<SSUpdateAccountGradeDbReq>(iDBServerID, (int)SSMsgID.UpdateAccountGradeDbReq, ref dbReq, packet.ObjectID);
|
||
|
}
|
||
|
|
||
|
private void OnUpdateAccountGradeDbRes(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var req = ref packet.GetMessage<SSUpdateAccountGradeDbRes>();
|
||
|
if (req.IsExData)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
var csRes = new CSUpdateAccountGradeRes();
|
||
|
|
||
|
AccountInfoOnAccountServer accountInfo = AccountServerUtils.GetAccountTableOp().GetAccountInfo(req.AccountInfo.AccountType, req.AccountInfo.AccountID.GetString());
|
||
|
if(accountInfo == null)
|
||
|
{
|
||
|
TraceLog.Error("AccountMsgHandler.OnUpdateAccountGradeDbRes: Get accountInfo faild! AccountType:{0}, AccountID:{1}",
|
||
|
req.AccountInfo.AccountType,
|
||
|
req.AccountInfo.AccountID.GetString());
|
||
|
return;
|
||
|
}
|
||
|
csRes.Ret = req.Ret;
|
||
|
|
||
|
// 转发给 world
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID(accountInfo.WorldServerID,
|
||
|
(int)CSMsgID.UpdateAccountGradeRes, ref csRes, 0/*, accountInfo.GameID*/);
|
||
|
}
|
||
|
private void OnDownloadResourceReq(uint remoteAppID, StructPacket packet)
|
||
|
{
|
||
|
ref var req = ref packet.GetMessage<CSDownLoadResourceReq>();
|
||
|
|
||
|
AccountInfoOnAccountServer accountInfo = AccountServerUtils.GetAccountTableOp().GetAccountInfo(
|
||
|
req.AccountType, req.AccountId.GetString());
|
||
|
|
||
|
if (accountInfo == null)
|
||
|
{
|
||
|
TraceLog.Error("OnDownloadResourceReq accountInfo is null, uid {0} AccountID : {1} ", packet.ObjectID, req.AccountId);
|
||
|
return;
|
||
|
}
|
||
|
var res = new CSDownLoadResourceRes();
|
||
|
res.OpType = req.OpType;
|
||
|
res.DownloadId = req.DownloadId;
|
||
|
switch (req.OpType)
|
||
|
{
|
||
|
case DownLoadResourceOpType.SetFinish:
|
||
|
case DownLoadResourceOpType.Getreward:
|
||
|
{
|
||
|
//更新进度数据
|
||
|
if (req.DownloadId == 0)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
bool findid = false;
|
||
|
for (int i = 0; i < accountInfo.accountExData.DownloadResource.Count; i++)
|
||
|
{
|
||
|
if(accountInfo.accountExData.DownloadResource[i] == req.DownloadId)
|
||
|
{
|
||
|
findid = true;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
if (!findid)
|
||
|
{
|
||
|
if (accountInfo.accountExData.DownloadResource.Count >= accountInfo.accountExData.DownloadResource.GetMaxCount())
|
||
|
{
|
||
|
TraceLog.Error("OnDownloadResourceReq accountInfo uid {0} DownloadResource is max count", packet.ObjectID);
|
||
|
return;//最大限制
|
||
|
}
|
||
|
accountInfo.accountExData.DownloadResource.Add(req.DownloadId);
|
||
|
//保存db
|
||
|
var dbReq = new SSUpdateAccountGradeDbReq();
|
||
|
dbReq.AccountInfo.AccountID.SetString(accountInfo.AccountID);
|
||
|
dbReq.AccountInfo.AccountToken.SetString(accountInfo.AccountToken);
|
||
|
dbReq.AccountInfo.AccountType = accountInfo.AccountType;
|
||
|
dbReq.AccountInfo.PlatformType = accountInfo.PlatformType;
|
||
|
dbReq.ExData.CopyFrom(ref accountInfo.accountExData);
|
||
|
dbReq.IsExData = true;
|
||
|
|
||
|
uint iDBServerID = DBServerSelect.GetDBServerID(accountInfo.AccountType, accountInfo.AccountID);
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID<SSUpdateAccountGradeDbReq>(iDBServerID, (int)SSMsgID.UpdateAccountGradeDbReq, ref dbReq, packet.ObjectID);
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
res.DownloadResource.CopyFrom(ref accountInfo.accountExData.DownloadResource);
|
||
|
// 发给 world => game
|
||
|
AccountServerUtils.GetPacketSender().SendToServerByID(accountInfo.WorldServerID,
|
||
|
(int)CSGameMsgID.DownloadResourceRes, ref res, packet.ObjectID);
|
||
|
}
|
||
|
}
|
||
|
}
|