本文整理汇总了C#中Game.Base.Packets.GSPacketIn.WriteHeader方法的典型用法代码示例。如果您正苦于以下问题:C# GSPacketIn.WriteHeader方法的具体用法?C# GSPacketIn.WriteHeader怎么用?C# GSPacketIn.WriteHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Base.Packets.GSPacketIn
的用法示例。
在下文中一共展示了GSPacketIn.WriteHeader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WritePacket_
public void WritePacket_(GSPacketIn pkg)
{
pkg.WriteHeader();
Write(pkg.Buffer, 0, pkg.Length);
}
示例2: OnRecvPacket
/// <summary>
/// 收到协议包
/// </summary>
/// <param name="pkg"></param>
public override void OnRecvPacket(GSPacketIn pkg)
{
if (m_packetProcessor == null)
{
m_packetLib = AbstractPacketLib.CreatePacketLibForVersion(1, this);
m_packetProcessor = new PacketProcessor(this);
}
if (m_player != null)
{
pkg.ClientID = m_player.PlayerId;
pkg.WriteHeader();
}
//LogMsg(Marshal.ToHexDump("recevie:", pkg.Buffer, 0, pkg.Length));
m_packetProcessor.HandlePacket(pkg);
}
示例3: WritePacket
public void WritePacket(GSPacketIn content)
{
content.WriteHeader();
WriteShort((short)content.Length);
WriteShort(0);
Write(content.Buffer, 2, content.Length - 2);
}
示例4: SendTCP
public void SendTCP(GSPacketIn packet)
{
//Fix the packet size
packet.WriteHeader();
//reset the offset for read
packet.Offset = 0;
//Check if client is connected
if (m_client.Socket.Connected)
{
try
{
Statistics.BytesOut += packet.Length;
Statistics.PacketsOut++;
if (log.IsDebugEnabled)
{
log.Debug(Marshal.ToHexDump(string.Format("Send Pkg to {0} :", m_client.TcpEndpoint), packet.Buffer, 0, packet.Length));
}
lock (m_tcpQueue.SyncRoot)
{
m_tcpQueue.Enqueue(packet);
if (m_sendingTcp)
{
return;
}
else
{
m_sendingTcp = true;
}
}
if (m_client.AsyncPostSend)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(AsyncSendTcpImp), this);
}
else
{
AsyncTcpSendCallback(this, send_event);
}
}
catch (Exception e)
{
log.Error("SendTCP", e);
log.WarnFormat("It seems <{0}> went linkdead. Closing connection. (SendTCP, {1}: {2})", m_client, e.GetType(), e.Message);
m_client.Disconnect();
}
}
}