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.
 
 
 
 
 
 

90 lines
2.4 KiB

using Sog;
using ProtoCSStruct;
namespace World
{
/// <summary>
/// 好友在线状态
/// </summary>
public static class FriendStatusSvc
{
public static void OnQueryFriendStatusReq(uint remoteAppID, StructPacket packet)
{
ref var req = ref packet.GetMessage<CSQueryFriendStatusReq>();
TraceLog.Debug("FriendStatusSvc.OnQueryFriendStatusReq uid {0} query count {1}"
, packet.ObjectID, req.Uids.Count);
var res = new CSQueryFriendStatusRes();
int count = 0;
for (int i = 0; i < req.Uids.Count; i++)
{
if (count >= 100)
{
break;
}
count++;
CSFriendOneStatus oneStatus = new CSFriendOneStatus();
oneStatus.Uid = req.Uids[i];
var player = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(oneStatus.Uid);
if (player != null && player.IsOnline)
{
oneStatus.Status = 1; //在线
}
else
{
oneStatus.Status = 0; //不在线
}
res.Friends.Add(ref oneStatus);
}
WorldServerUtils.GetPacketSender().SendToServerByID(remoteAppID, (int)CSGameMsgID.QueryFriendStatusRes, ref res, packet.ObjectID);
}
//game发给world要查玩家详细信息
public static void OnQueryOtherDetailReq(uint serverID, StructPacket packet)
{
PlayerInfoWorld player = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(packet.ObjectID);
if (player == null)
{
TraceLog.Error("FriendStatusSvc.OnQueryOtherDetailReq player {0} = null", packet.ObjectID);
return;
}
ref var req = ref packet.GetMessage<CSQueryOtherDetailReq>();
var res = new CSQueryOtherDetailRes { TargetUid = req.TargetUid };
//如果是机器人,则直接赋值并且回包
if (req.TargetUid < 10000)
{
res.HideInfo = 1;
var robot = WorldServerUtils.GetPlayerTableOp().GetPlayerInfo(req.TargetUid);
if (robot != null)
{
res.Ret = 0;
res.Nick = robot.roleBase.Nick;
res.Icon = robot.roleBase.Icon;
res.Level = robot.roleBase.Level;
res.Chip = robot.roleBase.Chip;
res.Diamond = robot.roleBase.Diamond;
}
else
{
TraceLog.Error("FriendStatusSvc.OnQueryOtherDetailReq robot {0} not in table", req.TargetUid);
}
WorldServerUtils.GetPacketSender().SendToServerByID(serverID, (int)CSGameMsgID.QueryOtherDetailRes, ref res, packet.ObjectID);
}
else
{
//不是机器人发给friend
WorldServerUtils.GetPacketSender().SendToFriendServer<CSQueryOtherDetailReq>(packet, player.UserID);
}
}
}
}