public class Meteor
extends java.lang.Object
Meteor is a simple class that can be used from a Servlet
to suspend, broadcast and resume a response. A Meteor can be created by invoking
the build() method.
Meteor.build(HttpServletRequest).suspend(-1);
A Meteor is usually created when an application need to suspend a response. A Meteor instance can then be cached and re-used later for either broadcasting a message, or when an application needs to resume the suspended response.
| Modifier and Type | Field and Description |
|---|---|
protected static java.util.concurrent.ConcurrentHashMap<AtmosphereResource,Meteor> |
cache |
| Modifier and Type | Method and Description |
|---|---|
Meteor |
addListener(AtmosphereResourceEventListener e)
Add a
AtmosphereResourceEventListener which gets invoked when
response are resuming, when the remote client close the connection or
when the a Broadcaster.broadcast(T) operations occurs. |
void |
attach(java.lang.Object o)
Attach an
Object with this Meteor |
java.lang.Object |
attachement()
Return an
Object with this Meteor |
Meteor |
broadcast(java.lang.Object o)
Broadcast an
Object to all suspended response. |
static Meteor |
build(javax.servlet.http.HttpServletRequest r)
Create a
Meteor using the HttpServletRequest |
static Meteor |
build(javax.servlet.http.HttpServletRequest req,
Broadcaster.SCOPE scope,
java.util.List<BroadcastFilter> l,
Serializer s)
Create a
Meteor using the HttpServletRequest and use a list of
BroadcastFilter and Serializer for writting the result
of a broadcast operation the HttpServletResponse. |
static Meteor |
build(javax.servlet.http.HttpServletRequest req,
java.util.List<BroadcastFilter> l,
Serializer s)
Create a
Meteor using the HttpServletRequest and use a list of
BroadcastFilter and Serializer for writting the result
of a broadcast operation the HttpServletResponse. |
static Meteor |
build(javax.servlet.http.HttpServletRequest r,
Serializer s)
Create a
Meteor using the HttpServletRequest and use the
Serializer for writting the result of a broadcast operation using
the HttpServletResponse |
Meteor |
delayBroadadcast(java.lang.Object o,
long period)
Schedule a delayed broadcast, in seconds.
|
void |
destroy()
Mark this instance as Destroyed.
|
AtmosphereResource |
getAtmosphereResource()
Return the underlying
AtmosphereResource |
Broadcaster |
getBroadcaster()
Return the underlying
Broadcaster |
static Meteor |
lookup(javax.servlet.http.HttpServletRequest r)
Retrieve an instance of
Meteor based on the HttpServletRequest |
Meteor |
removeListener(AtmosphereResourceEventListener e)
Remove a
AtmosphereResourceEventListener which gets invoked when
response are resuming, when the remote client close the connection or
when the a Broadcaster.broadcast(T) operations occurs. |
Meteor |
resume()
Resume the underlying
HttpServletResponse |
Meteor |
resumeOnBroadcast(boolean resumeOnBroadcast)
Resume the Meteor after the first broadcast operation.
|
Meteor |
schedule(java.lang.Object o,
long period)
Schedule a periodic broadcast, in seconds.
|
void |
setBroadcaster(Broadcaster b)
Set a
Broadcaster instance. |
Meteor |
suspend(long l)
Suspend the underlying
HttpServletResponse. |
Meteor |
suspend(long l,
boolean outputComments)
Suspend the underlying
HttpServletResponse. |
Meteor |
suspend(long timeout,
java.util.concurrent.TimeUnit timeunit)
Suspend the underlying
HttpServletResponse. |
Meteor |
suspend(long timeout,
java.util.concurrent.TimeUnit timeunit,
boolean outputComments)
Suspend the underlying
HttpServletResponse. |
AtmosphereResource.TRANSPORT |
transport()
Return the current
AtmosphereResource.TRANSPORT. |
protected static final java.util.concurrent.ConcurrentHashMap<AtmosphereResource,Meteor> cache
public static Meteor lookup(javax.servlet.http.HttpServletRequest r)
Meteor based on the HttpServletRequestr - HttpServletRequestMeteor or null if not foundpublic static final Meteor build(javax.servlet.http.HttpServletRequest r)
Meteor using the HttpServletRequestr - an HttpServletRequestMeteor than can be used to resume, suspend and broadcast Objectpublic static final Meteor build(javax.servlet.http.HttpServletRequest r, Serializer s)
Meteor using the HttpServletRequest and use the
Serializer for writting the result of a broadcast operation using
the HttpServletResponser - an HttpServletRequests - a Serializer used when writing broadcast events.Meteor than can be used to resume, suspend and broadcast Objectpublic static final Meteor build(javax.servlet.http.HttpServletRequest req, java.util.List<BroadcastFilter> l, Serializer s)
Meteor using the HttpServletRequest and use a list of
BroadcastFilter and Serializer for writting the result
of a broadcast operation the HttpServletResponse.req - an HttpServletRequestl - a list of BroadcastFilters - a Serializer used when writing broadcast events.Meteor than can be used to resume, suspend and broadcast Objectpublic static final Meteor build(javax.servlet.http.HttpServletRequest req, Broadcaster.SCOPE scope, java.util.List<BroadcastFilter> l, Serializer s)
Meteor using the HttpServletRequest and use a list of
BroadcastFilter and Serializer for writting the result
of a broadcast operation the HttpServletResponse.req - an HttpServletRequestscope - the Broadcaster.SCOPE}l - a list of BroadcastFilters - a Serializer used when writing broadcast events.Meteor than can be used to resume, suspend and broadcast Objectpublic Meteor suspend(long l)
HttpServletResponse. Passing value of -1
suspend the response forever.l - the maximum time a response stay suspended.Meteorpublic Meteor resumeOnBroadcast(boolean resumeOnBroadcast)
resumeOnBroadcast - public AtmosphereResource.TRANSPORT transport()
AtmosphereResource.TRANSPORT. The transport needs to be
explicitly set by the client by adding the appropriate HeaderConfig.X_ATMOSPHERE_TRANSPORT value,
which can be long-polling, streaming, websocket or jsonp.public Meteor suspend(long timeout, java.util.concurrent.TimeUnit timeunit)
HttpServletResponse. Passing value of -1
suspend the response forever.timeout - the maximum time a response stay suspended.timeunit - The time unit of the timeout valueMeteorpublic Meteor suspend(long l, boolean outputComments)
HttpServletResponse. Passing value of -1
suspend the response forever.l - the maximum time a response stay suspended.outputComments - the maximum time a response stay suspended.Meteorpublic Meteor suspend(long timeout, java.util.concurrent.TimeUnit timeunit, boolean outputComments)
HttpServletResponse. Passing value of -1
suspend the response forever.timeout - the maximum time a response stay suspended.timeunit - The time unit of the timeout valueoutputComments - the maximum time a response stay suspended.Meteorpublic Meteor broadcast(java.lang.Object o)
Object to all suspended response.o - an ObjectMeteorpublic Meteor schedule(java.lang.Object o, long period)
o - an Objectperiod - period in secondsMeteorpublic Meteor delayBroadadcast(java.lang.Object o, long period)
o - an Objectperiod - period in secondsMeteorpublic Broadcaster getBroadcaster()
Broadcasterpublic void setBroadcaster(Broadcaster b)
Broadcaster instance.b - public java.lang.Object attachement()
Object with this MeteorObjectpublic void attach(java.lang.Object o)
Object with this Meteorpublic Meteor addListener(AtmosphereResourceEventListener e)
AtmosphereResourceEventListener which gets invoked when
response are resuming, when the remote client close the connection or
when the a Broadcaster.broadcast(T) operations occurs.e - an inatance of AtmosphereResourceEventListenerpublic Meteor removeListener(AtmosphereResourceEventListener e)
AtmosphereResourceEventListener which gets invoked when
response are resuming, when the remote client close the connection or
when the a Broadcaster.broadcast(T) operations occurs.e - an inatance of AtmosphereResourceEventListenerpublic void destroy()
public AtmosphereResource getAtmosphereResource()
AtmosphereResourceAtmosphereResourceCopyright © 2018. All Rights Reserved.