org.atmosphere.websocket.protocol
Class EchoProtocol

java.lang.Object
  extended by org.atmosphere.websocket.protocol.EchoProtocol
All Implemented Interfaces:
WebSocketProtocol

public class EchoProtocol
extends Object
implements WebSocketProtocol

Simple WebSocketProcessor that invoke the Broadcaster.broadcast(T) 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
EchoProtocol()
           
 
Method Summary
 void configure(AtmosphereServlet.AtmosphereConfig config)
          Allow an implementation to query the AtmosphereConfig of init-param, etc.
 javax.servlet.http.HttpServletRequest parseMessage(AtmosphereResource resource, byte[] data, int offset, int length)
          Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology.
 javax.servlet.http.HttpServletRequest parseMessage(AtmosphereResource resource, String data)
          Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EchoProtocol

public EchoProtocol()
Method Detail

parseMessage

public javax.servlet.http.HttpServletRequest parseMessage(AtmosphereResource resource,
                                                          String data)
Description copied from interface: WebSocketProtocol
Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology. Invoking AtmosphereServlet.cometSupport will delegate the request processing to the AtmosphereHandler implementation. 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:
parseMessage in interface WebSocketProtocol
Parameters:
resource - The AtmosphereResource associated with the WebSocket Handshake
data - The Websocket message

parseMessage

public javax.servlet.http.HttpServletRequest parseMessage(AtmosphereResource resource,
                                                          byte[] data,
                                                          int offset,
                                                          int length)
Description copied from interface: WebSocketProtocol
Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology. Invoking AtmosphereServlet.cometSupport will delegate the request processing to the AtmosphereHandler implementation. 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:
parseMessage in interface WebSocketProtocol
Parameters:
resource - The AtmosphereResource associated with the WebSocket Handshake
data - The Websocket message
offset - offset message index
length - length of the message.

configure

public void configure(AtmosphereServlet.AtmosphereConfig config)
Description copied from interface: WebSocketProtocol
Allow an implementation to query the AtmosphereConfig of init-param, etc.

Specified by:
configure in interface WebSocketProtocol
Parameters:
config - AtmosphereServlet.AtmosphereConfig


Copyright © 2011. All Rights Reserved.