Use a constructor parameter to determine clientsideness in packet encoder

This commit is contained in:
Camotoy 2021-11-24 11:21:14 -05:00
parent 2a8d18a3f8
commit a61bcb97f7
3 changed files with 4 additions and 4 deletions

View file

@ -114,7 +114,7 @@ public class TcpClientSession extends TcpSession {
pipeline.addLast("encryption", new TcpPacketEncryptor(TcpClientSession.this)); pipeline.addLast("encryption", new TcpPacketEncryptor(TcpClientSession.this));
pipeline.addLast("sizer", new TcpPacketSizer(TcpClientSession.this)); pipeline.addLast("sizer", new TcpPacketSizer(TcpClientSession.this));
pipeline.addLast("codec", new TcpPacketCodec(TcpClientSession.this)); pipeline.addLast("codec", new TcpPacketCodec(TcpClientSession.this, true));
pipeline.addLast("manager", TcpClientSession.this); pipeline.addLast("manager", TcpClientSession.this);
addHAProxySupport(pipeline); addHAProxySupport(pipeline);

View file

@ -18,9 +18,9 @@ public class TcpPacketCodec extends ByteToMessageCodec<Packet> {
private final Session session; private final Session session;
private final boolean client; private final boolean client;
public TcpPacketCodec(Session session) { public TcpPacketCodec(Session session, boolean client) {
this.session = session; this.session = session;
this.client = session instanceof TcpClientSession; this.client = client;
} }
@Override @Override

View file

@ -83,7 +83,7 @@ public class TcpServer extends AbstractServer {
pipeline.addLast("encryption", new TcpPacketEncryptor(session)); pipeline.addLast("encryption", new TcpPacketEncryptor(session));
pipeline.addLast("sizer", new TcpPacketSizer(session)); pipeline.addLast("sizer", new TcpPacketSizer(session));
pipeline.addLast("codec", new TcpPacketCodec(session)); pipeline.addLast("codec", new TcpPacketCodec(session, false));
pipeline.addLast("manager", session); pipeline.addLast("manager", session);
} }
}).group(this.group).localAddress(this.getHost(), this.getPort()).bind(); }).group(this.group).localAddress(this.getHost(), this.getPort()).bind();