javax.net.websocket
Interface RemoteEndpoint<T>

All Known Implementing Classes:
RemoteEndpointWrapper

public interface RemoteEndpoint<T>

The RemoteEndpoint object is supplied by the container and represents the 'other end' of the Web Socket conversation. In particular, objects of this kind include numerous ways to send web socket messages. There is no guarantee of the success of receipt of a web socket message, but if the action of sending a message causes a known error, the API throws it. This object includes a variety of ways to send messages to the other end of a web socket session: by whole message, in pieces and asynchronously, where the point of completion is defined when all the supplied data had 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.

Since:
DRAFT 001
Author:
dannycoward

Method Summary
 OutputStream getSendStream()
           
 Writer getSendWriter()
           
 void sendBytes(byte[] data)
          Send a binary message, returning when all of the message has been transmitted.
 Future<SendResult> sendBytes(byte[] data, SendHandler completion)
          Initiates the asynchronous transmission of a binary message.
 void sendObject(T o)
          Sends a custom developer object, blocking until it has been transmitted.
 Future<SendResult> sendObject(T o, SendHandler handler)
          Initiates the transmission of a custom developer object.
 void sendPartialBytes(byte[] partialByte, boolean isLast)
          Send a binary message, blocking until all of the message has been transmitted.
 void sendPartialString(String fragment, boolean isLast)
           
 void sendPing(byte[] applicationData)
          Send a Ping message containing the given application data to the remote endpoint.
 void sendPong(byte[] applicationData)
          Allows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session.
 void sendString(String text)
          Send a text message, blocking until all of the message has been transmitted.
 Future<SendResult> sendString(String text, SendHandler completion)
          Initiates the asynchronous transmission of a text message.
 

Method Detail

sendString

void sendString(String text)
                throws IOException
Send a text message, blocking until all of the message has been transmitted.

Throws:
IOException

sendBytes

void sendBytes(byte[] data)
               throws IOException
Send a binary message, returning when all of the message has been transmitted.

Throws:
IOException

sendPartialString

void sendPartialString(String fragment,
                       boolean isLast)
                       throws IOException
Throws:
IOException

sendPartialBytes

void sendPartialBytes(byte[] partialByte,
                      boolean isLast)
                      throws IOException
Send a binary message, blocking until all of the message has been transmitted. The container reads the message from the caller of the API through the Iterable parameter until all the message has been sent.

Throws:
IOException

getSendStream

OutputStream getSendStream()
                           throws IOException
Throws:
IOException

getSendWriter

Writer getSendWriter()
                     throws IOException
Throws:
IOException

sendObject

void sendObject(T o)
                throws IOException,
                       EncodeException
Sends a custom developer object, blocking until it has been transmitted. Containers will by default be able to encode java primitive types, their object equivalents, and arrays or collections thereof. The developer will have provided an encoder for this object type in the endpoint configuration.

Parameters:
text -
completion -
Throws:
IOException
EncodeException

sendString

Future<SendResult> sendString(String text,
                              SendHandler completion)
Initiates the asynchronous transmission of a text message. This method returns before the message is transmitted. Developers may provide a callback to be notified when the message has been transmitted, or may use the returned Future object to track progress of the transmission. Errors in transmission are given to the developer in the SendResult object in either case.

Parameters:
text -
completion -
Returns:

sendBytes

Future<SendResult> sendBytes(byte[] data,
                             SendHandler completion)
Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted. Developers may provide a callback to be notified when the message has been transmitted, or may use the returned Future object to track progress of the transmission. Errors in transmission are given to the developer in the SendResult object in either case.

Parameters:
text -
completion -
Returns:

sendObject

Future<SendResult> sendObject(T o,
                              SendHandler handler)
Initiates the 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, their object equivalents, and arrays or collections thereof. Progress can be tracked using the Future object, or the developer can wait for a provided callback object to be notified when transmission is complete.

Parameters:
text -
completion -
Returns:

sendPing

void sendPing(byte[] applicationData)
Send a Ping message containing the given application data to the remote endpoint. The corresponding Pong message may be picked up using the MessageHandler.Pong handler.

Parameters:
applicationData -

sendPong

void sendPong(byte[] applicationData)
Allows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the session.



Copyright © 2012. All Rights Reserved.