public class DefaultWebSocketProcessor extends java.lang.Object implements WebSocketProcessor, java.io.Serializable
AsynchronousProcessor class, this class is responsible for dispatching WebSocket request to the
proper WebSocket implementation. This class can be extended in order to support any protocol
running on top websocket.WebSocketProcessor.WebSocketException, WebSocketProcessor.WebSocketHandlerProxy| Constructor and Description |
|---|
DefaultWebSocketProcessor(AtmosphereFramework framework) |
| Modifier and Type | Method and Description |
|---|---|
void |
close(WebSocket webSocket,
int closeCode)
Invked when the WebServer is closing the native WebSocket
|
static java.util.Map<java.lang.String,java.lang.String> |
configureHeader(AtmosphereRequest request) |
void |
destroy()
Destroy all resources associated with this class.
|
void |
dispatch(WebSocket webSocket,
AtmosphereRequest request,
AtmosphereResponse r)
Dispatch to request/response to the
AsyncSupport implementation as it was a normal HTTP request. |
protected void |
dispatchReader(WebSocket webSocket,
java.io.Reader r) |
protected void |
dispatchStream(WebSocket webSocket,
java.io.InputStream is) |
void |
executeClose(AsynchronousProcessor.AsynchronousProcessorHook h,
WebSocket webSocket,
int closeCode) |
int |
getByteBufferMaxSize()
Obtain the current maximum size (in bytes) of the buffer used for binary
messages.
|
int |
getCharBufferMaxSize()
Obtain the current maximum size (in characters) of the buffer used for
binary messages.
|
boolean |
handshake(javax.servlet.http.HttpServletRequest request)
Determine if the WebSocket's handshake data can be processed, or if the request be cancelled.
|
void |
invokeWebSocketProtocol(WebSocket webSocket,
byte[] data,
int offset,
int length)
Invoked when a WebSocket message gets received from the underlying container
|
void |
invokeWebSocketProtocol(WebSocket webSocket,
java.io.InputStream stream)
Invoked when a WebSocket message gets received from the underlying container
|
void |
invokeWebSocketProtocol(WebSocket webSocket,
java.io.Reader reader)
Invoked when a WebSocket message gets received from the underlying container
|
void |
invokeWebSocketProtocol(WebSocket webSocket,
java.lang.String webSocketMessage)
Invoked when a WebSocket message gets received from the underlying container
|
void |
notifyListener(WebSocket webSocket,
WebSocketEventListener.WebSocketEvent event)
Notify all
WebSocketEventListener |
void |
open(WebSocket webSocket,
AtmosphereRequest request,
AtmosphereResponse response)
Invoked when a WebSocket gets opened by the underlying container
|
protected void |
optimizeMapping() |
protected WebSocketHandler |
postProcessMapping(WebSocket webSocket,
AtmosphereRequest request,
WebSocketProcessor.WebSocketHandlerProxy w) |
WebSocketProcessor |
registerWebSocketHandler(java.lang.String path,
WebSocketProcessor.WebSocketHandlerProxy webSockethandler)
Register a
WebSocketHandler |
void |
setByteBufferMaxSize(int byteBufferMaxSize)
Set the maximum size (in bytes) of the buffer used for binary messages.
|
void |
setCharBufferMaxSize(int charBufferMaxSize)
Set the maximum size (in characters) of the buffer used for textual
messages.
|
boolean |
wildcardMapping() |
public DefaultWebSocketProcessor(AtmosphereFramework framework)
public boolean handshake(javax.servlet.http.HttpServletRequest request)
WebSocketProcessorHttpServletRequest might be null, so implementation must check for null.handshake in interface WebSocketProcessorrequest - HttpServletRequestpublic WebSocketProcessor registerWebSocketHandler(java.lang.String path, WebSocketProcessor.WebSocketHandlerProxy webSockethandler)
WebSocketProcessorWebSocketHandlerregisterWebSocketHandler in interface WebSocketProcessorpath - the URI mapping the WebSocketHandlerwebSockethandler - an instance of WebSocketProcessor.WebSocketHandlerProxypublic final void open(WebSocket webSocket, AtmosphereRequest request, AtmosphereResponse response) throws java.io.IOException
WebSocketProcessoropen in interface WebSocketProcessorjava.io.IOExceptionprotected WebSocketHandler postProcessMapping(WebSocket webSocket, AtmosphereRequest request, WebSocketProcessor.WebSocketHandlerProxy w)
public void invokeWebSocketProtocol(WebSocket webSocket, java.lang.String webSocketMessage)
WebSocketProcessorinvokeWebSocketProtocol in interface WebSocketProcessorpublic void invokeWebSocketProtocol(WebSocket webSocket, byte[] data, int offset, int length)
WebSocketProcessorinvokeWebSocketProtocol in interface WebSocketProcessorpublic void invokeWebSocketProtocol(WebSocket webSocket, java.io.InputStream stream)
WebSocketProcessorinvokeWebSocketProtocol in interface WebSocketProcessorpublic void invokeWebSocketProtocol(WebSocket webSocket, java.io.Reader reader)
WebSocketProcessorinvokeWebSocketProtocol in interface WebSocketProcessorpublic final void dispatch(WebSocket webSocket, AtmosphereRequest request, AtmosphereResponse r)
AsyncSupport implementation as it was a normal HTTP request.request - a AtmosphereRequestr - a AtmosphereResponsepublic void close(WebSocket webSocket, int closeCode)
WebSocketProcessorclose in interface WebSocketProcessorpublic void executeClose(AsynchronousProcessor.AsynchronousProcessorHook h, WebSocket webSocket, int closeCode)
public void destroy()
WebSocketProcessordestroy in interface WebSocketProcessorpublic void notifyListener(WebSocket webSocket, WebSocketEventListener.WebSocketEvent event)
WebSocketProcessorWebSocketEventListenernotifyListener in interface WebSocketProcessorpublic static final java.util.Map<java.lang.String,java.lang.String> configureHeader(AtmosphereRequest request)
protected void dispatchStream(WebSocket webSocket, java.io.InputStream is) throws java.io.IOException
java.io.IOExceptionprotected void dispatchReader(WebSocket webSocket, java.io.Reader r) throws java.io.IOException
java.io.IOExceptionpublic final int getByteBufferMaxSize()
public final void setByteBufferMaxSize(int byteBufferMaxSize)
public final int getCharBufferMaxSize()
public final void setCharBufferMaxSize(int charBufferMaxSize)
protected void optimizeMapping()
public boolean wildcardMapping()
Copyright © 2018. All Rights Reserved.