Added debug.

This commit is contained in:
Mike 2020-05-09 22:41:43 +02:00
parent ee5a97bbae
commit a93ffbbbac

View File

@ -4,18 +4,28 @@ import com.eu.habbo.messages.ServerMessage;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder; import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.util.IllegalReferenceCountException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GameServerMessageEncoder extends MessageToByteEncoder<ServerMessage> { public class GameServerMessageEncoder extends MessageToByteEncoder<ServerMessage> {
private static final Logger LOGGER = LoggerFactory.getLogger(GameServerMessageEncoder.class);
@Override @Override
protected void encode(ChannelHandlerContext ctx, ServerMessage message, ByteBuf out) { protected void encode(ChannelHandlerContext ctx, ServerMessage message, ByteBuf out) {
ByteBuf buf = message.get();
try { try {
out.writeBytes(buf); ByteBuf buf = message.get();
} finally {
// Release copied buffer. try {
buf.release(); out.writeBytes(buf);
} finally {
// Release copied buffer.
buf.release();
}
} catch (IllegalReferenceCountException e) {
LOGGER.error("IllegalReferenceCountException happened for packet {}.", message.getHeader());
throw e;
} }
} }