本文整理汇总了C#中Aura.Shared.Network.Packet.Build方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.Build方法的具体用法?C# Packet.Build怎么用?C# Packet.Build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aura.Shared.Network.Packet
的用法示例。
在下文中一共展示了Packet.Build方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildPacket
protected override byte[] BuildPacket(Packet packet)
{
var packetSize = packet.GetSize();
// Calculate header size
var headerSize = 3;
int n = packetSize;
do { headerSize++; n >>= 7; } while (n != 0);
// Write header
var result = new byte[headerSize + packetSize];
result[0] = 0x55;
result[1] = 0x12;
result[2] = 0x00;
// Length
var ptr = 3;
n = packetSize;
do
{
result[ptr++] = (byte)(n > 0x7F ? (0x80 | (n & 0xFF)) : n & 0xFF);
n >>= 7;
}
while (n != 0);
// Write packet
packet.Build(ref result, ptr);
return result;
}
示例2: BuildPacket
protected override byte[] BuildPacket(Packet packet)
{
var result = new byte[6 + packet.GetSize() + 4]; // header + packet + checksum
result[0] = 0x88;
System.Buffer.BlockCopy(BitConverter.GetBytes(result.Length), 0, result, 1, sizeof(int));
packet.Build(ref result, 6);
return result;
}
示例3: PutBin
/// <summary>Writes packet as bin and the length of it as int to buffer.</summary>
public Packet PutBin(Packet packet)
{
var val = packet.Build(false);
return this.PutInt(val.Length).PutBin(val);
}
示例4: Send
/// <summary>
/// Builds buffer from packet and sends it.
/// </summary>
/// <param name="packet"></param>
public virtual void Send(Packet packet)
{
// Don't log internal packets
//if (packet.Op < Op.Internal.ServerIdentify)
// Log.Debug("S: " + packet);
this.Send(packet.Build());
}