protected override void OnReceive(byte[] Packet) { lock (this) { PacketIn packet = new PacketIn(Packet, 0, Packet.Length); long byteLeft = packet.Length; while (byteLeft > 0) { if (!m_expectData) { long StartPos = packet.Position; m_expectSize = packet.DecodeMythicSize(); long EndPos = packet.Position; long Diff = EndPos - StartPos; byteLeft -= Diff; if (m_expectSize <= 0) { packet.Opcode = packet.GetUint8(); packet.Size = (ulong)m_expectSize; _srvr.HandlePacket(this, packet); return; } if (byteLeft <= 0) return; Opcode = packet.GetUint8(); byteLeft -= 1; m_expectData = true; } else { m_expectData = false; if (byteLeft >= m_expectSize) { long Pos = packet.Position; packet.Opcode = Opcode; packet.Size = (ulong)m_expectSize; _srvr.HandlePacket(this, packet); byteLeft -= m_expectSize; packet.Position = Pos; packet.Skip(m_expectSize); } else { Log.Error("OnReceive", "Data count incorrect :" + byteLeft + " != " + m_expectSize); } } } packet.Dispose(); } }