All pastes #382565 Raw Edit

Something

public text v1 · immutable
·published 2007-03-05 19:13 UTC
rendered paste body
        /// <summary>
        /// Pass recieved data into the packet buffer and try to parse.
        /// </summary>
        /// <param name="num_bytes">number of bytes waiting to be read</param>
        protected override void OnReceive(int num_bytes)
        {
            PacketBuffer.MarshallRead(m_inBuf, 0, num_bytes);

            if (IsEncrypted)
            {
                long startPos = PacketBuffer.Position - num_bytes;
                Decrypt(PacketBuffer, startPos);
            }

            PacketBuffer.Parse(this);
            PacketBuffer.Clear();
                // when receive unhandled packet, position isnt reset to 0, and throws an exception in ParseUnsafe
        }