From ef94883dd7ab8cbddfc176e70ede31f71d495b40 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Wed, 17 Jun 2020 21:16:04 -0700 Subject: [PATCH] Refactored name scheme --- .../src/com/riiablo/server/netty/Client.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/server/netty/src/com/riiablo/server/netty/Client.java b/server/netty/src/com/riiablo/server/netty/Client.java index ae7a9710..f1ce3d10 100644 --- a/server/netty/src/com/riiablo/server/netty/Client.java +++ b/server/netty/src/com/riiablo/server/netty/Client.java @@ -5,7 +5,6 @@ import com.google.flatbuffers.FlatBufferBuilder; import io.netty.bootstrap.Bootstrap; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; @@ -55,15 +54,15 @@ public class Client extends ApplicationAdapter { protected void initChannel(DatagramChannel ch) { ReliableInboundHandler in = new ReliableInboundHandler(); ReliableOutboundHandler out = new ReliableOutboundHandler(); - final EchoClientHandler echo = new EchoClientHandler(); + final ClientHandler client = new ClientHandler(); ch.pipeline() .addLast(in) - .addLast(echo) + .addLast(client) .addLast(out) .addLast(new ChannelInboundHandlerAdapter() { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { - echo.init(ctx.channel()); + client.init(ctx); ctx.pipeline().remove(this); } }) @@ -80,13 +79,13 @@ public class Client extends ApplicationAdapter { } } - public static class EchoClientHandler extends SimpleChannelInboundHandler { - EchoClientHandler() { + public static class ClientHandler extends SimpleChannelInboundHandler { + ClientHandler() { super(false); } - void init(Channel ch) { - InetSocketAddress remoteAddress = (InetSocketAddress) ch.remoteAddress(); + void init(ChannelHandlerContext ctx) { + InetSocketAddress remoteAddress = (InetSocketAddress) ctx.channel().remoteAddress(); Gdx.app.log(TAG, "Connecting to " + remoteAddress.getHostString() + ":" + remoteAddress.getPort()); FlatBufferBuilder builder = new FlatBufferBuilder(); @@ -99,7 +98,7 @@ public class Client extends ApplicationAdapter { sanity(builder.dataBuffer()); ByteBuf byteBuf = Unpooled.wrappedBuffer(builder.dataBuffer()); - ch.writeAndFlush(byteBuf); + ctx.writeAndFlush(byteBuf); } @Override