Exemple #1
0
        public static void Serialize(PacketBase packet, byte[] buffer)
        {
            MemoryStream ms = new MemoryStream();
            System.Text.Encoding encode = System.Text.Encoding.Unicode;
            BinaryWriter writer = new BinaryWriter(ms, encode);
            packet.Serialize(writer);

            // copy to byte[]
            writer.BaseStream.Position = 0;
            ms.Read(buffer, 0, (int)packet.len);
        }
Exemple #2
0
 // 버퍼를 패킷으로 Deserialize 해줌.
 public static void Deserialize(PacketBase packet, byte[] buffer)
 {
     MemoryStream rl_ms = new MemoryStream();
     rl_ms.Write(buffer, 0, Marshal.SizeOf(packet));
     rl_ms.Position = 0;
     BinaryReader rl_binary = new BinaryReader(rl_ms, System.Text.Encoding.Unicode);
     packet.Deserialize(rl_binary);
 }