Interface RemoteEndpoint.Async

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.
  • Method Details

    • 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 is null.
    • 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 returns null upon successful completion. Errors in transmission are wrapped in the ExecutionException 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 is null.
    • 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 returns null upon successful completion. Errors in transmission are wrapped in the ExecutionException 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 is null.
    • 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 be null.
      handler - the handler that will be notified of progress, must not be null.
      Throws:
      IllegalArgumentException - if either the data or the handler are null.
    • 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 return null upon successful completion. Errors in transmission are wrapped in the ExecutionException 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 is null.
    • 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 be null.
      Throws:
      IllegalArgumentException - if either the data or the handler are null.