Ejemplo n.º 1
0
 public void OnMessage(byte[] msg)
 {
     PacketTest t = new PacketTest(msg, 0);
     switch (t.PacketId)
     {
         case 1:
             StringPacket packet = new StringPacket();
             packet.Decode(msg, 0, msg.Length);
             Console.WriteLine("OnMessage - " + packet.data);
             break;
         case 10001:
             FileBlockBeginPacket begin = new FileBlockBeginPacket();
             Console.WriteLine("OnMessage - FileBlockBeginPacket");
             break;
         case 10002:
             //Console.WriteLine("OnMessage - FileBlockDataPacket");
             break;
         case 10003:
             Console.WriteLine("OnMessage - FileBlockEndPacket");
             break;
     }
 }
Ejemplo n.º 2
0
        public void TestPacketPartReading()
        {
            Input.Delay = true;

            PacketTest p = new PacketTest(Input);

            Assert.IsFalse(p.IsComplete);

            Input.Delay = false;

            p.ContinueDataRead();

            Assert.IsTrue(p.IsComplete);

            byte[] testData = new byte[] { 0x20, 0xA0, 0x02, 0x5f, 0x30, 0x39, 0x30, 0x34, 0x31, 0x39 };

            Assert.AreEqual(10, p.Data.Length);

            for (int i = 0; i < 10; ++i)
            {
                Assert.AreEqual(testData[i], p.Data[i]);
            }
        }