Clean up code style surrounding bootstrap creation
This commit is contained in:
parent
57793e93f0
commit
8a70af5293
@ -223,13 +223,7 @@ public class BungeeCord extends ProxyServer
|
|||||||
{
|
{
|
||||||
for ( final ListenerInfo info : config.getListeners() )
|
for ( final ListenerInfo info : config.getListeners() )
|
||||||
{
|
{
|
||||||
new ServerBootstrap()
|
ChannelFutureListener listener = new ChannelFutureListener()
|
||||||
.channel( NioServerSocketChannel.class )
|
|
||||||
.childAttr( PipelineUtils.LISTENER, info )
|
|
||||||
.childHandler( PipelineUtils.SERVER_CHILD )
|
|
||||||
.group( eventLoops )
|
|
||||||
.localAddress( info.getHost() )
|
|
||||||
.bind().addListener( new ChannelFutureListener()
|
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(ChannelFuture future) throws Exception
|
public void operationComplete(ChannelFuture future) throws Exception
|
||||||
@ -243,7 +237,14 @@ public class BungeeCord extends ProxyServer
|
|||||||
getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() );
|
getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
};
|
||||||
|
new ServerBootstrap()
|
||||||
|
.channel( NioServerSocketChannel.class )
|
||||||
|
.childAttr( PipelineUtils.LISTENER, info )
|
||||||
|
.childHandler( PipelineUtils.SERVER_CHILD )
|
||||||
|
.group( eventLoops )
|
||||||
|
.localAddress( info.getHost() )
|
||||||
|
.bind().addListener( listener );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,14 +98,7 @@ public class BungeeServerInfo implements ServerInfo
|
|||||||
@Override
|
@Override
|
||||||
public void ping(final Callback<ServerPing> callback)
|
public void ping(final Callback<ServerPing> callback)
|
||||||
{
|
{
|
||||||
new Bootstrap()
|
ChannelFutureListener listener = new ChannelFutureListener()
|
||||||
.channel( NioSocketChannel.class )
|
|
||||||
.group( BungeeCord.getInstance().eventLoops )
|
|
||||||
.handler( PipelineUtils.BASE )
|
|
||||||
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable
|
|
||||||
.remoteAddress( getAddress() )
|
|
||||||
.connect()
|
|
||||||
.addListener( new ChannelFutureListener()
|
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(ChannelFuture future) throws Exception
|
public void operationComplete(ChannelFuture future) throws Exception
|
||||||
@ -118,6 +111,14 @@ public class BungeeServerInfo implements ServerInfo
|
|||||||
callback.done( null, future.cause() );
|
callback.done( null, future.cause() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
};
|
||||||
|
new Bootstrap()
|
||||||
|
.channel( NioSocketChannel.class )
|
||||||
|
.group( BungeeCord.getInstance().eventLoops )
|
||||||
|
.handler( PipelineUtils.BASE )
|
||||||
|
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable
|
||||||
|
.remoteAddress( getAddress() )
|
||||||
|
.connect()
|
||||||
|
.addListener( listener );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,10 +164,7 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
|
|
||||||
pendingConnects.add( target );
|
pendingConnects.add( target );
|
||||||
|
|
||||||
new Bootstrap()
|
ChannelInitializer initializer = new ChannelInitializer()
|
||||||
.channel( NioSocketChannel.class )
|
|
||||||
.group( BungeeCord.getInstance().eventLoops )
|
|
||||||
.handler( new ChannelInitializer()
|
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
protected void initChannel(Channel ch) throws Exception
|
protected void initChannel(Channel ch) throws Exception
|
||||||
@ -175,11 +172,8 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
PipelineUtils.BASE.initChannel( ch );
|
PipelineUtils.BASE.initChannel( ch );
|
||||||
ch.pipeline().get( HandlerBoss.class ).setHandler( new ServerConnector( bungee, UserConnection.this, target ) );
|
ch.pipeline().get( HandlerBoss.class ).setHandler( new ServerConnector( bungee, UserConnection.this, target ) );
|
||||||
}
|
}
|
||||||
} )
|
};
|
||||||
.localAddress( getPendingConnection().getListener().getHost() )
|
ChannelFutureListener listener = new ChannelFutureListener()
|
||||||
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable
|
|
||||||
.remoteAddress( target.getAddress() )
|
|
||||||
.connect().addListener( new ChannelFutureListener()
|
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(ChannelFuture future) throws Exception
|
public void operationComplete(ChannelFuture future) throws Exception
|
||||||
@ -206,7 +200,15 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
};
|
||||||
|
new Bootstrap()
|
||||||
|
.channel( NioSocketChannel.class )
|
||||||
|
.group( BungeeCord.getInstance().eventLoops )
|
||||||
|
.handler( initializer )
|
||||||
|
.localAddress( getPendingConnection().getListener().getHost() )
|
||||||
|
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable
|
||||||
|
.remoteAddress( target.getAddress() )
|
||||||
|
.connect().addListener( listener );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user