- java.lang.Object
-
- io.netty5.handler.address.DynamicAddressConnectHandler
-
- All Implemented Interfaces:
ChannelHandler
public abstract class DynamicAddressConnectHandler extends Object implements ChannelHandler
ChannelHandlerimplementation 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 Future<Void>connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress)Called once a connect operation is made.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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelExceptionCaught, channelInactive, channelInboundEvent, channelRead, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, deregister, disconnect, flush, handlerAdded, handlerRemoved, isSharable, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown, write
-
-
-
-
Method Detail
-
connect
public final Future<Void> connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress)
Description copied from interface:ChannelHandlerCalled once a connect operation is made.- Specified by:
connectin interfaceChannelHandler- Parameters:
ctx- theChannelHandlerContextfor which the connect operation is maderemoteAddress- theSocketAddressto which it should connectlocalAddress- theSocketAddresswhich is used as source on connect- Returns:
- the
Futurewhich will be notified once the operation completes.
-
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
-
-