private void OctetQueueChanged(OctetQueue queue) { // log.Debug("OctetQueue changed {0}", queue); lastReceivedPacketTime = Timestamp.Now(); var tempBuf = new byte[32 * 1024]; while (true) { var octetCount = queue.Peek(tempBuf, 0, tempBuf.Length); if (octetCount <= 0) { return; } int octetsUsed = 0; var packet = PacketDecoder.Decode(tempBuf, 0, octetCount, out octetsUsed, log); if (packet == null) { return; } queue.Skip(octetsUsed); try { OnPacketRead(packet); } catch (Exception e) { log.Exception(e); throw e; } } }