public abstract class BaseWebSocketFilter extends BaseFilter
Filter implementation, which supposed to be placed into a FilterChain right after HTTP
Filter: HttpServerFilter, HttpClientFilter; depending whether it's server or client side. The
BaseWebSocketFilter handles websocket connection, handshake phases and, when receives a websocket frame -
redirects it to appropriate connection (WebSocketApplication, WebSocket) for processing.| Constructor and Description |
|---|
BaseWebSocketFilter()
Constructs a new
BaseWebSocketFilter with a default idle connection
timeout of 15 minutes; |
BaseWebSocketFilter(long wsTimeoutInSeconds)
Constructs a new
BaseWebSocketFilter with a default idle connection
timeout of 15 minutes; |
| Modifier and Type | Method and Description |
|---|---|
NextAction |
handleClose(FilterChainContext ctx)
Method handles Grizzly
Connection close phase. |
protected abstract NextAction |
handleHandshake(FilterChainContext ctx,
HttpContent content)
Handle websocket handshake
|
NextAction |
handleRead(FilterChainContext ctx)
Handle Grizzly
Connection read phase. |
NextAction |
handleWrite(FilterChainContext ctx)
Handle Grizzly
Connection write phase. |
protected void |
onHandshakeFailure(Connection connection,
HandshakeException e)
The method is called when WebSocket handshake fails for the
Connection. |
protected void |
setIdleTimeout(FilterChainContext ctx) |
protected static boolean |
webSocketInProgress(Connection connection) |
createContext, exceptionOccurred, handleAccept, handleConnect, handleEvent, onAdded, onFilterChainChanged, onRemoved, toStringpublic BaseWebSocketFilter()
BaseWebSocketFilter with a default idle connection
timeout of 15 minutes;public BaseWebSocketFilter(long wsTimeoutInSeconds)
BaseWebSocketFilter with a default idle connection
timeout of 15 minutes;public NextAction handleClose(FilterChainContext ctx) throws IOException
Connection close phase. Check if the Connection is a WebSocket, if
yes - tries to close the websocket gracefully (sending close frame) and calls WebSocket.onClose(DataFrame). If the Grizzly Connection is not websocket - passes processing to the next
filter in the chain.handleClose in interface FilterhandleClose in class BaseFilterctx - FilterChainContextNextAction instruction for FilterChain, how it should continue the executionIOExceptionpublic NextAction handleRead(FilterChainContext ctx) throws IOException
Connection read phase. If the Connection has associated WebSocket object
(websocket connection), we check if websocket handshake has been completed for this connection, if not -
initiate/validate handshake. If handshake has been completed - parse websocket DataFrames one by one and
pass processing to appropriate WebSocket: WebSocketApplication for server- and client- side
connections.handleRead in interface FilterhandleRead in class BaseFilterctx - FilterChainContextNextAction instruction for FilterChain, how it should continue the executionIOExceptionpublic NextAction handleWrite(FilterChainContext ctx) throws IOException
Connection write phase. If the Connection has associated WebSocket object
(websocket connection), we assume that message is websocket DataFrame and serialize it into a Buffer.handleWrite in interface FilterhandleWrite in class BaseFilterctx - FilterChainContextNextAction instruction for FilterChain, how it should continue the executionIOExceptionprotected abstract NextAction handleHandshake(FilterChainContext ctx, HttpContent content) throws IOException
ctx - FilterChainContextcontent - HTTP messageNextAction instruction for FilterChain, how it should continue the executionIOExceptionprotected void onHandshakeFailure(Connection connection, HandshakeException e)
Connection.connection - e - protected static boolean webSocketInProgress(Connection connection)
protected void setIdleTimeout(FilterChainContext ctx)
Copyright © 2017 Oracle Corporation. All Rights Reserved.