Package org.atmosphere.websocket
Interface WebSocketProtocol
-
- All Superinterfaces:
AtmosphereConfigAware
- All Known Subinterfaces:
WebSocketProtocolStream
- All Known Implementing Classes:
EchoProtocol,SimpleHttpProtocol,StreamingHttpProtocol
public interface WebSocketProtocol extends AtmosphereConfigAware
A WebSocket based protocol implementation. Implement this class to process WebSockets messages and dispatch it to Atmosphere or any consumer of WebSocket message.- Author:
- Jeanfrancois Arcand
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidonClose(WebSocket webSocket)Invoked when a WebSocket is closedvoidonError(WebSocket webSocket, WebSocketProcessor.WebSocketException t)Invoked when an error occurs.java.util.List<AtmosphereRequest>onMessage(WebSocket webSocket, byte[] data, int offset, int length)Parse the WebSocket message, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology.java.util.List<AtmosphereRequest>onMessage(WebSocket webSocket, java.lang.String data)Parse the WebSocket message, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology.voidonOpen(WebSocket webSocket)Invoked when a WebSocket is opened-
Methods inherited from interface org.atmosphere.inject.AtmosphereConfigAware
configure
-
-
-
-
Method Detail
-
onMessage
java.util.List<AtmosphereRequest> onMessage(WebSocket webSocket, java.lang.String data)
Parse the WebSocket message, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology. InvokingAtmosphereFramework.asyncSupportwill delegate the request processing to theAtmosphereHandlerimplementation. Returning null means this implementation will handle itself the processing/dispatching of the WebSocket's request;
As an example, this is how Websocket messages are delegated to the Jersey runtime.- Parameters:
webSocket- TheWebSocketconnectiondata- The Websocket message- Returns:
- a List of
AtmosphereRequest
-
onMessage
java.util.List<AtmosphereRequest> onMessage(WebSocket webSocket, byte[] data, int offset, int length)
Parse the WebSocket message, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology. InvokingAtmosphereFramework.asyncSupportwill delegate the request processing to theAtmosphereHandlerimplementation. Returning null means this implementation will handle itself the processing/dispatching of the WebSocket's request;
As an example, this is how Websocket messages are delegated to the Jersey runtime.- Parameters:
webSocket- TheWebSocketconnectionoffset- offset message indexlength- length of the message.- Returns:
- a List of
AtmosphereRequest
-
onOpen
void onOpen(WebSocket webSocket)
Invoked when a WebSocket is opened- Parameters:
webSocket-WebSocket
-
onClose
void onClose(WebSocket webSocket)
Invoked when a WebSocket is closed- Parameters:
webSocket-WebSocket
-
onError
void onError(WebSocket webSocket, WebSocketProcessor.WebSocketException t)
Invoked when an error occurs.- Parameters:
webSocket-WebSockett- aWebSocketProcessor.WebSocketException
-
-