public class ChannelFsm
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ChannelFsm.TransitionListener |
| Modifier and Type | Method and Description |
|---|---|
void |
addTransitionListener(ChannelFsm.TransitionListener transitionListener)
|
java.util.concurrent.CompletableFuture<io.netty.channel.Channel> |
connect()
Fire a
Event.Connect event and return a CompletableFuture that completes successfully with the
Channel if a successful connection is made, or already exists, and completes exceptionally otherwise. |
java.util.concurrent.CompletableFuture<java.lang.Void> |
disconnect()
Fire a
Event.Disconnect event and return a CompletableFuture that completes successfully when the
Channel has been closed. |
java.util.concurrent.CompletableFuture<io.netty.channel.Channel> |
getChannel()
Fire a
Event.GetChannel event and return a CompletableFuture that completes successfully when the
Channel is available and completes exceptionally if the FSM is not currently connected or the connection
attempt failed. |
java.util.concurrent.CompletableFuture<io.netty.channel.Channel> |
getChannel(boolean waitForReconnect)
Fire a
Event.GetChannel event and return a CompletableFuture that completes successfully when the
Channel is available and completes exceptionally if the FSM is not currently connected or the connection
attempt failed. |
State |
getState()
Get the current
State of the ChannelFsm. |
void |
removeTransitionListener(ChannelFsm.TransitionListener transitionListener)
Remove a previously registered
ChannelFsm.TransitionListener. |
public java.util.concurrent.CompletableFuture<io.netty.channel.Channel> connect()
Event.Connect event and return a CompletableFuture that completes successfully with the
Channel if a successful connection is made, or already exists, and completes exceptionally otherwise.CompletableFuture that completes successfully with the Channel if a successful
connection was made, or already exists, and completes exceptionally otherwise.public java.util.concurrent.CompletableFuture<java.lang.Void> disconnect()
Event.Disconnect event and return a CompletableFuture that completes successfully when the
Channel has been closed.CompletableFuture that completes successfully when the Channel has been closed.public java.util.concurrent.CompletableFuture<io.netty.channel.Channel> getChannel()
Event.GetChannel event and return a CompletableFuture that completes successfully when the
Channel is available and completes exceptionally if the FSM is not currently connected or the connection
attempt failed.
connect() must have been called at least once before attempting to get a Channel. Whether further calls
are necessary depends on whether the FSM is configured to be persistent in its connection attempts or not.
The returned CompletableFuture always fails exceptionally if the FSM is not connected.
This method is equivalent to getChannel(true) - if the state machine is reconnecting it will wait for
the result.
CompletableFuture that completes successfully when the Channel is available and
completes exceptionally if the FSM is not currently connected or the connection attempt failed.public java.util.concurrent.CompletableFuture<io.netty.channel.Channel> getChannel(boolean waitForReconnect)
Event.GetChannel event and return a CompletableFuture that completes successfully when the
Channel is available and completes exceptionally if the FSM is not currently connected or the connection
attempt failed.
connect() must have been called at least once before attempting to get a Channel. Whether further calls
are necessary depends on whether the FSM is configured to be persistent in its connection attempts or not.
The returned CompletableFuture always fails exceptionally if the FSM is not connected.
waitForReconnect - when true and the state machine is in State.ReconnectWait the future
will not be completed until the result of the subsequent reconnect attempt has been
obtained. When false and the state machine is in State.ReconnectWait
the future is failed immediately. This parameter has no effect in other states.CompletableFuture that completes successfully when the Channel is available and
*completes exceptionally if the FSM is not currently connected or the connection attempt failed.public State getState()
State of the ChannelFsm.State of the ChannelFsm.public void addTransitionListener(ChannelFsm.TransitionListener transitionListener)
transitionListener - the ChannelFsm.TransitionListener.public void removeTransitionListener(ChannelFsm.TransitionListener transitionListener)
ChannelFsm.TransitionListener.transitionListener - the ChannelFsm.TransitionListener.