|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface AtmosphereHandler<F,G>
Implementation of AtmosphereHandler allows creation of
event-driven web applications which are hosted in the browser.
An AtmosphereHandler allows a web application to suspend and resume
an http response. An http response can be suspended AtmosphereResource.suspend()
and later resume via AtmosphereResource.resume(). Messages can also
be shared between suspended response and their associated AtmosphereHandler
using a Broadcaster. Any invocation of Broadcaster.broadcast(java.lang.Object)
will allow a suspended response to write the content of the message
onStateChange(org.atmosphere.cpr.AtmosphereResourceEvent).
AtmosphereHandler must be thread safe
For example, a simple pubsub based AtmosphereHandler will take the form of
public class AtmosphereHandlerPubSub extends AbstractReflectorAtmosphereHandler {
- Author:
- Jeanfrancois Arcand
Method Summary voiddestroy()
Destroy this handlervoidonRequest(AtmosphereResource<F,G> resource)
When a client send a request to its associatedAtmosphereHandler, it can decide if the underlying connection can be suspended (creating a Continuation) or handle the connection synchronously.voidonStateChange(AtmosphereResourceEvent<F,G> event)
This method is invoked when theBroadcasterexecute a broadcast operations.
Method Detail onRequest
void onRequest(AtmosphereResource<F,G> resource) throws IOException
- When a client send a request to its associated
AtmosphereHandler, it can decide if the underlying connection can be suspended (creating a Continuation) or handle the connection synchronously. It is recommended to only suspend request for which HTTP method is a GET and use the POST method to send data to the server, without marking the connection as asynchronous.
- Parameters:
resource- anAtmosphereResource- Throws:
IOException
onStateChange
void onStateChange(AtmosphereResourceEvent<F,G> event) throws IOException
- This method is invoked when the
Broadcasterexecute a broadcast operations. When this method is invoked its associatedBroadcaster, any suspended connection will be allowed to write the data back to its associated clients.
This method will also be invoked when a response get resumed, e.g. whenAtmosphereResource.resume()gets invoked. In that case,AtmosphereResourceEvent.isResuming()will return true.
This method will also be invoked when theAtmosphereResource.suspend(long)expires. In that case,AtmosphereResourceEvent.isResumedOnTimeout()will return true
- Parameters:
event- anAtmosphereResourceEvent- Throws:
IOException
destroy
void destroy()
- Destroy this handler
Overview Package Class Use Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD
Copyright © 2012. All Rights Reserved.