org.glassfish.tyrus.spi
Class SPIEndpoint

java.lang.Object
  extended by org.glassfish.tyrus.spi.SPIEndpoint
Direct Known Subclasses:
EndpointWrapper

public abstract class SPIEndpoint
extends Object

The WebSocket SDK implements SPIEndpoint with its representation of a websocket endpoint mapped to a base URI that wishes to handle incoming messages.

Author:
Danny Coward (danny.coward at oracle.com), Stepan Kopriva (stepan.kopriva at oracle.com)

Constructor Summary
SPIEndpoint()
           
 
Method Summary
abstract  boolean checkHandshake(SPIHandshakeRequest hr)
          This method must be called by the provider during its check for a successful websocket handshake.
abstract  List<String> getNegotiatedExtensions(List<String> clientExtensions)
          Get the negotiated extensions' names based on the extensions supported by client.
abstract  String getNegotiatedProtocol(List<String> clientProtocols)
          Compute the sub - protocol which will be used.
abstract  void onClose(RemoteEndpoint gs)
          Called by the provider when the web socket connection to the given remote endpoint has just closed.
abstract  void onConnect(RemoteEndpoint gs, String subprotocol, List<String> extensions)
          Called by the provider when the web socket connection is established.
abstract  void onMessage(RemoteEndpoint gs, ByteBuffer bytes)
          Called by the provider when the web socket connection has an incoming binary message from the given remote endpoint.
abstract  void onMessage(RemoteEndpoint gs, String messageString)
          Called by the provider when the web socket connection has an incoming text message from the given remote endpoint.
abstract  void onPartialMessage(RemoteEndpoint gs, ByteBuffer partialBytes, boolean last)
          Called by the provider when the web socket connection has an incoming partial binary message from the given remote endpoint.
abstract  void onPartialMessage(RemoteEndpoint gs, String partialString, boolean last)
          Called by the provider when the web socket connection has an incoming partial text message from the given remote endpoint.
abstract  void onPing(RemoteEndpoint gs, ByteBuffer bytes)
          Called by the provider when the web socket connection has an incoming ping message from the given remote endpoint.
abstract  void onPong(RemoteEndpoint gs, ByteBuffer bytes)
          Called by the provider when the web socket connection has an incoming pong message from the given remote endpoint.
abstract  void remove()
          Called by the provider after all connections have been closed to this endpoint, and after the endpoint has been removed from service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SPIEndpoint

public SPIEndpoint()
Method Detail

checkHandshake

public abstract boolean checkHandshake(SPIHandshakeRequest hr)
This method must be called by the provider during its check for a successful websocket handshake. The provider must turn down the handshake if the method returns false. If the web socket handshake does complete, as determined by the provider, the endpoint must establish a connection and route all websocket events to this SDK provided component as appropriate.

Parameters:
hr - SPIHandshakeRequest that is going to be checked.
Returns:
true if handshake is successful false otherwise.

onConnect

public abstract void onConnect(RemoteEndpoint gs,
                               String subprotocol,
                               List<String> extensions)
Called by the provider when the web socket connection is established.

Parameters:
gs - SPIRemoteEndpoint who has just connected to this web socket endpoint.

onMessage

public abstract void onMessage(RemoteEndpoint gs,
                               String messageString)
Called by the provider when the web socket connection has an incoming text message from the given remote endpoint.

Parameters:
gs - SPIRemoteEndpoint who sent the message.
messageString - the String message.

onPartialMessage

public abstract void onPartialMessage(RemoteEndpoint gs,
                                      String partialString,
                                      boolean last)
Called by the provider when the web socket connection has an incoming partial text message from the given remote endpoint. Partial text messages are passed in sequential order, one piece at a time. If an implementation does not support streaming, it will need to reconstruct the message here and pass the whole thing along.

Parameters:
gs - SPIRemoteEndpoint who sent the message.
partialString - the String message.
last - to indicate if this is the last partial string in the sequence

onPartialMessage

public abstract void onPartialMessage(RemoteEndpoint gs,
                                      ByteBuffer partialBytes,
                                      boolean last)
Called by the provider when the web socket connection has an incoming partial binary message from the given remote endpoint. Partial binary messages are passed in sequential order, one piece at a time. If an implementation does not support streaming, it will need to reconstruct the message here and pass the whole thing along.

Parameters:
gs - SPIRemoteEndpoint who sent the message.
partialBytes - the piece of the binary message.
last - to indicate if this is the last partial byte buffer in the sequence

onMessage

public abstract void onMessage(RemoteEndpoint gs,
                               ByteBuffer bytes)
Called by the provider when the web socket connection has an incoming binary message from the given remote endpoint.

Parameters:
gs - SPIRemoteEndpoint who sent the message.
bytes - the message.

onPong

public abstract void onPong(RemoteEndpoint gs,
                            ByteBuffer bytes)
Called by the provider when the web socket connection has an incoming pong message from the given remote endpoint.

Parameters:
gs - SPIRemoteEndpoint who sent the message.
bytes - the message.

onPing

public abstract void onPing(RemoteEndpoint gs,
                            ByteBuffer bytes)
Called by the provider when the web socket connection has an incoming ping message from the given remote endpoint.

Parameters:
gs - SPIRemoteEndpoint who sent the message.
bytes - the message.

onClose

public abstract void onClose(RemoteEndpoint gs)
Called by the provider when the web socket connection to the given remote endpoint has just closed.

Parameters:
gs - SPIRemoteEndpoint who has just closed the connection.

remove

public abstract void remove()
Called by the provider after all connections have been closed to this endpoint, and after the endpoint has been removed from service.


getNegotiatedExtensions

public abstract List<String> getNegotiatedExtensions(List<String> clientExtensions)
Get the negotiated extensions' names based on the extensions supported by client.

Parameters:
clientExtensions - names of the extensions' supported by client.
Returns:
names of extensions supported by both client and class that implements this one.

getNegotiatedProtocol

public abstract String getNegotiatedProtocol(List<String> clientProtocols)
Compute the sub - protocol which will be used.

Parameters:
clientProtocols - sub - protocols supported by client.
Returns:
negotiated sub - protocol, null if none found.


Copyright © 2012. All Rights Reserved.