public byte[] Compile() { if (_Buffer != null) { return(_Buffer); } if (Stream == null) { Console.WriteLine("{0}: {1}: Bad Packet: Stream is null", GetType().Name, ID); return(_Buffer = _EmptyBuffer); } using (Stream) { Stream.Position = MinSize - 4; Stream.Write(Stream.Length); Stream.Position = Stream.Length; if (_Buffer == null) { _Buffer = Stream.ToArray(); } Stream.Close(); Stream = null; } return(_Buffer); }
protected PortalPacket(ushort packetID, int size) { ID = packetID; ClientID = Portal.ClientID; _Stream = new PortalPacketWriter(ID, ClientID, size); }
protected PortalPacket(ushort packetID) { ClientID = Portal.ClientID; ID = packetID; Stream = new PortalPacketWriter(ID, ClientID); }
protected PortalPacket(byte packetID, ushort length) { ClientID = Portal.ClientID; ID = packetID; Length = length; Stream = new PortalPacketWriter(ID, ClientID, Length); }
public void Dispose() { lock (_SyncRoot) { if (_Stream != null) { _Stream.Dispose(); _Stream = null; } } }
public byte[] Compile() { if (_Buffer != null) { return(_Buffer); } if (Stream == null) { Console.WriteLine("{0}: {1}: Bad Packet: Stream is null", GetType().Name, ID); return(_Buffer = _EmptyBuffer); } using (Stream) { if (Length == 0) { Stream.Position = 3; Stream.Write(Stream.Length); } else if (Stream.Length != Length) { var diff = Stream.Length - Length; Console.WriteLine( "{0}: {1}: Bad Packet Length: {2}{3} bytes", GetType().Name, ID, diff > 0 ? "+" : String.Empty, diff); _Buffer = _EmptyBuffer; } if (_Buffer == null) { _Buffer = Stream.ToArray(); } Stream.Close(); Stream = null; } return(_Buffer); }
public byte[] Compile() { if (_Buffer != null) { return _Buffer; } if (Stream == null) { Console.WriteLine("{0}: {1}: Bad Packet: Stream is null", GetType().Name, ID); return _Buffer = _EmptyBuffer; } using (Stream) { Stream.Position = MinSize - 4; Stream.Write(Stream.Length); Stream.Position = Stream.Length; if (_Buffer == null) { _Buffer = Stream.ToArray(); } Stream.Close(); Stream = null; } return _Buffer; }
public byte[] Compile() { if (_Buffer != null) { return _Buffer; } if (Stream == null) { Console.WriteLine("{0}: {1}: Bad Packet: Stream is null", GetType().Name, ID); return _Buffer = _EmptyBuffer; } using (Stream) { if (Length == 0) { Stream.Position = 3; Stream.Write(Stream.Length); } else if (Stream.Length != Length) { var diff = Stream.Length - Length; Console.WriteLine( "{0}: {1}: Bad Packet Length: {2}{3} bytes", GetType().Name, ID, diff > 0 ? "+" : String.Empty, diff); _Buffer = _EmptyBuffer; } if (_Buffer == null) { _Buffer = Stream.ToArray(); } Stream.Close(); Stream = null; } return _Buffer; }