Add info on registered channels to /bungee to enable users to help identify cause of random timeouts & resource leaks

This commit is contained in:
md_5 2013-03-17 09:03:20 +11:00
parent 40768c1711
commit b3c34815b0
2 changed files with 15 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.netty.HandlerBoss;
public class CommandBungee extends Command public class CommandBungee extends Command
{ {
@ -17,5 +18,6 @@ public class CommandBungee extends Command
public void execute(CommandSender sender, String[] args) public void execute(CommandSender sender, String[] args)
{ {
sender.sendMessage( ChatColor.BLUE + "This server is running BungeeCord version " + ProxyServer.getInstance().getVersion() + " by md_5" ); sender.sendMessage( ChatColor.BLUE + "This server is running BungeeCord version " + ProxyServer.getInstance().getVersion() + " by md_5" );
sender.sendMessage( ChatColor.BLUE + "There are currently " + HandlerBoss.registeredChannels + " channels registered" );
} }
} }

View File

@ -19,6 +19,7 @@ import net.md_5.bungee.packet.PacketHandler;
public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<byte[]> public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<byte[]>
{ {
public static volatile int registeredChannels;
private PacketHandler handler; private PacketHandler handler;
public void setHandler(PacketHandler handler) public void setHandler(PacketHandler handler)
@ -27,6 +28,18 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<byte[]>
this.handler = handler; this.handler = handler;
} }
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception
{
registeredChannels++;
}
@Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception
{
registeredChannels--;
}
@Override @Override
public void channelActive(ChannelHandlerContext ctx) throws Exception public void channelActive(ChannelHandlerContext ctx) throws Exception
{ {