org.glassfish.tyrus.grizzly
Class GrizzlyRemoteEndpoint

java.lang.Object
  extended by org.glassfish.tyrus.grizzly.GrizzlyRemoteEndpoint
All Implemented Interfaces:
RemoteEndpoint

public class GrizzlyRemoteEndpoint
extends Object
implements RemoteEndpoint

Author:
Danny Coward (danny.coward at oracle.com)

Constructor Summary
GrizzlyRemoteEndpoint(org.glassfish.grizzly.websockets.WebSocket socket)
           
 
Method Summary
static GrizzlyRemoteEndpoint get(org.glassfish.grizzly.websockets.WebSocket socket)
           
 OutputStream getSendStream()
          Opens an output stream on which a binary message may be sent.
 Writer getSendWriter()
          Opens an character stream on which a text message may be sent.
static void remove(org.glassfish.grizzly.websockets.WebSocket socket)
           
 void sendBytes(ByteBuffer byteBuffer)
          Send a binary message, returning when all of the message has been transmitted.
 void sendBytesByCompletion(ByteBuffer byteBuffer, SendHandler sendHandler)
          Initiates the asynchronous transmission of a binary message.
 Future<SendResult> sendBytesByFuture(ByteBuffer byteBuffer)
          Initiates the asynchronous transmission of a binary message.
 void sendObject(Object o)
          Sends a custom developer object, blocking until it has been transmitted.
 void sendObjectByCompletion(Object o, SendHandler sendHandler)
          Initiates the asynchronous transmission of a custom developer object.
 Future<SendResult> sendObjectByFuture(Object o)
          Initiates the asynchronous transmission of a custom developer object.
 void sendPartialBytes(ByteBuffer byteBuffer, boolean b)
          Send a binary message in pieces, blocking until all of the message has been transmitted.
 void sendPartialString(String fragment, boolean isLast)
          Send a text message in pieces, blocking until all of the message has been transmitted.
 void sendPing(ByteBuffer byteBuffer)
          Send a Ping message containing the given application data to the remote endpoint.
 void sendPong(ByteBuffer byteBuffer)
          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.
 void sendStringByCompletion(String s, SendHandler sendHandler)
          Initiates the asynchronous transmission of a text message.
 Future<SendResult> sendStringByFuture(String s)
          Initiates the asynchronous transmission of a text message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GrizzlyRemoteEndpoint

public GrizzlyRemoteEndpoint(org.glassfish.grizzly.websockets.WebSocket socket)
Method Detail

get

public static GrizzlyRemoteEndpoint get(org.glassfish.grizzly.websockets.WebSocket socket)

remove

public static void remove(org.glassfish.grizzly.websockets.WebSocket socket)

sendString

public void sendString(String text)
                throws IOException
Description copied from interface: RemoteEndpoint
Send a text message, blocking until all of the message has been transmitted.

Specified by:
sendString in interface RemoteEndpoint
Parameters:
text - the message to be sent.
Throws:
IOException

sendBytes

public void sendBytes(ByteBuffer byteBuffer)
               throws IOException
Description copied from interface: RemoteEndpoint
Send a binary message, returning when all of the message has been transmitted.

Specified by:
sendBytes in interface RemoteEndpoint
Parameters:
byteBuffer - the message to be sent.
Throws:
IOException

sendPartialString

public void sendPartialString(String fragment,
                              boolean isLast)
                       throws IOException
Description copied from interface: RemoteEndpoint
Send a text message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are sent with isLast set to false. The final piece must be sent with isLast set to true.

Specified by:
sendPartialString in interface RemoteEndpoint
Parameters:
fragment - the piece of the message being sent.
isLast - Whether the fragment being sent is the last piece of the message.
Throws:
IOException

sendPartialBytes

public void sendPartialBytes(ByteBuffer byteBuffer,
                             boolean b)
                      throws IOException
Description copied from interface: RemoteEndpoint
Send a binary message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are sent with isLast set to false. The final piece must be sent with isLast set to true.

