org.atmosphere.websocket
Class WebSocketProcessor

java.lang.Object
  extended by org.atmosphere.websocket.WebSocketProcessor
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EchoProtocol, SimpleHttpProtocol

public abstract class WebSocketProcessor
extends Object
implements Serializable

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:
Serialized Form

Constructor Summary
WebSocketProcessor(AtmosphereServlet atmosphereServlet, WebSocket webSocket)
           
 
Method Summary
 void close()
           
protected  Map<String,String> configureHeader(javax.servlet.http.HttpServletRequest request)
           
 void dispatch(javax.servlet.http.HttpServletRequest request)
           
protected  void dispatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Dispatch to request/response to the CometSupport implementation as it was a normal HTTP request.
 void notifyListener(WebSocketEventListener.WebSocketEvent event)
           
abstract  void parseMessage(byte[] data, int offset, int length)
          Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology.
abstract  void parseMessage(String data)
          Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology.
 javax.servlet.http.HttpServletRequest request()
           
 AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> resource()
           
 String toString()
           
 WebSocket webSocketSupport()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebSocketProcessor

public WebSocketProcessor(AtmosphereServlet atmosphereServlet,
                          WebSocket webSocket)
Method Detail

dispatch

public final void dispatch(javax.servlet.http.HttpServletRequest request)
                    throws IOException
Throws:
IOException

dispatch

protected final void dispatch(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
Dispatch to request/response to the CometSupport implementation as it was a normal HTTP request.

Parameters:
request - a HttpServletRequest
response - a HttpServletResponse

resource

public AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> resource()

request

public javax.servlet.http.HttpServletRequest request()

webSocketSupport

public WebSocket webSocketSupport()

parseMessage

public abstract void parseMessage(String data)
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. As an example, this is how Websocket messages are delegated to the Jersey runtime.

Parameters:
data - The Websocket message

parseMessage

public abstract void parseMessage(byte[] data,
                                  int offset,
                                  int length)
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. As an example, this is how Websocket messages are delegated to the Jersey runtime.

Parameters:
data - The Websocket message
offset - offset message index
length - length of the message.

close

public void close()

toString

public String toString()
Overrides:
toString in class Object

notifyListener

public void notifyListener(WebSocketEventListener.WebSocketEvent event)

configureHeader

protected Map<String,String> configureHeader(javax.servlet.http.HttpServletRequest request)


Copyright © 2011. All Rights Reserved.