public override IPacket ReadHeader(IByteBuffer buf) { int length = -1; int opcode = -1; try { length = ByteBufUtils.ReadVarInt(buf); // mark point before opcode buf.MarkReaderIndex(); opcode = ByteBufUtils.ReadVarInt(buf); return(inboundCodecs.Find(opcode)); } catch (IOException) { throw new UnknownPacketException("Failed to read packet data (corrupt?)", opcode, length); } catch (IllegalOpcodeException) { // go back to before opcode, so that skipping length doesn't skip too much buf.ResetReaderIndex(); throw new UnknownPacketException("Opcode received is not a registered codec on the server!", opcode, length); } }
public IPacket NewReadHeader(IByteBuffer header) { int opcode = ByteBufUtils.ReadVarInt(header); return(inboundCodecs.Find(opcode)); }