public interface AtmosphereResource
AtmosphereResource encapsulates the mechanism to suspend(), resume() and
broadcast (getBroadcaster()) messages among suspended resources. AtmosphereResources are passed to
an instance of AtmosphereHandler at runtime.| Modifier and Type | Interface and Description |
|---|---|
static class |
AtmosphereResource.TRANSPORT |
| Modifier and Type | Method and Description |
|---|---|
AtmosphereResource |
addBroadcaster(Broadcaster broadcaster)
Add/Associate a
Broadcaster with this resource. |
AtmosphereResource |
addEventListener(AtmosphereResourceEventListener e)
|
List<Broadcaster> |
broadcasters()
Return an unmodifiable list of
Broadcasters associated with this resource |
void |
close()
Close the underlying connection.
|
boolean |
forceBinaryWrite()
Return true when binary write is forced.
|
AtmosphereResource |
forceBinaryWrite(boolean force)
Force binary write and never write String value.
|
AtmosphereConfig |
getAtmosphereConfig()
Return the
AtmosphereConfig. |
AtmosphereHandler |
getAtmosphereHandler()
Return the associated
AtmosphereHandler associated with this resource. |
AtmosphereResourceEvent |
getAtmosphereResourceEvent()
Return the current
AtmosphereResourceEvent. |
Broadcaster |
getBroadcaster()
Return the first added
Broadcaster. |
AtmosphereRequest |
getRequest()
Return the underlying
AtmosphereRequest request. |
AtmosphereResponse |
getResponse()
Return the
AtmosphereResponse. |
Serializer |
getSerializer()
Get the
Serializer or null if not defined. |
AtmosphereResource |
initialize(AtmosphereConfig config,
Broadcaster broadcaster,
AtmosphereRequest req,
AtmosphereResponse response,
AsyncSupport asyncSupport,
AtmosphereHandler atmosphereHandler)
Initialize an
AtmosphereResource. |
boolean |
isCancelled()
Return true if this object has been cancelled.
|
boolean |
isResumed()
Return true if this object has been resumed.
|
boolean |
isSuspended()
Return true if the
suspend() has been invoked. |
AtmosphereResource |
notifyListeners()
Notify all
AtmosphereResourceEventListeners. |
AtmosphereResource |
notifyListeners(AtmosphereResourceEvent e)
Notify all
AtmosphereResourceEventListener. |
AtmosphereResource |
removeBroadcaster(Broadcaster broadcaster)
Remove a
Broadcaster with this resource. |
AtmosphereResource |
removeEventListener(AtmosphereResourceEventListener e)
Remove a
AtmosphereResourceEventListener. |
AtmosphereResource |
removeEventListeners()
Remove all
AtmosphereResourceEventListeners. |
AtmosphereResource |
removeFromAllBroadcasters()
Remove this
AtmosphereResource from all Broadcaster |
AtmosphereResource |
resume()
Complete the
AtmosphereResponse and finish/commit it. |
boolean |
resumeOnBroadcast()
Return true if this AtmosphereResource is resumed after the first broadcast.
|
AtmosphereResource |
resumeOnBroadcast(boolean resumeOnBroadcast)
Set to true to resume the response after the first broadcast.
|
javax.servlet.http.HttpSession |
session()
Return the
HttpSession if supported, null if not |
javax.servlet.http.HttpSession |
session(boolean create)
Return the
HttpSession if supported, and creates it if not already created. |
AtmosphereResource |
setBroadcaster(Broadcaster broadcaster)
Set the first
Broadcaster associated with this resource. |
AtmosphereResource |
setSerializer(Serializer s)
Set the
Serializer to use when write(java.lang.String) execute the operation. |
AtmosphereResource |
suspend()
Suspend the
AtmosphereResponse indefinitely. |
AtmosphereResource |
suspend(long timeout)
Suspend the
AtmosphereResponse. |
AtmosphereResource |
suspend(long timeout,
TimeUnit timeunit)
Suspend the
AtmosphereResponse. |
AtmosphereResource.TRANSPORT |
transport()
Return the current
AtmosphereResource.TRANSPORT. |
String |
uuid()
Return the unique ID associated with this AtmosphereResource.
|
AtmosphereResource |
write(byte[] s)
Write the bytes If
resumeOnBroadcast() is true, the underlying connection will be resumed (@link #resume()); |
AtmosphereResource |
write(String s)
Write the String.
|
Object |
writeOnTimeout()
Return the object that will be written when the resource times out.
|
AtmosphereResource |
writeOnTimeout(Object o)
Set a message that will be written when the resource times out.
|
AtmosphereResource.TRANSPORT transport()
AtmosphereResource.TRANSPORT. The transport value is retrieved using the HeaderConfig.X_ATMOSPHERE_TRANSPORT
header value.AtmosphereResource resumeOnBroadcast(boolean resumeOnBroadcast)
resumeOnBroadcast - boolean isSuspended()
suspend() has been invoked.suspend() has been invokedboolean resumeOnBroadcast()
resumeOnBroadcast()boolean isResumed()
boolean isCancelled()
AtmosphereResource resume()
AtmosphereResponse and finish/commit it. If the AtmosphereResponse is in the
process of being resumed, invoking this method has no effect.AtmosphereResource suspend()
AtmosphereResponse indefinitely.
Suspending a AtmosphereResponse will tell the underlying container to avoid recycling objects associated
with the current instance, and also to avoid committing a response.
The Framework will output some HTML comments when suspending the response in order to make sure all browsers
work well with suspended responses.AtmosphereResource suspend(long timeout)
AtmosphereResponse. Suspending a AtmosphereResponse will tell the underlying
container to avoid recycling objects associated with the current instance, and also to avoid committing response.
Invoking this method when a request is being timed out (e.g. AtmosphereResourceEvent.isResumedOnTimeout()
returns true) has no effect.
timeout - The maximum amount of time, in milliseconds, a AtmosphereResponse can be suspended. When
the timeout expires, the AtmosphereResponse will be automatically resumed and committed.
Usage of any methods of a AtmosphereResponse that times out will throw an IllegalStateException.AtmosphereResource suspend(long timeout, TimeUnit timeunit)
AtmosphereResponse. Suspending a AtmosphereResponse will tell the underlying
container to avoid recycling objects associated with the current instance, and also to avoid committing response.
Invoking this method when a request is being timed out (e.g. AtmosphereResourceEvent.isResumedOnTimeout()
returns true) has no effect.
timeout - The maximum amount of time a AtmosphereResponse can be suspended. When the timeout
expires, the AtmosphereResponse will be automatically resumed and committed. Usage of any
methods of a AtmosphereResponse that times out will throw an IllegalStateException.timeunit - The time unit of the timeout valueAtmosphereRequest getRequest()
AtmosphereRequest request.AtmosphereRequest the underlying request.AtmosphereResponse getResponse()
AtmosphereResponse.AtmosphereResponse the underlying response.AtmosphereConfig getAtmosphereConfig()
AtmosphereConfig.AtmosphereConfigBroadcaster getBroadcaster()
Broadcaster.BroadcasterList<Broadcaster> broadcasters()
Broadcasters associated with this resourceBroadcasterAtmosphereResource removeFromAllBroadcasters()
AtmosphereResource from all BroadcasterAtmosphereResource setBroadcaster(Broadcaster broadcaster)
Broadcaster associated with this resource. This Broadcaster
will be returned when getBroadcaster() is invoked.broadcaster - AtmosphereResource addBroadcaster(Broadcaster broadcaster)
Broadcaster with this resource.broadcaster - AtmosphereResource removeBroadcaster(Broadcaster broadcaster)
Broadcaster with this resource.broadcaster - AtmosphereResource setSerializer(Serializer s)
Serializer to use when write(java.lang.String) execute the operation.
By default, the Serializer is null.s - the SerializerAtmosphereResource write(String s)
resumeOnBroadcast() is true, the underlying connection will be resumed (@link #resume());s - AtmosphereResource write(byte[] s)
resumeOnBroadcast() is true, the underlying connection will be resumed (@link #resume());s - Serializer getSerializer()
Serializer or null if not defined.Serializer or null if not definedAtmosphereResourceEvent getAtmosphereResourceEvent()
AtmosphereResourceEvent.AtmosphereHandler getAtmosphereHandler()
AtmosphereHandler associated with this resource.AtmosphereHandler associated with this resourceAtmosphereResource writeOnTimeout(Object o)
Object writeOnTimeout()
String uuid()
AtmosphereResource addEventListener(AtmosphereResourceEventListener e)
e - an instance of AtmosphereResourceEventListenerAtmosphereResource removeEventListener(AtmosphereResourceEventListener e)
AtmosphereResourceEventListener.e - AtmosphereResource removeEventListeners()
AtmosphereResourceEventListeners.AtmosphereResource notifyListeners(AtmosphereResourceEvent e)
AtmosphereResourceEventListener.e - an instance of AtmosphereResourceEventAtmosphereResource notifyListeners()
AtmosphereResourceEventListeners.javax.servlet.http.HttpSession session()
HttpSession if supported, null if notHttpSession if supported, null if notjavax.servlet.http.HttpSession session(boolean create)
HttpSession if supported, and creates it if not already created.HttpSession if supported, and creates it if not already createdvoid close()
throws IOException
AtmosphereResource}.IOExceptionAtmosphereResource forceBinaryWrite(boolean force)
boolean forceBinaryWrite()
AtmosphereResource initialize(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereRequest req, AtmosphereResponse response, AsyncSupport asyncSupport, AtmosphereHandler atmosphereHandler)
AtmosphereResource.config - The AtmosphereConfigbroadcaster - The Broadcaster.req - The AtmosphereRequestresponse - The AtmosphereResourceasyncSupport - The AsyncSupportatmosphereHandler - The AtmosphereHandlerCopyright © 2016. All rights reserved.