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.
57 lines
1.8 KiB
57 lines
1.8 KiB
/*
|
|
Sog 游戏基础库
|
|
2016 by zouwei
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
using Sog.Gate;
|
|
|
|
using ProtoCSStruct;
|
|
|
|
namespace Account
|
|
{
|
|
// 实现 SendToPlayer
|
|
public static class PlayerPacketSender
|
|
{
|
|
public static void SendToPlayer<T>(long sessionId, int iMsgID, ref T structMessage)
|
|
where T : struct, IStructMessage<T>
|
|
{
|
|
PlayerSession playerSession = AccountServerUtils.GetPlayerTableOp().GetPlayerSession(sessionId);
|
|
|
|
if (playerSession != null)
|
|
{
|
|
GateService.SendToGate(0, AccountServerUtils.GetApp().GetCluster()
|
|
, playerSession.GateServerID, playerSession.SessionID, iMsgID, ref structMessage);
|
|
}
|
|
else
|
|
{
|
|
TraceLog.Debug("PlayerPacketSender.SendToPlayer sessionId {0} no PlayerSession object!", sessionId);
|
|
}
|
|
}
|
|
|
|
public static void SendToPlayer<T>(PlayerSession playerSession, int iMsgID, ref T structMessage)
|
|
where T : struct, IStructMessage<T>
|
|
{
|
|
GateService.SendToGate(0,AccountServerUtils.GetApp().GetCluster()
|
|
,playerSession.GateServerID,playerSession.SessionID, iMsgID, ref structMessage);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 直接转发
|
|
/// </summary>
|
|
/// <param name="playerSession"></param>
|
|
/// <param name="packet"></param>
|
|
public static void SendToPlayer<T>(PlayerSession playerSession, StructPacket packet)
|
|
where T : struct, IStructMessage<T>
|
|
{
|
|
GateService.SendToGate(0,AccountServerUtils.GetApp().GetCluster()
|
|
, playerSession.GateServerID, playerSession.SessionID, packet.MsgID, ref packet.GetMessage<T>());
|
|
}
|
|
}
|
|
}
|
|
|