org.atmosphere.samples.chat
Class ChatAtmosphereHandler

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

public class ChatAtmosphereHandler
extends Object
implements AtmosphereHandler<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>

Simple AtmosphereHandler that implement the logic to build a Chat application.

Author:
Jeanfrancois Arcand, TAKAI Naoto (original author for the Comet based Chat).

Constructor Summary
ChatAtmosphereHandler()
           
 
Method Summary
 void destroy()
           
 void onRequest(AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> event)
          When the AtmosphereServlet detect an HttpServletRequest maps to this AtmosphereHandler, the AtmosphereHandler.onRequest(org.atmosphere.cpr.AtmosphereResource) gets invoked and the response will be suspended depending on the http method, e.g.
 void onStateChange(AtmosphereResourceEvent<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> event)
          Invoked when a call to Broadcaster.broadcast(java.lang.Object) is issued or when the response times out, e.g whne the value AtmosphereResource.suspend(long) expires.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChatAtmosphereHandler

public ChatAtmosphereHandler()
Method Detail

onRequest

public void onRequest(AtmosphereResource<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> event)
               throws IOException
When the AtmosphereServlet detect an HttpServletRequest maps to this AtmosphereHandler, the AtmosphereHandler.onRequest(org.atmosphere.cpr.AtmosphereResource) gets invoked and the response will be suspended depending on the http method, e.g. GET will suspend the connection, POST will broadcast chat message to suspended connection.

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

onStateChange

public void onStateChange(AtmosphereResourceEvent<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse> event)
                   throws IOException
Invoked when a call to Broadcaster.broadcast(java.lang.Object) is issued or when the response times out, e.g whne the value AtmosphereResource.suspend(long) expires.

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

destroy

public void destroy()
Specified by:
destroy in interface AtmosphereHandler<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>


Copyright © 2012. All Rights Reserved.