I created a login server for the game client using the network network library.
This game client likes to send several packets to one buffer, which creates a problem; this problem is that in the netty decoding class it can only return one message.
Then it is impossible for me to read several packets in several messages and return them to one call to the decoding method.
My question is: what is the best way to use multiple packages in one call to the DecoderClass.decode () method? Since I can only return one object, I am puzzled.
My preliminary decoding class is below:
protected Object decode(ChannelHandlerContext ctx, Channel c, ChannelBuffer buf, VoidEnum state) throws Exception { short length = -1; short opcode = -1; short security = -1; while(buf.readableBytes() != 0 ){ length = buf.readShort(); opcode = buf.readShort(); security = buf.readShort(); } System.out.println("---------------------------------------"); System.out.println("receivedLength: " + length); System.out.println("receivedOPCode: " + opcode); System.out.println("receivedSecurity: " + security); System.out.println("---------------------------------------"); MessageCodec<?> codec = CodecLookupService.find(opcode); if (codec == null) { throw new IOException("Unknown op code: " + opcode + " (previous opcode: " + previousOpcode + ")."); } previousOpcode = opcode; return codec.decode(buf);
My full github repository is here: https://github.com/desmin88/LoginServer
I hope I have provided enough information so that someone can adequately understand my problem.
Thanks,
Billy
source share