public class Meteor extends Object
Meteor is a simple class that can be used from a Servlet
to suspend, broadcast and resume responses. A Meteor can be created by invoking
the build() method.
Meteor.build(HttpServletRequest).suspend(-1);
A Meteor is usually created when an application needs 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 | Method and Description |
|---|---|
Meteor |
addListener(AtmosphereResourceEventListener e)
Add a
AtmosphereResourceEventListener which gets invoked when
responses are resuming, when the remote client closes the connection or
when the a Broadcaster.broadcast(java.lang.Object) operations occurs. |
void |
attach(Object o)
|
Object |
attachement()
|
Meteor |
broadcast(Object o)
Broadcast an
Object to all suspended responses. |
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,
List<BroadcastFilter> l,
Serializer s)
Create a
Meteor using the HttpServletRequest and use a list of
BroadcastFilter and Serializer for writing the result
of a broadcast operation the HttpServletResponse. |
static Meteor |
build(javax.servlet.http.HttpServletRequest req,
List<BroadcastFilter> l,
Serializer s)
Create a
Meteor using the HttpServletRequest and use a list of
BroadcastFilter and Serializer for writing 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 writing the result of a broadcast operation using
the HttpServletResponse. |
Meteor |
delayBroadadcast(Object o,
long period)
Schedule a delayed broadcast, in seconds.
|
void |
destroy()
Mark this instance as destroyed.
|
AtmosphereConfig |
getAtmosphereConfig()
Return the
AtmosphereConfig |
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
a response is resuming, when the remote client closes the connection or
when the a Broadcaster.broadcast(java.lang.Object) operations occurs. |
Meteor |
resume()
Resume the underlying
HttpServletResponse. |
Meteor |
resumeOnBroadcast(boolean resumeOnBroadcast)
Resume the Meteor after the first broadcast operation.
|
Meteor |
schedule(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 timeout,
TimeUnit timeunit)
Suspend the underlying
HttpServletResponse. |
AtmosphereResource.TRANSPORT |
transport()
Return the current
AtmosphereResource.TRANSPORT. |
public static Meteor lookup(javax.servlet.http.HttpServletRequest r)
Meteor based on the HttpServletRequest.r - HttpServletRequestMeteor or null if not foundpublic static final Meteor build(javax.servlet.http.HttpServletRequest r)
Meteor using the HttpServletRequest.public static final Meteor build(javax.servlet.http.HttpServletRequest r, Serializer s)
Meteor using the HttpServletRequest and use the
Serializer for writing the result of a broadcast operation using
the HttpServletResponse.r - an HttpServletRequests - a Serializer used when writing broadcast eventsMeteor than can be used to resume, suspend and broadcast Objectpublic static final Meteor build(javax.servlet.http.HttpServletRequest req, List<BroadcastFilter> l, Serializer s)
Meteor using the HttpServletRequest and use a list of
BroadcastFilter and Serializer for writing the result
of a broadcast operation the HttpServletResponse.req - an HttpServletRequestl - a list of BroadcastFilters - a Serializer used when writing broadcast eventsMeteor than can be used to resume, suspend and broadcast Objectpublic static final Meteor build(javax.servlet.http.HttpServletRequest req, Broadcaster.SCOPE scope, List<BroadcastFilter> l, Serializer s)
Meteor using the HttpServletRequest and use a list of
BroadcastFilter and Serializer for writing 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 eventsMeteor than can be used to resume, suspend and broadcast Objectpublic Meteor suspend(long l)
HttpServletResponse. Passing a value of -1
suspends the response forever.l - the maximum time a response stay suspendedMeteorpublic 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, TimeUnit timeunit)
HttpServletResponse. Passing a value of -1
suspends the response forever.timeout - the maximum time a response stay suspendedtimeunit - The time unit of the timeout valueMeteorpublic Meteor delayBroadadcast(Object o, long period)
public Broadcaster getBroadcaster()
Broadcaster.public void setBroadcaster(Broadcaster b)
Broadcaster instance.b - public void attach(Object o)
public Meteor addListener(AtmosphereResourceEventListener e)
AtmosphereResourceEventListener which gets invoked when
responses are resuming, when the remote client closes the connection or
when the a Broadcaster.broadcast(java.lang.Object) operations occurs.e - an instance of AtmosphereResourceEventListenerpublic Meteor removeListener(AtmosphereResourceEventListener e)
AtmosphereResourceEventListener which gets invoked when
a response is resuming, when the remote client closes the connection or
when the a Broadcaster.broadcast(java.lang.Object) operations occurs.e - an instance of AtmosphereResourceEventListenerpublic void destroy()
public AtmosphereResource getAtmosphereResource()
AtmosphereResource.AtmosphereResourcepublic AtmosphereConfig getAtmosphereConfig()
AtmosphereConfigAtmosphereConfigCopyright © 2016. All rights reserved.