- java.lang.Object
-
- io.netty5.handler.address.DynamicAddressConnectHandler
-
- All Implemented Interfaces:
ChannelHandler
public abstract class DynamicAddressConnectHandler extends Object implements ChannelHandler
ChannelHandler
implementation which allows to dynamically replace the usedremoteAddress
and / orlocalAddress
when making a connection attempt.This can be useful to for example bind to a specific
NetworkInterface
based 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 SocketAddress
localAddress(SocketAddress remoteAddress, SocketAddress localAddress)
Returns the localSocketAddress
to use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the originalremoteAddress
andlocalAddress
.protected SocketAddress
remoteAddress(SocketAddress remoteAddress, SocketAddress localAddress)
Returns the remoteSocketAddress
to use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the originalremoteAddress
andlocalAddress
.-
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:ChannelHandler
Called once a connect operation is made.- Specified by:
connect
in interfaceChannelHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the connect operation is maderemoteAddress
- theSocketAddress
to which it should connectlocalAddress
- theSocketAddress
which is used as source on connect- Returns:
- the
Future
which will be notified once the operation completes.
-
localAddress
protected SocketAddress localAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
Returns the localSocketAddress
to use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the originalremoteAddress
andlocalAddress
. By default, this method returns the givenlocalAddress
.- Throws:
Exception
-
remoteAddress
protected SocketAddress remoteAddress(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception
Returns the remoteSocketAddress
to use forChannelOutboundInvoker.connect(SocketAddress, SocketAddress)
based on the originalremoteAddress
andlocalAddress
. By default, this method returns the givenremoteAddress
.- Throws:
Exception
-
-