private void WritePacket(IDataWriter writer, int id) { byte[] packet = writer.Data; writer.Clear(); byte typeLen = ComputeTypeLen(packet.Length); var header = (short)SubComputeStaticHeader((uint)id, typeLen); writer.WriteShort(header); switch (typeLen) { case 0: break; case 1: writer.WriteByte((byte)packet.Length); break; case 2: writer.WriteShort((short)packet.Length); break; case 3: writer.WriteByte((byte)(packet.Length >> 16 & 255)); writer.WriteShort((short)(packet.Length & 65535)); break; default: throw new System.Exception("Packet's length can't be encoded on 4 or more bytes"); } writer.WriteBytes(packet); }
public void WritePacket(IDataWriter output) { byte[] data = output.Data; output.Clear(); var typeLen = ComputeTypeLen((uint)data.Length); output.WriteShort((short)SubComputeStaticHeader(Id, typeLen)); switch (typeLen) { case 0: return; case 1: output.WriteByte((byte)data.Length); break; case 2: output.WriteShort((short)data.Length); break; case 3: output.WriteByte((byte)(data.Length >> 16 & 255)); output.WriteShort((short)(data.Length & 65535)); break; } output.WriteBytes(data); }
private void WritePacket(IDataWriter writer) { var data = writer.Data; writer.Clear(); var num = ComputeTypeLen(data.Length); var num1 = SubComputeStaticHeader(MessageID, num); writer.WriteShort((short)num1); writer.WriteUInt(MessageUtils.InstanceId++); switch (num) { case 0: break; case 1: writer.WriteByte((byte)data.Length); break; case 2: writer.WriteShort((short)data.Length); break; case 3: writer.WriteByte((byte)((data.Length >> 16) & 255)); writer.WriteShort((short)(data.Length & 65535)); break; default: throw new Exception("Packet's length can't be encoded on 4 or more bytes"); } writer.WriteBytes(data); }
private void WritePacket(IDataWriter writer) { byte[] packet = writer.Data; writer.Clear(); byte typeLen = ComputeTypeLen(packet.Length); var header = (short) SubComputeStaticHeader(MessageId, typeLen); writer.WriteShort(header); switch (typeLen) { case 0: break; case 1: writer.WriteByte((byte) packet.Length); break; case 2: writer.WriteShort((short) packet.Length); break; case 3: writer.WriteByte((byte) (packet.Length >> 16 & 255)); writer.WriteShort((short) (packet.Length & 65535)); break; default: throw new Exception("Packet's length can't be encoded on 4 or more bytes"); } writer.WriteBytes(packet); }
private void WritePacket(IDataWriter packet) { byte[] data = packet.Data; packet.Clear(); uint typeLen = PacketLength((uint)data.Length); packet.WriteShort((short)SubComputeStaticHeader(MessageId, typeLen)); switch (typeLen) { case 0: return; case 1: packet.WriteByte((byte)data.Length); break; case 2: packet.WriteShort((short)data.Length); break; case 3: packet.WriteByte((byte)(data.Length >> 16 & 255)); packet.WriteShort((short)(data.Length & 65535)); break; } packet.WriteBytes(data); }
public void Clear() { _data.Clear(); }