org.atmosphere.samples.counter
Class CounterLongPollingAtmosphereHandler

java.lang.Object
  extended by org.atmosphere.samples.counter.CounterLongPollingAtmosphereHandler
All Implemented Interfaces:
org.atmosphere.cpr.AtmosphereHandler<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>

public class CounterLongPollingAtmosphereHandler
extends Object
implements org.atmosphere.cpr.AtmosphereHandler<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>

Simple application that demonstrate how a Comet long poll request can be implemented. Mainly, the client send a GET, the AtmosphereHandler suspend the connection. As soon a POST request arrive, the underlying response is resumed.

Author:
Jeanfrancois Arcand

Constructor Summary
CounterLongPollingAtmosphereHandler()
           
 
Method Summary
 void onRequest(org.atmosphere.cpr.AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> event)
          On GET, suspend the conneciton.
 void onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> event)
          Resume the underlying response on the first Broadcast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CounterLongPollingAtmosphereHandler

public CounterLongPollingAtmosphereHandler()
Method Detail

onRequest

public void onRequest(org.atmosphere.cpr.AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> event)
               throws IOException
On GET, suspend the conneciton. On POST, resume the connection.

Specified by:
onRequest in interface org.atmosphere.cpr.AtmosphereHandler<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>
Parameters:
event -
Throws:
IOException

onStateChange

public void onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> event)
                   throws IOException
Resume the underlying response on the first Broadcast

Specified by:
onStateChange in interface org.atmosphere.cpr.AtmosphereHandler<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>
Parameters:
event -
Throws:
IOException


Copyright © 2010 SUN Microsystems. All Rights Reserved.