org.glassfish.tyrus.spi
Interface SPIEndpoint


public interface SPIEndpoint

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

Author:
dannycoward

Method Summary
 boolean checkHandshake(SPIHandshakeRequest hr)
          This method must be called by the provider during its check for a successful websocket handshake.
 java.util.List<java.lang.String> getSupportedProtocols(java.util.List<java.lang.String> subProtocols)
          Called by the provider during the handshake to determine a list of subprotocols this endpoint will support of those passed in.
 void onClose(SPIRemoteEndpoint gs)
          Called by the provider when the web socket connection to the given remote endpoint has just closed.
 void onConnect(SPIRemoteEndpoint gs)
          Called by the provider when the web socket connection is established.
 void onMessage(SPIRemoteEndpoint gs, byte[] messageBytes)
          Called by the provider when the web socket connection has an incoming binary message from the given remote endpoint.
 void onMessage(SPIRemoteEndpoint gs, java.lang.String messageString)
          Called by the provider when the web socket connection has an incoming text message from the given remote endpoint.
 void remove()
          Called by the provider after all connections have been closed to this endpoint, and after the endpoint has been removed from service.
 

Method Detail

checkHandshake

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

void onConnect(SPIRemoteEndpoint gs)
Called by the provider when the web socket connection is established.

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

onMessage

void onMessage(SPIRemoteEndpoint gs,
               java.lang.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.

onMessage

void onMessage(SPIRemoteEndpoint gs,
               byte[] messageBytes)
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.
messageBytes - the byte[] message.

onClose

void onClose(SPIRemoteEndpoint 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.

getSupportedProtocols

java.util.List<java.lang.String> getSupportedProtocols(java.util.List<java.lang.String> subProtocols)
Called by the provider during the handshake to determine a list of subprotocols this endpoint will support of those passed in.

Parameters:
subProtocols - the subprotocols to be checked.
Returns:
List of supported subprotocols.

remove

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



Copyright © 2012. All Rights Reserved.