public abstract class WebSocketApplication extends Object implements WebSocketListener
| Constructor and Description |
|---|
WebSocketApplication() |
| Modifier and Type | Method and Description |
|---|---|
WebSocket |
createSocket(ProtocolHandler handler,
WebSocketRequest requestPacket,
WebSocketListener... listeners)
Factory method to create new
WebSocket instances. |
List<Extension> |
getSupportedExtensions()
Return the websocket extensions supported by this
WebSocketApplication. |
List<String> |
getSupportedProtocols(List<String> subProtocol) |
protected Set<WebSocket> |
getWebSockets()
Returns a set of
WebSockets, registered with the application. |
protected void |
handshake(HandShake handshake)
This method will be called, when initial
WebSocket handshake
process has been completed, but allows the application to perform further
negotiation/validation. |
protected abstract boolean |
isApplicationRequest(WebSocketRequest request)
Checks application specific criteria to determine if this application can
process the request as a WebSocket connection.
|
void |
onClose(WebSocket socket,
ClosingFrame frame)
When a
WebSocket.onClose(org.glassfish.tyrus.websockets.draft06.ClosingFrame) is invoked, the WebSocket
will be unassociated with this application and closed. |
void |
onConnect(WebSocket socket)
|
boolean |
onError(WebSocket webSocket,
Throwable t)
This method will be invoked if an unexpected exception is caught by
the WebSocket runtime.
|
void |
onExtensionNegotiation(List<Extension> extensions)
Invoked during the handshake if the client has advertised extensions
it may use and one or more extensions intersect with those returned
by
getSupportedExtensions(). |
abstract void |
onHandShakeResponse(WebSocketRequest request,
WebSocketResponse response)
Invoked when server side handshake is ready to send response.
|
boolean |
upgrade(WebSocketRequest request)
Checks protocol specific information can and should be upgraded.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonFragment, onFragment, onMessage, onMessage, onPing, onPongpublic WebSocket createSocket(ProtocolHandler handler, WebSocketRequest requestPacket, WebSocketListener... listeners)
WebSocket instances. Developers may
wish to override this to return customized WebSocket implementations.handler - the ProtocolHandler to use with the newly created
WebSocket.requestPacket - the WebSocketRequest that triggered the
creation of the WebSocket connection.listeners - the WebSocketListeners to associate with the new
WebSocket.public void onClose(WebSocket socket, ClosingFrame frame)
WebSocket.onClose(org.glassfish.tyrus.websockets.draft06.ClosingFrame) is invoked, the WebSocket
will be unassociated with this application and closed.onClose in interface WebSocketListenersocket - the WebSocket being closed.frame - the closing frame.public void onConnect(WebSocket socket)
WebSocket connection is made to this application, the
WebSocket will be associated with this application.onConnect in interface WebSocketListenersocket - the new WebSocket connection.public void onExtensionNegotiation(List<Extension> extensions)
getSupportedExtensions().
The Extensions passed to this method will include any extension
parameters included by the client. It's up to this method to re-order
and or adjust any parameter values within the list. This method must not
add any extensions that weren't originally in the list, but it is acceptable
to remove one or all extensions if for some reason they can't be supported.
If not overridden, the List will be sent as-is back to the client.extensions - the intersection of extensions between client and
application.public final boolean upgrade(WebSocketRequest request)
Upgrade header with a value of WebSocket.
If present, isApplicationRequest(WebSocketRequest)
will be invoked to determine if the request is a valid websocket request.request - TODOtrue if the request should be upgraded to a
WebSocket connectionpublic boolean onError(WebSocket webSocket, Throwable t)
webSocket - the websocket being processed at the time the
exception occurred.t - the unexpected exception.true if the WebSocket should be closed otherwise
false.public abstract void onHandShakeResponse(WebSocketRequest request, WebSocketResponse response)
request - original request which caused this handshake.response - response to be send.protected abstract boolean isApplicationRequest(WebSocketRequest request)
request - the incoming HTTP request.true if this application can service this requestpublic List<Extension> getSupportedExtensions()
WebSocketApplication.
The Extensions added to this List should not include
any Extension.Parameters as they will be ignored. This is used
exclusively for matching the requested extensions.WebSocketApplication.public List<String> getSupportedProtocols(List<String> subProtocol)
subProtocol - TODOprotected Set<WebSocket> getWebSockets()
WebSockets, registered with the application.
The returned set is unmodifiable, the possible modifications may cause exceptions.WebSockets, registered with the application.protected void handshake(HandShake handshake) throws HandshakeException
WebSocket handshake
process has been completed, but allows the application to perform further
negotiation/validation.handshake - TODOHandshakeException - error occurred during the handshake.Copyright © 2012-2013. All Rights Reserved.