Exemplo n.º 1
0
 /// <summary>
 /// Reads the bytes from the stream.
 /// </summary>
 private void ReadWork()
 {
     try
     {
         while (IsAlive)
         {
             ushort packetType     = BitConverter.ToUInt16(ReadBytes(2), 0);
             int    packetLength   = BitConverter.ToInt32(ReadBytes(4), 0);
             byte[] packetData     = ReadBytes(packetLength);
             Packet receivedPacket = ((Packet)Activator.CreateInstance(typeByte[packetType]));
             receivedPacket.SetProperties(packetData);
             receivedPackets.Enqueue(receivedPacket);
             receivedPacket.Size = packetLength;
         }
     }  catch { }
 }