Package rocks.xmpp.core.session
Class SendTask<S extends Stanza>
- java.lang.Object
-
- rocks.xmpp.core.session.SendTask<S>
-
public final class SendTask<S extends Stanza> extends Object implements Future<Void>
A send task is the result of a send action and allows to keep track of the sent stanza.This class implements
Future
, which Future.isDone() is done}, when the stanza has been sent to the server.- See Also:
XmppSession.sendMessage(Message)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancel(boolean mayInterruptIfRunning)
Void
get()
Void
get(long timeout, TimeUnit timeUnit)
S
getStanza()
Gets the stanza, which has been sent.boolean
isCancelled()
boolean
isDone()
void
onAcknowledge(Consumer<S> onAcknowledge)
Called when the sent stanza has been acknowledged by the server.void
onFailed(BiConsumer<Throwable,S> onFailure)
Called, when a send operation failed.void
onSent(Consumer<S> onSent)
Called, when a stanza has been sent to the server.
-
-
-
Method Detail
-
getStanza
public final S getStanza()
Gets the stanza, which has been sent.- Returns:
- The stanza.
-
onAcknowledge
public final void onAcknowledge(Consumer<S> onAcknowledge)
Called when the sent stanza has been acknowledged by the server.- Parameters:
onAcknowledge
- The consumer.
-
onSent
public final void onSent(Consumer<S> onSent)
Called, when a stanza has been sent to the server. Note, that this does not mean, that the server received it.- Parameters:
onSent
- The callback.
-
onFailed
public final void onFailed(BiConsumer<Throwable,S> onFailure)
Called, when a send operation failed.- Parameters:
onFailure
- The callback.
-
cancel
public final boolean cancel(boolean mayInterruptIfRunning)
-
isCancelled
public final boolean isCancelled()
- Specified by:
isCancelled
in interfaceFuture<S extends Stanza>
-
get
public final Void get() throws InterruptedException, ExecutionException
- Specified by:
get
in interfaceFuture<S extends Stanza>
- Throws:
InterruptedException
ExecutionException
-
get
public final Void get(long timeout, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
get
in interfaceFuture<S extends Stanza>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
-