/// /// Pass recieved data into the packet buffer and try to parse. /// /// number of bytes waiting to be read 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 }