Exemplo n.º 1
0
        public byte[] SerializeWithHeader(APINetworkPacket packet)
        {
            using (var ms = new MemoryStream())
                using (var writer = new BinaryWriter(ms))
                {
                    writer.Write(0);
                    writer.Write((int)packet.Type);
                    Serializer.Serialize(ms, packet);

                    ms.Position = 0;
                    writer.Write((int)ms.Length);

                    ms.Position = ms.Length;
                    return(ms.ToArray());
                }
        }
Exemplo n.º 2
0
        public byte[] SerializeWithHeader(APINetworkPacket packet)
        {
            using (var ms = new MemoryStream())
            using (var writer = new BinaryWriter(ms))
            {
                writer.Write(0);
                writer.Write((int)packet.Type);
                Serializer.Serialize(ms, packet);
                
                ms.Position = 0;
                writer.Write((int)ms.Length);

                ms.Position = ms.Length;
                return ms.ToArray();
            }
        }
Exemplo n.º 3
0
 public void SendPacket(APINetworkPacket packet)
 {                        
     SendPacket(serializer.SerializeWithHeader(packet));         
 }
Exemplo n.º 4
0
 private void OnPacketReceived(APINetworkPacket packet)
 {
     var h = PacketReceived;
     if (h != null)
         EventHandler.RiseSafely(() => h(packet));
 }