Package org.atmosphere.websocket
Interface WebSocketProcessor
- All Known Implementing Classes:
DefaultWebSocketProcessor,WebSocketProcessorAdapter
public interface WebSocketProcessor
Atmosphere's WebSocket Support implementation. The default behavior is implemented in
This class can also be used to implement the JSR 345 recommendation.
DefaultWebSocketProcessor.
This class is targeted at framework developer as it requires Atmosphere's internal knowledge.
This class can also be used to implement the JSR 345 recommendation.
- Author:
- Jeanfrancois Arcand
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classAn exception that can be used to flag problems with the WebSocket processing.static final class -
Method Summary
Modifier and TypeMethodDescriptionvoidInvked when the WebServer is closing the native WebSocketconfigure(AtmosphereConfig config) Configure, or post construct a WebSocketProcessorvoiddestroy()Destroy all resources associated with this class.booleanhandshake(jakarta.servlet.http.HttpServletRequest request) Determine if the WebSocket's handshake data can be processed, or if the request be cancelled.voidinvokeWebSocketProtocol(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 containervoidnotifyListener(WebSocket webSocket, WebSocketEventListener.WebSocketEvent<?> webSocketEvent) Notify allWebSocketEventListenervoidopen(WebSocket webSocket, AtmosphereRequest request, AtmosphereResponse response) Invoked when a WebSocket gets opened by the underlying containerregisterWebSocketHandler(String path, WebSocketProcessor.WebSocketHandlerProxy webSockethandler) Register aWebSocketHandler
-
Method Details
-
configure
Configure, or post construct a WebSocketProcessor- Parameters:
config- anAtmosphereConfig- Returns:
- this
-
handshake
boolean handshake(jakarta.servlet.http.HttpServletRequest request) Determine 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.- Parameters:
request-HttpServletRequest- Returns:
- true if the processing can continue, false if not.
-
registerWebSocketHandler
WebSocketProcessor registerWebSocketHandler(String path, WebSocketProcessor.WebSocketHandlerProxy webSockethandler) Register aWebSocketHandler- Parameters:
path- the URI mapping the WebSocketHandlerwebSockethandler- an instance ofWebSocketProcessor.WebSocketHandlerProxy- Returns:
- this
-
open
void open(WebSocket webSocket, AtmosphereRequest request, AtmosphereResponse response) throws IOException Invoked when a WebSocket gets opened by the underlying container- Parameters:
request-- Throws:
IOException
-
invokeWebSocketProtocol
Invoked when a WebSocket message gets received from the underlying container- Parameters:
webSocketMessage-
-
invokeWebSocketProtocol
Invoked when a WebSocket message gets received from the underlying container- Parameters:
data-
-
invokeWebSocketProtocol
Invoked when a WebSocket message gets received from the underlying container- Parameters:
stream-
-
invokeWebSocketProtocol
Invoked when a WebSocket message gets received from the underlying container- Parameters:
reader-- Throws:
IOException
-
close
Invked when the WebServer is closing the native WebSocket- Parameters:
closeCode-
-
notifyListener
Notify allWebSocketEventListener- Parameters:
webSocketEvent-
-
destroy
void destroy()Destroy all resources associated with this class.
-