I'm not sure if I'm doing something wrong but after I decode the revision and encode the response the client sends me the operation code 6 with a length of 7
Log
Code:
[main] INFO com.openlinx.game.net.NetworkService - Initializing network service...
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.ProtocolFrameDecoder - Decoding Packet
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.ProtocolFrameDecoder - Decoding Packet: Opcode - 15
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.ProtocolFrameDecoder - DEBUG: opcode - 15 readable - 4
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.ProtocolFrameDecoder - Decoding Packet: Opcode - 15 length - 4
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.Js5.Js5ServiceProtocolFrameCodec - Decoded: opcode - 15 revision - 525
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.ProtocolFrameDecoder - Decoding Packet: Opcode - 15 length - 4 payload - 0
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.Js5.Js5ServiceProtocolFrameCodec - Encoding: response - 0
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.ProtocolFrameDecoder - Decoding Packet
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.ProtocolFrameDecoder - Decoding Packet: Opcode - 6
[multithreadEventLoopGroup-1-2] INFO com.openlinx.net.proto.codec.ProtocolFrameDecoder - DEBUG: opcode - 6 readable - 7
Code:
@Override
protected void decode(ChannelHandlerContext context, Buffer input) {
logger.info("Decoding Packet");
if (input.readableBytes() == 0) return;
var opcode = (input.readUnsignedByte() - cipher.nextInt()) & 0xFF;
var codec = publisher.codecOf(opcode);
logger.info("Decoding Packet: Opcode - {}", opcode);
debugIncoming(input, opcode);
if (input.readableBytes() == 0) return;
var length = codec.protocolFrame().length();
logger.info("Decoding Packet: Opcode - {} length - {}", opcode, length);
if (input.readableBytes() < length) return;
var payload = input.readSplit(length);
codec.decode(payload);
logger.info("Decoding Packet: Opcode - {} length - {} payload - {}", opcode, length, input.readableBytes());
context.fireChannelRead(codec.protocolFrame());
}
private void debugIncoming(Buffer input, int opcode) {
logger.info("DEBUG: opcode - {} readable - {}", opcode, input.readableBytes());
}
Code:
@Override
public Buffer encode(BufferAllocator allocator) {
logger.info("Encoding: response - {}", (revision == 525 ? 0 : 6));
return allocator.allocate(1).writeByte((byte) (revision == 525 ? 0 : 6));
}
@Override
public void decode(Buffer payload) {
revision = payload.readInt();
logger.info("Decoded: opcode - {} revision - {}", protocolFrame().opcode(), revision);
}