Exemple #1
0
        static void PacketManipulationDemo()
        {
            Console.WriteLine("Packet manipulation test/demo... should print 3 2 1...");
            using (ENet.Packet packet = new ENet.Packet())
            {
                packet.Initialize(new byte[0]);
                packet.Add((byte)1);
                packet.Insert(0, (byte)3);
                packet.Insert(1, (byte)2);
                packet.Insert(packet.IndexOf((byte)3), 4);
                packet.Remove(1);
                packet.RemoveAt(0);
                if (packet.Contains(3))
                {
                    packet.Add((byte)1);
                }
                if (packet.Contains(4))
                {
                    packet.Add((byte)5);
                }

                byte[] bytes = packet.GetBytes();
                for (int i = 0; i < bytes.Length; i++)
                {
                    Console.WriteLine(bytes[i]);
                }
            }
        }
Exemple #2
0
 public override int GetBytesCount()
 {
     return(packet.GetBytes().Length);
 }
Exemple #3
0
        static void PacketManipulationDemo()
        {
            Console.WriteLine("Packet manipulation test/demo... should print 3 2 1...");
            using (ENet.Packet packet = new ENet.Packet())
            {
                packet.Initialize(new byte[0]);
                packet.Add((byte)1);
                packet.Insert(0, (byte)3);
                packet.Insert(1, (byte)2);
                packet.Insert(packet.IndexOf((byte)3), 4);
                packet.Remove(1);
                packet.RemoveAt(0);
                if (packet.Contains(3)) { packet.Add((byte)1); }
                if (packet.Contains(4)) { packet.Add((byte)5); }

                byte[] bytes = packet.GetBytes();
                for (int i = 0; i < bytes.Length; i++)
                {
                    Console.WriteLine(bytes[i]);
                }
            }
        }