mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 20:59:12 +01:00
Clean up pipeline flow.
This commit is contained in:
parent
b55944e2fb
commit
3ce7982778
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.EntityMap;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
@ -16,17 +17,16 @@ import net.md_5.bungee.protocol.packet.Packet3Chat;
|
||||
import net.md_5.bungee.protocol.packet.PacketCCSettings;
|
||||
import net.md_5.bungee.protocol.packet.PacketFAPluginMessage;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class UpstreamBridge extends PacketHandler
|
||||
{
|
||||
|
||||
private final ProxyServer bungee;
|
||||
private final UserConnection con;
|
||||
|
||||
public UpstreamBridge(ProxyServer bungee, UserConnection con)
|
||||
@Override
|
||||
public void added()
|
||||
{
|
||||
this.bungee = bungee;
|
||||
this.con = con;
|
||||
|
||||
BungeeCord.getInstance().addConnection( con );
|
||||
con.getTabList().onConnect();
|
||||
con.unsafe().sendPacket( BungeeCord.getInstance().registerChannels() );
|
||||
|
@ -26,12 +26,11 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<Object>
|
||||
{
|
||||
Preconditions.checkArgument( handler != null, "handler" );
|
||||
this.handler = handler;
|
||||
this.handler.added();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception
|
||||
{
|
||||
if ( handler != null )
|
||||
{
|
||||
channel = new ChannelWrapper( ctx );
|
||||
handler.connected( channel );
|
||||
@ -41,12 +40,9 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<Object>
|
||||
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception
|
||||
{
|
||||
if ( handler != null )
|
||||
{
|
||||
handler.disconnected( channel );
|
||||
|
||||
@ -55,12 +51,11 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<Object>
|
||||
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageReceived(ChannelHandlerContext ctx, Object msg) throws Exception
|
||||
{
|
||||
if ( handler != null && ctx.channel().isActive() )
|
||||
if ( !channel.isClosed() )
|
||||
{
|
||||
if ( msg instanceof PacketWrapper )
|
||||
{
|
||||
@ -86,7 +81,7 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<Object>
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
||||
{
|
||||
if ( ctx.channel().isActive() )
|
||||
if ( !channel.isClosed() )
|
||||
{
|
||||
if ( cause instanceof ReadTimeoutException )
|
||||
{
|
||||
@ -98,8 +93,7 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<Object>
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause );
|
||||
}
|
||||
if ( handler != null )
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
handler.exception( cause );
|
||||
@ -107,8 +101,8 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<Object>
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - exception processing exception", ex );
|
||||
}
|
||||
}
|
||||
ctx.close();
|
||||
|
||||
channel.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,10 @@ public abstract class PacketHandler extends net.md_5.bungee.protocol.packet.Abst
|
||||
{
|
||||
}
|
||||
|
||||
public void added()
|
||||
{
|
||||
}
|
||||
|
||||
public void connected(ChannelWrapper channel) throws Exception
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user