Package org.atmosphere.websocket
Class DefaultWebSocketProcessor
java.lang.Object
org.atmosphere.websocket.DefaultWebSocketProcessor
- All Implemented Interfaces:
Serializable,WebSocketPingPongListener,WebSocketProcessor
public class DefaultWebSocketProcessor
extends Object
implements WebSocketProcessor, Serializable, WebSocketPingPongListener
Like the
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.- Author:
- Jeanfrancois Arcand
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.atmosphere.websocket.WebSocketProcessor
WebSocketProcessor.WebSocketException, WebSocketProcessor.WebSocketHandlerProxy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintbyteBufferMaxSize(int byteBufferMaxSize) intcharBufferMaxSize(int charBufferMaxSize) voidInvked when the WebServer is closing the native WebSocketlongconfigure(AtmosphereConfig config) Configure, or post construct a WebSocketProcessorconfigureHeader(AtmosphereRequest request) voiddestroy()Destroy all resources associated with this class.booleanfinal voiddispatch(WebSocket webSocket, AtmosphereRequest request, AtmosphereResponse r) Dispatch to request/response to theAsyncSupportimplementation as it was a normal HTTP request.protected voiddispatchReader(WebSocket webSocket, Reader r) protected voiddispatchStream(WebSocket webSocket, InputStream is) booleanvoidexecuteClose(WebSocket webSocket, int closeCode) handlers()booleanhandshake(javax.servlet.http.HttpServletRequest request) Determine if the WebSocket's handshake data can be processed, or if the request be cancelled.booleanvoidinvokeWebSocketProtocol(WebSocket webSocket, byte[] data, int offset, int length) Invoked when a WebSocket message gets received from the underlying containervoidinvokeWebSocketProtocol(WebSocket webSocket, InputStream stream) Invoked when a WebSocket message gets received from the underlying containervoidinvokeWebSocketProtocol(WebSocket webSocket, Reader reader) Invoked when a WebSocket message gets received from the underlying containervoidinvokeWebSocketProtocol(WebSocket webSocket, String webSocketMessage) Invoked when a WebSocket message gets received from the underlying containermapper()voidnotifyListener(WebSocket webSocket, WebSocketEventListener.WebSocketEvent<?> event) Notify allWebSocketEventListenervoidHandle WebSocket PINGvoidHandle WebSocket PONGfinal voidopen(WebSocket webSocket, AtmosphereRequest request, AtmosphereResponse response) Invoked when a WebSocket gets opened by the underlying containerprotected voidprotected WebSocketHandlerpostProcessMapping(WebSocket webSocket, AtmosphereRequest request, WebSocketProcessor.WebSocketHandlerProxy w) registerWebSocketHandler(String path, WebSocketProcessor.WebSocketHandlerProxy webSockethandler) Register aWebSocketHandlerbooleanwildcardMapping(boolean wildcardMapping)
-
Constructor Details
-
DefaultWebSocketProcessor
public DefaultWebSocketProcessor()
-
-
Method Details
-
configure
Description copied from interface:WebSocketProcessorConfigure, or post construct a WebSocketProcessor- Specified by:
configurein interfaceWebSocketProcessor- Parameters:
config- anAtmosphereConfig- Returns:
- this
-
handshake
public boolean handshake(javax.servlet.http.HttpServletRequest request) Description copied from interface:WebSocketProcessorDetermine if the WebSocket's handshake data can be processed, or if the request be cancelled. Since it's container related native API, theHttpServletRequestmight be null, so implementation must check for null.- Specified by:
handshakein interfaceWebSocketProcessor- Parameters:
request-HttpServletRequest- Returns:
- true if the processing can continue, false if not.
-
registerWebSocketHandler
public WebSocketProcessor registerWebSocketHandler(String path, WebSocketProcessor.WebSocketHandlerProxy webSockethandler) Description copied from interface:WebSocketProcessorRegister aWebSocketHandler- Specified by:
registerWebSocketHandlerin interfaceWebSocketProcessor- Parameters:
path- the URI mapping the WebSocketHandlerwebSockethandler- an instance ofWebSocketProcessor.WebSocketHandlerProxy- Returns:
- this
-
open
public final void open(WebSocket webSocket, AtmosphereRequest request, AtmosphereResponse response) throws IOException Description copied from interface:WebSocketProcessorInvoked when a WebSocket gets opened by the underlying container- Specified by:
openin interfaceWebSocketProcessor- Parameters:
request-- Throws:
IOException
-
postProcessMapping
protected WebSocketHandler postProcessMapping(WebSocket webSocket, AtmosphereRequest request, WebSocketProcessor.WebSocketHandlerProxy w) -
invokeWebSocketProtocol
Description copied from interface:WebSocketProcessorInvoked when a WebSocket message gets received from the underlying container- Specified by:
invokeWebSocketProtocolin interfaceWebSocketProcessor- Parameters:
webSocketMessage-
-
invokeWebSocketProtocol
Description copied from interface:WebSocketProcessorInvoked when a WebSocket message gets received from the underlying container- Specified by:
invokeWebSocketProtocolin interfaceWebSocketProcessor- Parameters:
data-
-
invokeWebSocketProtocol
Description copied from interface:WebSocketProcessorInvoked when a WebSocket message gets received from the underlying container- Specified by:
invokeWebSocketProtocolin interfaceWebSocketProcessor- Parameters:
stream-
-
invokeWebSocketProtocol
Description copied from interface:WebSocketProcessorInvoked when a WebSocket message gets received from the underlying container- Specified by:
invokeWebSocketProtocolin interfaceWebSocketProcessor- Parameters:
reader-
-
dispatch
Dispatch to request/response to theAsyncSupportimplementation as it was a normal HTTP request.- Parameters:
request- aAtmosphereRequestr- aAtmosphereResponse
-
close
Description copied from interface:WebSocketProcessorInvked when the WebServer is closing the native WebSocket- Specified by:
closein interfaceWebSocketProcessor- Parameters:
closeCode-
-
executeClose
-
destroy
public void destroy()Description copied from interface:WebSocketProcessorDestroy all resources associated with this class.- Specified by:
destroyin interfaceWebSocketProcessor
-
notifyListener
Description copied from interface:WebSocketProcessorNotify allWebSocketEventListener- Specified by:
notifyListenerin interfaceWebSocketProcessor- Parameters:
event-
-
configureHeader
-
dispatchStream
- Throws:
IOException
-
dispatchReader
- Throws:
IOException
-
optimizeMapping
protected void optimizeMapping() -
wildcardMapping
public boolean wildcardMapping() -
wildcardMapping
-
handlers
-
executeAsync
public boolean executeAsync() -
destroyable
public boolean destroyable() -
byteBufferMaxSize
public int byteBufferMaxSize() -
byteBufferMaxSize
-
charBufferMaxSize
public int charBufferMaxSize() -
charBufferMaxSize
-
closingTime
public long closingTime() -
mapper
-
invokeInterceptors
public boolean invokeInterceptors() -
onPong
Description copied from interface:WebSocketPingPongListenerHandle WebSocket PONG- Specified by:
onPongin interfaceWebSocketPingPongListener- Parameters:
webSocket-WebSocketpayload- the received bytesoffset- the offsetlength- the length
-
onPing
Description copied from interface:WebSocketPingPongListenerHandle WebSocket PING- Specified by:
onPingin interfaceWebSocketPingPongListener- Parameters:
webSocket-WebSocketpayload- the received bytesoffset- the offsetlength- the length
-