org.atmosphere.samples.chat
Class ChatAtmosphereHandler

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

public class ChatAtmosphereHandler
extends Object
implements AtmosphereHandler<HttpServletRequest,HttpServletResponse>

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

Author:
Jeanfrancois Arcand

Constructor Summary
ChatAtmosphereHandler()
           
 
Method Summary
 AtmosphereEvent<HttpServletRequest,HttpServletResponse> onEvent(AtmosphereEvent<HttpServletRequest,HttpServletResponse> event)
          When the AtmosphereServlet detect an HttpServletRequest maps to this AtmosphereHandler, the AtmosphereHandler.onEvent(org.atmosphere.cpr.AtmosphereEvent) gets invoked and the response will be suspended depending on the http method, e.g.
 AtmosphereEvent<HttpServletRequest,HttpServletResponse> onMessage(AtmosphereEvent<HttpServletRequest,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 AtmosphereEvent.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

onEvent

public AtmosphereEvent<HttpServletRequest,HttpServletResponse> onEvent(AtmosphereEvent<HttpServletRequest,HttpServletResponse> event)
                                                                throws IOException
When the AtmosphereServlet detect an HttpServletRequest maps to this AtmosphereHandler, the AtmosphereHandler.onEvent(org.atmosphere.cpr.AtmosphereEvent) 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:
onEvent in interface AtmosphereHandler<HttpServletRequest,HttpServletResponse>
Parameters:
event - An AtmosphereEvent
Returns:
AtmosphereEvent
Throws:
IOException

onMessage

public AtmosphereEvent<HttpServletRequest,HttpServletResponse> onMessage(AtmosphereEvent<HttpServletRequest,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 AtmosphereEvent.suspend(long) expires.

Specified by:
onMessage in interface AtmosphereHandler<HttpServletRequest,HttpServletResponse>
Parameters:
event - An AtmosphereEvent
Returns:
AtmosphereEvent
Throws:
IOException


Copyright © 2009 SUN Microsystems. All Rights Reserved.