public interface ConnectFuture extends IoFuture
IoFuture for asynchronous connect requests.
IoConnector connector = ...; ConnectFuture future = connector.connect(...); future.awaitUninterruptibly(); // Wait until the connection attempt is finished. IoSession session = future.getSession(); session.write(...);
| 限定符和类型 | 方法和说明 |
|---|---|
ConnectFuture |
addListener(IoFutureListener<?> listener)
Adds an event listener which is notified when
this future is completed.
|
ConnectFuture |
await()
Wait for the asynchronous operation to complete.
|
ConnectFuture |
awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly.
|
boolean |
cancel()
Cancels the connection attempt and notifies all threads waiting for
this future.
|
java.lang.Throwable |
getException()
Returns the cause of the connection failure.
|
IoSession |
getSession()
Returns
IoSession which is the result of connect operation. |
boolean |
isCanceled() |
boolean |
isConnected() |
ConnectFuture |
removeListener(IoFutureListener<?> listener)
Removes an existing event listener so it won't be notified when
the future is completed.
|
void |
setException(java.lang.Throwable exception)
Sets the exception caught due to connection failure and notifies all
threads waiting for this future.
|
void |
setSession(IoSession session)
Sets the newly connected session and notifies all threads waiting for
this future.
|
await, await, awaitUninterruptibly, awaitUninterruptibly, isDone, join, joinIoSession getSession()
IoSession which is the result of connect operation.getSession 在接口中 IoFuturenull otherwisejava.lang.Throwable getException()
boolean isConnected()
true if the connect operation is finished successfully.boolean isCanceled()
true if the connect operation has been canceled by
cancel() method.void setSession(IoSession session)
session - The created session to store in the ConnectFuture insteancevoid setException(java.lang.Throwable exception)
exception - The exception to store in the ConnectFuture instanceboolean cancel()
true if the future has been cancelled by this call, false
if the future was already cancelled.ConnectFuture await() throws java.lang.InterruptedException
ConnectFuture awaitUninterruptibly()
awaitUninterruptibly 在接口中 IoFutureConnectFuture addListener(IoFutureListener<?> listener)
addListener 在接口中 IoFuturelistener - The listener to addConnectFuture removeListener(IoFutureListener<?> listener)
removeListener 在接口中 IoFuturelistener - The listener to remove