Class EchoProtocol
- java.lang.Object
-
- org.atmosphere.websocket.protocol.EchoProtocol
-
- All Implemented Interfaces:
AtmosphereConfigAware,WebSocketProtocol
public class EchoProtocol extends java.lang.Object implements WebSocketProtocol
SimpleWebSocketProcessorthat invoke theBroadcaster.broadcast(java.lang.Object)API when a WebSocket message is received. NOTE: If WebSocket frame are used the bytes will be decoded into a String, which reduce performance.- Author:
- Jeanfrancois Arcand
-
-
Constructor Summary
Constructors Constructor Description EchoProtocol()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(AtmosphereConfig config)Configure an AtmosphereFramework object.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
-
-
-
Method Detail
-
onMessage
public java.util.List<AtmosphereRequest> onMessage(WebSocket webSocket, java.lang.String data)
Description copied from interface:WebSocketProtocolParse 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.- Specified by:
onMessagein interfaceWebSocketProtocol- Parameters:
webSocket- TheWebSocketconnectiondata- The Websocket message- Returns:
- a List of
AtmosphereRequest
-
onMessage
public java.util.List<AtmosphereRequest> onMessage(WebSocket webSocket, byte[] data, int offset, int length)
Description copied from interface:WebSocketProtocolParse 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.- Specified by:
onMessagein interfaceWebSocketProtocol- Parameters:
webSocket- TheWebSocketconnectionoffset- offset message indexlength- length of the message.- Returns:
- a List of
AtmosphereRequest
-
configure
public void configure(AtmosphereConfig config)
Description copied from interface:AtmosphereConfigAwareConfigure an AtmosphereFramework object.- Specified by:
configurein interfaceAtmosphereConfigAware- Parameters:
config-AtmosphereConfig
-
onOpen
public void onOpen(WebSocket webSocket)
Description copied from interface:WebSocketProtocolInvoked when a WebSocket is opened- Specified by:
onOpenin interfaceWebSocketProtocol- Parameters:
webSocket-WebSocket
-
onClose
public void onClose(WebSocket webSocket)
Description copied from interface:WebSocketProtocolInvoked when a WebSocket is closed- Specified by:
onClosein interfaceWebSocketProtocol- Parameters:
webSocket-WebSocket
-
onError
public void onError(WebSocket webSocket, WebSocketProcessor.WebSocketException t)
Description copied from interface:WebSocketProtocolInvoked when an error occurs.- Specified by:
onErrorin interfaceWebSocketProtocol- Parameters:
webSocket-WebSockett- aWebSocketProcessor.WebSocketException
-
-