Specified by:
sendPartialBytes in interface RemoteEndpoint
Parameters:
byteBuffer - the piece of the message being sent.
b - Whether the fragment being sent is the last piece of the message.
Throws:
IOException

getSendStream

public OutputStream getSendStream()
                           throws IOException
Description copied from interface: RemoteEndpoint
Opens an output stream on which a binary message may be sent. The developer must close the output stream in order to indicate that the complete message has been placed into the output stream.

Specified by:
getSendStream in interface RemoteEndpoint
Returns:
the output stream to which the message will be written.
Throws:
IOException

getSendWriter

public Writer getSendWriter()
                     throws IOException
Description copied from interface: RemoteEndpoint
Opens an character stream on which a text message may be sent. The developer must close the writer in order to indicate that the complete message has been placed into the character stream.

Specified by:
getSendWriter in interface RemoteEndpoint
Returns:
the writer to which the message will be written.
Throws:
IOException

sendObject

public void sendObject(Object o)
                throws IOException,
                       EncodeException
Description copied from interface: RemoteEndpoint
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.

Specified by:
sendObject in interface RemoteEndpoint
Parameters:
o - the object to be sent.
Throws:
IOException
EncodeException

sendStringByCompletion

public void sendStringByCompletion(String s,
                                   SendHandler sendHandler)
Description copied from interface: RemoteEndpoint
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.

Specified by:
sendStringByCompletion in interface RemoteEndpoint
Parameters:
s - the text being sent.
sendHandler - the handler which will be notified of progress.

sendStringByFuture

public Future<SendResult> sendStringByFuture(String s)
Description copied from interface: RemoteEndpoint
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. Errors in transmission are given to the developer in the SendResult object.

Specified by:
sendStringByFuture in interface RemoteEndpoint
Parameters:
s - the text being sent.
Returns:
the Future object representing the send operation.

sendBytesByFuture

public Future<SendResult> sendBytesByFuture(ByteBuffer byteBuffer)
Description copied from interface: RemoteEndpoint
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. Errors in transmission are given to the developer in the SendResult object.

Specified by:
sendBytesByFuture in interface RemoteEndpoint
Parameters:
byteBuffer - the data being sent.
Returns:
the Future object representing the send operation.

sendBytesByCompletion

public void sendBytesByCompletion(ByteBuffer byteBuffer,
                                  SendHandler sendHandler)
Description copied from interface: RemoteEndpoint
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.

Specified by:
sendBytesByCompletion in interface RemoteEndpoint
Parameters:
byteBuffer - the data being sent.
sendHandler - the handler that will be notified of progress.

sendObjectByFuture

public Future<SendResult> sendObjectByFuture(Object o)
Description copied from interface: RemoteEndpoint
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, their object equivalents, and arrays or collections thereof. Progress is be tracked using the Future object.

Specified by:
sendObjectByFuture in interface RemoteEndpoint
Parameters:
o - the object being sent.
Returns:
the Future object representing the send operation.

sendObjectByCompletion

public void sendObjectByCompletion(Object o,
                                   SendHandler sendHandler)
Description copied from interface: RemoteEndpoint
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, their object equivalents, and arrays or collections thereof. Developers are notified when transmission is complete through the supplied callback object.

Specified by:
sendObjectByCompletion in interface RemoteEndpoint
Parameters:
o - the object being sent.
sendHandler - the handler that will be notified of progress

sendPing

public void sendPing(ByteBuffer byteBuffer)
Description copied from interface: RemoteEndpoint
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.

Specified by:
sendPing in interface RemoteEndpoint
Parameters:
byteBuffer - the data to be carried in the ping request.

sendPong

public void sendPong(ByteBuffer byteBuffer)
Description copied from interface: RemoteEndpoint
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.

Specified by:
sendPong in interface RemoteEndpoint
Parameters:
byteBuffer - the application data to be carried in the pong response.


Copyright © 2012. All Rights Reserved.