Ejemplo n.º 1
0
 public override void Start()
 {
     if (m_conn != null &&
         !m_conn.IsRunning)
     {
         m_conn.PacketReceived += ConnectionPacketReceived;
         m_conn.Start();
     }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            byte[] before = { 0, 12, 0, 13, 0, 14 };
            byte[] after  = COBSEncoding.Encode(before);
            byte[] final  = COBSEncoding.Decode(after);

            PrintArray(before, "BEFORE");
            PrintArray(after, " AFTER");
            PrintArray(final, " FINAL");

            Console.WriteLine("--------------------------------------------");

            byte[] veryLongArray = new byte[10000];
            for (int i = 0; i < veryLongArray.Length; i++)
            {
                veryLongArray[i] = (byte)(255 * (new Random().NextDouble()));
            }

            byte[] encoded = COBSEncoding.Encode(veryLongArray);
            byte[] decoded = COBSEncoding.Encode(encoded);

            Console.WriteLine("BEFORE: " + veryLongArray.Length);
            Console.WriteLine(" AFTER: " + encoded.Length);
            Console.WriteLine(" FINAL: " + decoded.Length);

            Console.WriteLine("--------------------------------------------");

            Udp.Receiver receiver = new Udp.Receiver();
            receiver.PacketReceived += ReceiverPacketReceived;
            receiver.BytesReceived  += ReceiverBytesReceived;
            receiver.Start();

            Udp.Sender sender = new Udp.Sender();

            List <byte[]> packets = new List <byte[]>();

            for (int i = 0; i < 100; i++)
            {
                // packets.Add(before);
                sender.Send(before);
            }

            // sender.Send(packets);

            Console.WriteLine("Press any key to continue ...");
            Console.ReadKey();
        }