diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index d95ffb5e5..1892df9a9 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -181,7 +181,7 @@ public class BungeeCord extends ProxyServer public static void main(String[] args) throws Exception { Calendar deadline = Calendar.getInstance(); - deadline.set( 2013, 7, 1 ); // year, month, date + deadline.set( 2013, 7, 16 ); // year, month, date if ( Calendar.getInstance().after( deadline ) ) { System.err.println( "*** Warning, this build is outdated ***" ); 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 646a879b0..b6ffdb8ec 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 @@ -2,6 +2,7 @@ package net.md_5.bungee.netty; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.MessageList; import lombok.Getter; public class ChannelWrapper @@ -10,17 +11,35 @@ 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 ) { - ch.write( packet ); + if ( flushNow ) + { + ch.write( packet ); + } else + { + queue.add( packet ); + } } } @@ -29,6 +48,7 @@ public class ChannelWrapper if ( !closed ) { closed = true; + ch.write( queue ); ch.close(); } } 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 c3ed29a8c..ede4ad5ce 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,6 +61,7 @@ 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() ) @@ -85,6 +86,7 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter } } } + channel.flushNow( true ); } @Override