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)
WebSocketProcessor
configure
in interface WebSocketProcessor
config
- an AtmosphereConfig
public boolean handshake(javax.servlet.http.HttpServletRequest request)
WebSocketProcessor
HttpServletRequest
might be null, so implementation must check for null.handshake
in interface WebSocketProcessor
request
- HttpServletRequest
public WebSocketProcessor registerWebSocketHandler(String path, WebSocketProcessor.WebSocketHandlerProxy webSockethandler)
WebSocketProcessor
WebSocketHandler
registerWebSocketHandler
in interface WebSocketProcessor
path
- the URI mapping the WebSocketHandlerwebSockethandler
- an instance of WebSocketProcessor.WebSocketHandlerProxy
public final void open(WebSocket webSocket, AtmosphereRequest request, AtmosphereResponse response) throws IOException
WebSocketProcessor
open
in interface WebSocketProcessor
IOException
protected WebSocketHandler postProcessMapping(WebSocket webSocket, AtmosphereRequest request, WebSocketProcessor.WebSocketHandlerProxy w)
public void invokeWebSocketProtocol(WebSocket webSocket, String webSocketMessage)
WebSocketProcessor
invokeWebSocketProtocol
in interface WebSocketProcessor
public void invokeWebSocketProtocol(WebSocket webSocket, byte[] data, int offset, int length)
WebSocketProcessor
invokeWebSocketProtocol
in interface WebSocketProcessor
public void invokeWebSocketProtocol(WebSocket webSocket, InputStream stream)
WebSocketProcessor
invokeWebSocketProtocol
in interface WebSocketProcessor
public void invokeWebSocketProtocol(WebSocket webSocket, Reader reader)
WebSocketProcessor
invokeWebSocketProtocol
in interface WebSocketProcessor
public final void dispatch(WebSocket webSocket, AtmosphereRequest request, AtmosphereResponse r)
AsyncSupport
implementation as it was a normal HTTP request.request
- a AtmosphereRequest
r
- a AtmosphereResponse
public void close(WebSocket webSocket, int closeCode)
WebSocketProcessor
close
in interface WebSocketProcessor
public void executeClose(WebSocket webSocket, int closeCode)
public void destroy()
WebSocketProcessor
destroy
in interface WebSocketProcessor
public void notifyListener(WebSocket webSocket, WebSocketEventListener.WebSocketEvent event)
WebSocketProcessor
WebSocketEventListener
notifyListener
in interface WebSocketProcessor
public static final Map<String,String> configureHeader(AtmosphereRequest request)
protected void dispatchStream(WebSocket webSocket, InputStream is) throws IOException
IOException
protected void dispatchReader(WebSocket webSocket, Reader r) throws IOException
IOException
protected 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)
WebSocketPingPongListener
onPong
in interface WebSocketPingPongListener
webSocket
- WebSocket
payload
- the received bytesoffset
- the offsetlength
- the lengthpublic void onPing(WebSocket webSocket, byte[] payload, int offset, int length)
WebSocketPingPongListener
onPing
in interface WebSocketPingPongListener
webSocket
- WebSocket
payload
- the received bytesoffset
- the offsetlength
- the lengthCopyright © 2016. All rights reserved.