public class DefaultWebSocketProcessor extends Object implements WebSocketProcessor, Serializable, WebSocketPingPongListener
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() |
| Modifier and Type | Method and Description |
|---|---|
int |
byteBufferMaxSize() |
DefaultWebSocketProcessor |
byteBufferMaxSize(int byteBufferMaxSize) |
int |
charBufferMaxSize() |
DefaultWebSocketProcessor |
charBufferMaxSize(int charBufferMaxSize) |
void |
close(WebSocket webSocket,
int closeCode)
Invked when the WebServer is closing the native WebSocket
|
long |
closingTime() |
WebSocketProcessor |
configure(AtmosphereConfig config)
Configure, or post construct a WebSocketProcessor
|
static Map<String,String> |
configureHeader(AtmosphereRequest request) |
void |
destroy()
Destroy all resources associated with this class.
|
boolean |
destroyable() |
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,
Reader r) |
protected void |
dispatchStream(WebSocket webSocket,
InputStream is) |
boolean |
executeAsync() |
void |
executeClose(WebSocket webSocket,
int closeCode) |
Map<String,WebSocketProcessor.WebSocketHandlerProxy> |
handlers() |
boolean |
handshake(javax.servlet.http.HttpServletRequest request)
Determine if the WebSocket's handshake data can be processed, or if the request be cancelled.
|
boolean |
invokeInterceptors() |
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,
InputStream stream)
Invoked when a WebSocket message gets received from the underlying container
|
void |
invokeWebSocketProtocol(WebSocket webSocket,
Reader reader)
Invoked when a WebSocket message gets received from the underlying container
|
void |
invokeWebSocketProtocol(WebSocket webSocket,
String webSocketMessage)
Invoked when a WebSocket message gets received from the underlying container
|
EndpointMapper<WebSocketProcessor.WebSocketHandlerProxy> |
mapper() |
void |
notifyListener(WebSocket webSocket,
WebSocketEventListener.WebSocketEvent event)
Notify all
WebSocketEventListener |
void |
onPing(WebSocket webSocket,
byte[] payload,
int offset,
int length)
Handle WebSocket PING
|
void |
onPong(WebSocket webSocket,
byte[] payload,
int offset,
int length)
Handle WebSocket PONG
|
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(String path,
WebSocketProcessor.WebSocketHandlerProxy webSockethandler)
Register a
WebSocketHandler |
boolean |
wildcardMapping() |
DefaultWebSocketProcessor |
wildcardMapping(boolean wildcardMapping) |
public WebSocketProcessor configure(AtmosphereConfig config)
WebSocketProcessorconfigure in interface WebSocketProcessorconfig - an AtmosphereConfigpublic boolean handshake(javax.servlet.http.HttpServletRequest request)
WebSocketProcessorHttpServletRequest might be null, so implementation must check for null.handshake in interface WebSocketProcessorrequest - HttpServletRequestpublic WebSocketProcessor registerWebSocketHandler(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 IOException
WebSocketProcessoropen in interface WebSocketProcessorIOExceptionprotected WebSocketHandler postProcessMapping(WebSocket webSocket, AtmosphereRequest request, WebSocketProcessor.WebSocketHandlerProxy w)
public void invokeWebSocketProtocol(WebSocket webSocket, String webSocketMessage)
WebSocketProcessorinvokeWebSocketProtocol in interface WebSocketProcessorpublic void invokeWebSocketProtocol(WebSocket webSocket, byte[] data, int offset, int length)
WebSocketProcessorinvokeWebSocketProtocol in interface WebSocketProcessorpublic void invokeWebSocketProtocol(WebSocket webSocket, InputStream stream)
WebSocketProcessorinvokeWebSocketProtocol in interface WebSocketProcessorpublic void invokeWebSocketProtocol(WebSocket webSocket, 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(WebSocket webSocket, int closeCode)
public void destroy()
WebSocketProcessordestroy in interface WebSocketProcessorpublic void notifyListener(WebSocket webSocket, WebSocketEventListener.WebSocketEvent event)
WebSocketProcessorWebSocketEventListenernotifyListener in interface WebSocketProcessorpublic static final Map<String,String> configureHeader(AtmosphereRequest request)
protected void dispatchStream(WebSocket webSocket, InputStream is) throws IOException
IOExceptionprotected void dispatchReader(WebSocket webSocket, Reader r) throws IOException
IOExceptionprotected void optimizeMapping()
public boolean wildcardMapping()
public DefaultWebSocketProcessor wildcardMapping(boolean wildcardMapping)
public Map<String,WebSocketProcessor.WebSocketHandlerProxy> handlers()
public boolean executeAsync()
public boolean destroyable()
public int byteBufferMaxSize()
public DefaultWebSocketProcessor byteBufferMaxSize(int byteBufferMaxSize)
public int charBufferMaxSize()
public DefaultWebSocketProcessor charBufferMaxSize(int charBufferMaxSize)
public long closingTime()
public EndpointMapper<WebSocketProcessor.WebSocketHandlerProxy> mapper()
public boolean invokeInterceptors()
public void onPong(WebSocket webSocket, byte[] payload, int offset, int length)
WebSocketPingPongListeneronPong in interface WebSocketPingPongListenerwebSocket - WebSocketpayload - the received bytesoffset - the offsetlength - the lengthpublic void onPing(WebSocket webSocket, byte[] payload, int offset, int length)
WebSocketPingPongListeneronPing in interface WebSocketPingPongListenerwebSocket - WebSocketpayload - the received bytesoffset - the offsetlength - the lengthCopyright © 2016. All rights reserved.