org.atmosphere.websocket
Class WebSocketAtmosphereHandler

java.lang.Object
  extended by org.atmosphere.handler.AbstractReflectorAtmosphereHandler
      extended by org.atmosphere.websocket.WebSocketAtmosphereHandler
All Implemented Interfaces:
AtmosphereHandler<HttpServletRequest,HttpServletResponse>

public class WebSocketAtmosphereHandler
extends AbstractReflectorAtmosphereHandler

Simple AtmosphereHandler which redirect the first request to the web application welcome page. Once the WebSocket upgrade happens, this class just invoke the upgrade(AtmosphereResource) method.

Application should override the upgrade(AtmosphereResource). Application should override the AbstractReflectorAtmosphereHandler.onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent) if they do not want to reflect/send back all Websocket messages to all connections.

Author:
Jeanfrancois Arcand

Constructor Summary
WebSocketAtmosphereHandler()
           
 
Method Summary
 void onRequest(AtmosphereResource<HttpServletRequest,HttpServletResponse> r)
          This method redirect the request to the server main page (index.html, index.jsp, etc.) and then execute the upgrade(AtmosphereResource).
 void upgrade(AtmosphereResource r)
          WebSocket upgrade.
 
Methods inherited from class org.atmosphere.handler.AbstractReflectorAtmosphereHandler
onStateChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebSocketAtmosphereHandler

public WebSocketAtmosphereHandler()
Method Detail

onRequest

public void onRequest(AtmosphereResource<HttpServletRequest,HttpServletResponse> r)
               throws IOException
This method redirect the request to the server main page (index.html, index.jsp, etc.) and then execute the upgrade(AtmosphereResource).

Parameters:
r - The AtmosphereResource
Throws:
IOException

upgrade

public void upgrade(AtmosphereResource r)
             throws IOException
WebSocket upgrade. This is usually inside that method that you decide if a connection needs to be suspended or not. Override this method for specific operations like configuring their own Broadcaster, BroadcastFilter , BroadcasterCache etc.

Parameters:
r - an AtmosphereResource
Throws:
IOException


Copyright © 2010. All Rights Reserved.