diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java index ca1a78da..be81ae71 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java @@ -15,35 +15,17 @@ public class ChannelWrapper private final Channel ch; @Getter private volatile boolean closed; - private final MessageList queue = MessageList.newInstance(); - private volatile boolean flushNow = true; public ChannelWrapper(ChannelHandlerContext ctx) { this.ch = ctx.channel(); } - public synchronized void flushNow(boolean flush) - { - if ( !flushNow && flush ) - { - ch.write( queue.copy() ); - queue.clear(); - } - this.flushNow = flush; - } - public synchronized void write(Object packet) { if ( !closed ) { - if ( flushNow ) - { - ch.write( packet ); - } else - { - queue.add( packet ); - } + ch.write( packet ); } } @@ -52,24 +34,14 @@ public class ChannelWrapper if ( !closed ) { closed = true; - ch.write( queue, ch.newPromise() ).addListener( new ChannelFutureListener() - { - @Override - public void operationComplete(ChannelFuture future) throws Exception - { - ch.close(); - } - } ); + ch.close(); } } public void addBefore(String baseName, String name, ChannelHandler handler) { Preconditions.checkState( ch.eventLoop().inEventLoop(), "cannot add handler outside of event loop" ); - boolean oldFlush = flushNow; - flushNow( true ); ch.pipeline().addBefore( baseName, name, handler ); - flushNow( oldFlush ); } public Channel getHandle() diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java index ede4ad5c..c3ed29a8 100644 --- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java +++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java @@ -61,7 +61,6 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter @Override public void messageReceived(ChannelHandlerContext ctx, MessageList msgs) throws Exception { - channel.flushNow( false ); for ( Object msg : msgs ) { if ( handler != null && ctx.channel().isActive() ) @@ -86,7 +85,6 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter } } } - channel.flushNow( true ); } @Override