public class WebSocketEngine extends Object
WebSocketApplications registration, responsible
for client and server handshake validation.WebSocket,
WebSocketApplication| Modifier and Type | Class and Description |
|---|---|
static class |
WebSocketEngine.WebSocketHolder
WebSocketHolder object, which gets associated with the Grizzly
Connection. |
static class |
WebSocketEngine.WebSocketHolderListener
WebSocketEngine.WebSocketHolder listener. |
| Modifier and Type | Field and Description |
|---|---|
static String |
CONNECTION |
static Version |
DEFAULT_VERSION |
static String |
HOST |
static int |
MASK_SIZE |
static String |
ORIGIN_HEADER |
static String |
RESPONSE_CODE_MESSAGE |
static int |
RESPONSE_CODE_VALUE |
static String |
SEC_WS_ACCEPT |
static String |
SEC_WS_EXTENSIONS_HEADER |
static String |
SEC_WS_KEY_HEADER |
static String |
SEC_WS_ORIGIN_HEADER |
static String |
SEC_WS_PROTOCOL_HEADER |
static String |
SEC_WS_VERSION |
static String |
SERVER_KEY_HASH |
static String |
UPGRADE |
static String |
WEBSOCKET |
| Modifier and Type | Method and Description |
|---|---|
static WebSocketEngine |
getEngine() |
WebSocket |
getWebSocket(Connection connection)
Get the
WebSocket associated with the Grizzly Connection, or null, if there none is
associated. |
WebSocketEngine.WebSocketHolder |
getWebSocketHolder(Connection connection) |
void |
register(WebSocketApplication app)
Registers the specified
WebSocketApplication with the
WebSocketEngine. |
void |
removeConnection(Connection connection) |
WebSocketEngine.WebSocketHolder |
setWebSocketHolder(Connection connection,
ProtocolHandler handler,
WebSocketRequest request,
WebSocket socket,
WebSocketApplication application) |
static byte[] |
toArray(long length) |
static long |
toLong(byte[] bytes,
int start,
int end) |
static List<String> |
toString(byte[] bytes) |
void |
unregister(WebSocketApplication app)
Un-registers the specified
WebSocketApplication with the
WebSocketEngine. |
void |
unregisterAll()
Un-registers all
WebSocketApplication instances with the
WebSocketEngine. |
boolean |
upgrade(Connection connection,
WebSocketRequest request)
Evaluate whether connection/request is suitable for upgrade and perform it.
|
boolean |
upgrade(Connection connection,
WebSocketRequest request,
WebSocketEngine.WebSocketHolderListener webSocketHolderListener)
Evaluate whether connection/request is suitable for upgrade and perform it.
|
boolean |
webSocketInProgress(Connection connection)
Returns true if passed Grizzly
Connection is associated with a WebSocket, or
false otherwise. |
public static final String SEC_WS_ACCEPT
public static final String SEC_WS_KEY_HEADER
public static final String SEC_WS_ORIGIN_HEADER
public static final String ORIGIN_HEADER
public static final String SEC_WS_PROTOCOL_HEADER
public static final String SEC_WS_EXTENSIONS_HEADER
public static final String SEC_WS_VERSION
public static final String WEBSOCKET
public static final String RESPONSE_CODE_MESSAGE
public static final int RESPONSE_CODE_VALUE
public static final String UPGRADE
public static final String CONNECTION
public static final String HOST
public static final Version DEFAULT_VERSION
public static final String SERVER_KEY_HASH
public static final int MASK_SIZE
public static WebSocketEngine getEngine()
public static byte[] toArray(long length)
public static long toLong(byte[] bytes,
int start,
int end)
public boolean upgrade(Connection connection, WebSocketRequest request) throws IOException
connection - connection.request - request.true if upgrade is performed, false otherwise.IOException - if an I/O error occurred during the upgrade.public boolean upgrade(Connection connection, WebSocketRequest request, WebSocketEngine.WebSocketHolderListener webSocketHolderListener) throws HandshakeException
connection - connection.request - request.webSocketHolderListener - called when upgrade is going to be performed. Additinally, leaves
WebSocket.onConnect() call
responsibility to WebSocketEngine.WebSocketHolderListener instance.true if upgrade is performed, false otherwise.HandshakeException - if an error occurred during the upgrade.public void register(WebSocketApplication app) throws javax.websocket.DeploymentException
WebSocketApplication with the
WebSocketEngine.app - the WebSocketApplication to register.javax.websocket.DeploymentException - when added applications responds to same path as some already registered application.public void unregister(WebSocketApplication app)
WebSocketApplication with the
WebSocketEngine.app - the WebSocketApplication to un-register.public void unregisterAll()
WebSocketApplication instances with the
WebSocketEngine.public boolean webSocketInProgress(Connection connection)
Connection is associated with a WebSocket, or
false otherwise.connection - Grizzly Connection.Connection is associated with a WebSocket, or
false otherwise.public WebSocket getWebSocket(Connection connection)
WebSocket associated with the Grizzly Connection, or null, if there none is
associated.connection - Grizzly Connection.WebSocket associated with the Grizzly Connection, or null, if there none is
associated.public WebSocketEngine.WebSocketHolder getWebSocketHolder(Connection connection)
public WebSocketEngine.WebSocketHolder setWebSocketHolder(Connection connection, ProtocolHandler handler, WebSocketRequest request, WebSocket socket, WebSocketApplication application)
public void removeConnection(Connection connection)
Copyright © 2012-2013. All Rights Reserved.