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.
 
 
 
 
 
 

193 lines
7.2 KiB

using System.Collections.Generic;
using Sog;
using Sog.Crypto;
using ProtoCSStruct;
namespace HttpProxyWorld
{
public static class MessageTaskHandler
{
//测试用,所有登录的玩家互相是好友,并且不校验token
//public static bool bTestFriend = false;
//测试用,所有登录的玩家互相是好友,并且不校验token
public static Dictionary<string, int> TestFriendAllLoginIsFriend = new Dictionary<string, int>();
public static void HandlerPacket(uint remoteAppID, StructPacket packet)
{
switch (packet.MsgID)
{
case (int)SSMsgID.GcmGooglePushInfo:
OnHttpReqGooglePushInfo(remoteAppID, packet);
break;
case (int)SSGameMsgID.PayDiamondHolderQueryReq:
OnPayDiamondHolderQueryReq(remoteAppID, packet);
break;
case (int)SSGameMsgID.PayDiamondHolderAddReq:
OnPayDiamondHolderAddReq(remoteAppID, packet);
break;
case (int)SSGameMsgID.PayDiamondHolderCostReq:
OnPayDiamondHolderCostReq(remoteAppID, packet);
break;
case (int)SSGameMsgID.PayDiamondHolderCostCancelReq:
OnPayDiamondHolderCostCancelReq(remoteAppID, packet);
break;
default:
TraceLog.Error("MessageTaskHandler.HandlerPacket unknow MsgID {0}", packet.MsgID);
break;
}
}
private static void OnHttpReqGooglePushInfo(uint remoteAppID, StructPacket packet)
{
ref var data = ref packet.GetMessage<SSGoogleFirebasePush>();
TraceLog.Debug("MessageTaskHandler.OnHttpReqGooglePushInfo remoteAppID {0} Content {1} pushid count {2}"
, remoteAppID, data.Content, data.PushIds);
if (data.PushIds.Count == 0)
{
FirebaseHttpPushSvc.PushToGlobalTopics(data.Content.GetString(),data.ParamKey.GetString(), data.ParamValue.GetString());
}
else
{
List<string> pushIds = new List<string>();
for (int i = 0; i < data.PushIds.Count; i++)
{
pushIds.Add(data.PushIds[i].GetString());
}
FirebaseHttpPushSvc.PushNotificationToIds(data.Content.GetString(), pushIds, data.ParamKey.GetString(), data.ParamValue.GetString());
}
}
private static void OnPayDiamondHolderQueryReq(uint remoteAppID, StructPacket packet)
{
ref var req = ref packet.GetMessage<SSPayDiamondHolderQueryReq>();
TraceLog.Debug("MessageTaskHandler.OnPayDiamondHolderQueryReq uid {0}"
, req.Uid);
SSPayDiamondHolderQueryRes res = new SSPayDiamondHolderQueryRes();
res.Uid = req.Uid;
int diamond = 0;
int ret = MidasApi.QueryBalance(ref req.Account, ref req.Qqpayinfo, req.RealmId, out diamond);
if (ret != 0)
{
TraceLog.Error("MessageTaskHandler.OnPayDiamondHolderQueryReq QueryBalance failed uid {0} "
, req.Uid);
}
else
{
res.Diamond = diamond;
}
//返回包
HttpProxyWorldServerUtils.GetPacketSender().SendToServerByID(remoteAppID
, (int)SSGameMsgID.PayDiamondHolderQueryRes, ref res, packet.ObjectID, packet.ServerID);
}
private static void OnPayDiamondHolderAddReq(uint remoteAppID, StructPacket packet)
{
ref var req = ref packet.GetMessage<SSPayDiamondHolderAddReq>();
TraceLog.Debug("MessageTaskHandler.OnPayDiamondHolderAddReq uid {0}"
, req.Uid);
SSPayDiamondHolderAddRes res = new SSPayDiamondHolderAddRes();
res.Uid = req.Uid;
res.Account = req.Account;
res.Qqpayinfo = req.Qqpayinfo;
res.OrderId = req.OrderId;
res.ReasonId = req.ReasonId;
int diamond = 0;
int ret = MidasApi.PresentDiamond(ref req, out diamond);
if (ret != 0)
{
TraceLog.Error("MessageTaskHandler.OnPayDiamondHolderAddReq failed uid {0} "
, req.Uid);
}
else
{
res.NewDiamond = diamond;
}
//返回包
HttpProxyWorldServerUtils.GetPacketSender().SendToServerByID(remoteAppID
, (int)SSGameMsgID.PayDiamondHolderAddRes, ref res, packet.ObjectID, packet.ServerID);
}
private static void OnPayDiamondHolderCostReq(uint remoteAppID, StructPacket packet)
{
ref var req = ref packet.GetMessage<SSPayDiamondHolderCostReq>();
TraceLog.Debug("MessageTaskHandler.OnPayDiamondHolderCostReq uid {0}"
, req.Uid);
SSPayDiamondHolderCostRes res = new SSPayDiamondHolderCostRes();
res.Uid = req.Uid;
res.Account = req.Account;
res.Qqpayinfo = req.Qqpayinfo;
res.OrderId = req.OrderId;
int diamond = 0;
int ret = MidasApi.CostDiamond(ref req, out diamond);
if (ret != 0)
{
TraceLog.Error("MessageTaskHandler.OnPayDiamondHolderCostReq failed uid {0} "
, req.Uid);
}
else
{
res.NewDiamond = diamond;
}
//返回包
HttpProxyWorldServerUtils.GetPacketSender().SendToServerByID(remoteAppID
, (int)SSGameMsgID.PayDiamondHolderCostRes, ref res, packet.ObjectID, packet.ServerID);
}
private static void OnPayDiamondHolderCostCancelReq(uint remoteAppID, StructPacket packet)
{
ref var req = ref packet.GetMessage<SSPayDiamondHolderCostCancelReq>();
TraceLog.Debug("MessageTaskHandler.OnPayDiamondHolderCostCancelReq uid {0}"
, req.Uid);
int ret = MidasApi.CancelCostDiamond(ref req);
if (ret != 0)
{
TraceLog.Error("MessageTaskHandler.OnPayDiamondHolderCostCancelReq failed uid {0} "
, req.Uid);
return;
}
//回滚返回查询结果
SSPayDiamondHolderQueryRes res = new SSPayDiamondHolderQueryRes();
res.Uid = req.Uid;
int diamond = 0;
ret = MidasApi.QueryBalance(ref req.Account, ref req.Qqpayinfo, req.RealmId, out diamond);
if (ret != 0)
{
TraceLog.Error("MessageTaskHandler.OnPayDiamondHolderCostCancelReq QueryBalance failed uid {0} "
, req.Uid);
return;//查询失败就算了,不返回了
}
res.Diamond = diamond;
//返回查询结果包,游戏服务器需要知道最新的钻石数量
HttpProxyWorldServerUtils.GetPacketSender().SendToServerByID(remoteAppID
, (int)SSGameMsgID.PayDiamondHolderQueryRes, ref res, packet.ObjectID, packet.ServerID);
}
}
}