当前位置: 首页>>代码示例>>C#>>正文


C# Packet.Build方法代码示例

本文整理汇总了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;
		}
开发者ID:tkiapril,项目名称:aura,代码行数:30,代码来源:MsgrClient.cs

示例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;
		}
开发者ID:tkiapril,项目名称:aura,代码行数:9,代码来源:DefaultClient.cs

示例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);
 }
开发者ID:pie3467,项目名称:aura,代码行数:6,代码来源:Packet.cs

示例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());
        }
开发者ID:pie3467,项目名称:aura,代码行数:12,代码来源:BaseClient.cs


注:本文中的Aura.Shared.Network.Packet.Build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。