-
- All Superinterfaces:
- RemoteEndpoint
- Enclosing interface:
- RemoteEndpoint
public static interface RemoteEndpoint.Async extends RemoteEndpoint
This representation of the peer of a web socket conversation has the ability to send messages asynchronously. The point of completion of the send is defined when all the supplied data has been written to the underlying connection. The completion handlers for the asynchronous methods are always called with a different thread from that which initiated the send.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.websocket.RemoteEndpoint
RemoteEndpoint.Async, RemoteEndpoint.Basic
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description long
getSendTimeout()
Return the number of milliseconds the implementation will timeout attempting to send a websocket message.Future<Void>
sendBinary(ByteBuffer data)
Initiates the asynchronous transmission of a binary message.void
sendBinary(ByteBuffer data, SendHandler handler)
Initiates the asynchronous transmission of a binary message.Future<Void>
sendObject(Object data)
Initiates the asynchronous transmission of a custom developer object.void
sendObject(Object data, SendHandler handler)
Initiates the asynchronous transmission of a custom developer object.Future<Void>
sendText(String text)
Initiates the asynchronous transmission of a text message.void
sendText(String text, SendHandler handler)
Initiates the asynchronous transmission of a text message.void
setSendTimeout(long timeoutmillis)
Sets the number of milliseconds the implementation will timeout attempting to send a websocket message.-
Methods inherited from interface javax.websocket.RemoteEndpoint
flushBatch, getBatchingAllowed, sendPing, sendPong, setBatchingAllowed
-
-
-
-
Method Detail
-
getSendTimeout
long getSendTimeout()
Return the number of milliseconds the implementation will timeout attempting to send a websocket message. A non-positive number indicates the implementation will not timeout attempting to send a websocket message asynchronously. This value overrides the default value assigned in the WebSocketContainer.- Returns:
- the timeout time in milliseconds.
-
setSendTimeout
void setSendTimeout(long timeoutmillis)
Sets the number of milliseconds the implementation will timeout attempting to send a websocket message. A non-positive number indicates the implementation will not timeout attempting to send a websocket message asynchronously. This value overrides the default value assigned in the WebSocketContainer.- Parameters:
timeoutmillis
- The number of milliseconds this RemoteEndpoint will wait before timing out an incomplete asynchronous message send.
-
sendText
void sendText(String text, SendHandler handler)
Initiates the asynchronous transmission of a text message. This method returns before the message is transmitted. Developers provide a callback to be notified when the message has been transmitted. Errors in transmission are given to the developer in the SendResult object.- Parameters:
text
- the text being sent.handler
- the handler which will be notified of progress.- Throws:
IllegalArgumentException
- if the text or the handler isnull
.
-
sendText
Future<Void> sendText(String text)
Initiates the asynchronous transmission of a text message. This method returns before the message is transmitted. Developers use the returned Future object to track progress of the transmission. The Future's get() method returnsnull
upon successful completion. Errors in transmission are wrapped in theExecutionException
thrown when querying the Future object.- Parameters:
text
- the text being sent.- Returns:
- the Future object representing the send operation.
- Throws:
IllegalArgumentException
- if the text isnull
.
-
sendBinary
Future<Void> sendBinary(ByteBuffer data)
Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted. Developers use the returned Future object to track progress of the transmission. The Future's get() method returnsnull
upon successful completion. Errors in transmission are wrapped in theExecutionException
thrown when querying the Future object.- Parameters:
data
- the data being sent.- Returns:
- the Future object representing the send operation.
- Throws:
IllegalArgumentException
- if the data isnull
.
-
sendBinary
void sendBinary(ByteBuffer data, SendHandler handler)
Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted. Developers provide a callback to be notified when the message has been transmitted. Errors in transmission are given to the developer in the SendResult object.- Parameters:
data
- the data being sent, must not benull
.handler
- the handler that will be notified of progress, must not benull
.- Throws:
IllegalArgumentException
- if either the data or the handler arenull
.
-
sendObject
Future<Void> sendObject(Object data)
Initiates the asynchronous transmission of a custom developer object. The developer will have provided an encoder for this object type in the endpoint configuration. Containers will by default be able to encode java primitive types and their object equivalents, otherwise the developer must have provided an encoder for the object type in the endpoint configuration. Progress may be tracked using the Future object. The Future's get() methods returnnull
upon successful completion. Errors in transmission are wrapped in theExecutionException
thrown when querying the Future object.- Parameters:
data
- the object being sent.- Returns:
- the Future object representing the send operation.
- Throws:
IllegalArgumentException
- if the data isnull
.
-
sendObject
void sendObject(Object data, SendHandler handler)
Initiates the asynchronous transmission of a custom developer object. Containers will by default be able to encode java primitive types and their object equivalents, otherwise the developer must have provided an encoder for the object type in the endpoint configuration. Developers are notified when transmission is complete through the supplied callback object.- Parameters:
data
- the object being sent.handler
- the handler that will be notified of progress, must not benull
.- Throws:
IllegalArgumentException
- if either the data or the handler arenull
.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
07/10/2025 04:09:11 Cette version de la page est en cache (à la date du 07/10/2025 04:09:11) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/websocket/RemoteEndpoint.Async.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.