public class ReactorTcpClient<P> extends Object implements TcpOperations<P>
TcpOperations
based on the TCP client support of the Reactor project.| Modifier and Type | Field and Description |
|---|---|
static Class<reactor.tcp.netty.NettyTcpClient> |
REACTOR_TCP_CLIENT_TYPE |
| Constructor and Description |
|---|
ReactorTcpClient(String host,
int port,
reactor.tcp.encoding.Codec<reactor.io.Buffer,Message<P>,Message<P>> codec)
A constructor that creates a
NettyTcpClient with
a reactor.event.dispatch.SynchronousDispatcher as a result of which
network I/O is handled in Netty threads. |
ReactorTcpClient(reactor.tcp.TcpClient<Message<P>,Message<P>> tcpClient)
A constructor with a pre-configured
TcpClient. |
| Modifier and Type | Method and Description |
|---|---|
ListenableFuture<Void> |
connect(TcpConnectionHandler<P> connectionHandler)
Open a new connection.
|
ListenableFuture<Void> |
connect(TcpConnectionHandler<P> connectionHandler,
ReconnectStrategy reconnectStrategy)
Open a new connection and a strategy for reconnecting if the connection fails.
|
ListenableFuture<Void> |
shutdown()
Shut down and close any open connections.
|
public static final Class<reactor.tcp.netty.NettyTcpClient> REACTOR_TCP_CLIENT_TYPE
public ReactorTcpClient(String host, int port, reactor.tcp.encoding.Codec<reactor.io.Buffer,Message<P>,Message<P>> codec)
NettyTcpClient with
a reactor.event.dispatch.SynchronousDispatcher as a result of which
network I/O is handled in Netty threads.
Also see the constructor accepting a pre-configured Reactor
TcpClient.
host - the host to connect toport - the port to connect tocodec - the codec to use for encoding and decoding the TCP streampublic ReactorTcpClient(reactor.tcp.TcpClient<Message<P>,Message<P>> tcpClient)
TcpClient.
NOTE: if the client is configured with a thread-creating
dispatcher, you are responsible for shutting down the Environment
instance with which the client is configured.
tcpClient - the TcpClient to usepublic ListenableFuture<Void> connect(TcpConnectionHandler<P> connectionHandler)
TcpOperationsconnect in interface TcpOperations<P>connectionHandler - a handler to manage the connectionpublic ListenableFuture<Void> connect(TcpConnectionHandler<P> connectionHandler, ReconnectStrategy reconnectStrategy)
TcpOperationsconnect in interface TcpOperations<P>connectionHandler - a handler to manage the connectionreconnectStrategy - a strategy for reconnectingpublic ListenableFuture<Void> shutdown()
TcpOperationsshutdown in interface TcpOperations<P>