Beispiel #1
0
 public static Packet FromBytes(byte[] b)
 {
     if (b.Length <= 4) return new Packet();
     Packet p = new Packet();
     int length = BitConverter.ToInt32(b, 0);
     p.Type = BitConverter.ToInt32(b, 4);
     byte[] buffer = new byte[length - 8];
     Buffer.BlockCopy(b, 8, buffer, 0, length - 8);
     p.Bytes.AddRange(buffer);
     return p;
 }
Beispiel #2
0
 public virtual void SendPacket(Packet p, int offset = 0)
 {
     SendBytes(p.ToBytes(), offset);
 }
Beispiel #3
0
 public virtual void HandlePacket(GameTime gameTime, Packet p)
 {
     HandledPackets++;
 }
Beispiel #4
0
 public Packet DeepClone()
 {
     Packet p = new Packet(Type);
     p.Bytes = new List<byte>();
     p.Bytes.AddRange(Bytes.ToArray());
     return p;
 }
Beispiel #5
0
 public void AddPacket(Packet p)
 {
     AddBytes(p.Bytes.ToArray());
 }