Package io.netty.handler.address
Class DynamicAddressConnectHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelOutboundHandlerAdapter
-
- io.netty.handler.address.DynamicAddressConnectHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelOutboundHandler
public abstract class DynamicAddressConnectHandler extends io.netty.channel.ChannelOutboundHandlerAdapterChannelOutboundHandlerimplementation which allows to dynamically replace the usedremoteAddressand / orlocalAddresswhen making a connection attempt.This can be useful to for example bind to a specific
NetworkInterfacebased on theremoteAddress.
-
-
Constructor Summary
Constructors Constructor Description DynamicAddressConnectHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect(io.netty.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, io.netty.channel.ChannelPromise promise)protected SocketAddresslocalAddress(SocketAddress remoteAddress, SocketAddress localAddress)Returns the localSocketAddressto use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)based on the originalremoteAddressandlocalAddress.protected SocketAddressremoteAddress(SocketAddress remoteAddress, SocketAddress localAddress)Returns the remoteSocketAddressto use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)based on the originalremoteAddressandlocalAddress.-
Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter
bind, close, deregister, disconnect, flush, read, write
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Method Detail
-
connect
public final void connect(io.netty.channel.ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, io.netty.channel.ChannelPromise promise)- Specified by:
connectin interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
connectin classio.netty.channel.ChannelOutboundHandlerAdapter
-
localAddress
protected SocketAddress localAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
Returns the localSocketAddressto use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)based on the originalremoteAddressandlocalAddress. By default, this method returns the givenlocalAddress.- Throws:
Exception
-
remoteAddress
protected SocketAddress remoteAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
Returns the remoteSocketAddressto use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)based on the originalremoteAddressandlocalAddress. By default, this method returns the givenremoteAddress.- Throws:
Exception
-
-