public class AtmosphereResourceImpl extends Object implements AtmosphereResource
AtmosphereResource.TRANSPORT
Modifier and Type | Field and Description |
---|---|
protected AsyncSupport |
asyncSupport |
protected Broadcaster |
broadcaster |
protected List<Broadcaster> |
broadcasters |
static String |
METEOR |
static String |
PRE_SUSPEND |
protected javax.servlet.http.HttpSession |
session |
static String |
SKIP_BROADCASTER_CREATION |
Constructor and Description |
---|
AtmosphereResourceImpl() |
AtmosphereResourceImpl(AtmosphereConfig config,
Broadcaster broadcaster,
AtmosphereRequest req,
AtmosphereResponse response,
AsyncSupport asyncSupport,
AtmosphereHandler atmosphereHandler)
Deprecated.
|
public static final String PRE_SUSPEND
public static final String SKIP_BROADCASTER_CREATION
public static final String METEOR
protected final List<Broadcaster> broadcasters
protected Broadcaster broadcaster
protected AsyncSupport asyncSupport
protected javax.servlet.http.HttpSession session
public AtmosphereResourceImpl()
@Deprecated public AtmosphereResourceImpl(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereRequest req, AtmosphereResponse response, AsyncSupport asyncSupport, AtmosphereHandler atmosphereHandler)
public AtmosphereResource initialize(AtmosphereConfig config, Broadcaster broadcaster, AtmosphereRequest req, AtmosphereResponse response, AsyncSupport asyncSupport, AtmosphereHandler atmosphereHandler)
AtmosphereResource
.initialize
in interface AtmosphereResource
config
- The AtmosphereConfig
broadcaster
- The Broadcaster
.req
- The AtmosphereRequest
response
- The AtmosphereResource
asyncSupport
- The AsyncSupport
atmosphereHandler
- The AtmosphereHandler
protected void register()
public AtmosphereResourceEventImpl getAtmosphereResourceEvent()
AtmosphereResource
AtmosphereResourceEvent
.getAtmosphereResourceEvent
in interface AtmosphereResource
public AtmosphereHandler getAtmosphereHandler()
AtmosphereResource
AtmosphereHandler
associated with this resource.getAtmosphereHandler
in interface AtmosphereResource
AtmosphereHandler
associated with this resourcepublic AtmosphereResource writeOnTimeout(Object o)
AtmosphereResource
writeOnTimeout
in interface AtmosphereResource
public Object writeOnTimeout()
AtmosphereResource
writeOnTimeout
in interface AtmosphereResource
public String uuid()
AtmosphereResource
uuid
in interface AtmosphereResource
public AtmosphereResource.TRANSPORT transport()
AtmosphereResource
AtmosphereResource.TRANSPORT
. The transport value is retrieved using the HeaderConfig.X_ATMOSPHERE_TRANSPORT
header value.transport
in interface AtmosphereResource
public AtmosphereResourceImpl transport(AtmosphereResource.TRANSPORT transport)
TRANSPORT
transport
- set the TRANSPORT
public AtmosphereResource resumeOnBroadcast(boolean resumeOnBroadcast)
AtmosphereResource
resumeOnBroadcast
in interface AtmosphereResource
public boolean isSuspended()
AtmosphereResource
AtmosphereResource.suspend()
has been invoked.isSuspended
in interface AtmosphereResource
AtmosphereResource.suspend()
has been invokedpublic boolean resumeOnBroadcast()
AtmosphereResource
resumeOnBroadcast
in interface AtmosphereResource
AtmosphereResource.resumeOnBroadcast()
public AtmosphereResource resume()
AtmosphereResource
AtmosphereResponse
and finish/commit it. If the AtmosphereResponse
is in the
process of being resumed, invoking this method has no effect.resume
in interface AtmosphereResource
public AtmosphereResource suspend()
AtmosphereResource
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.suspend
in interface AtmosphereResource
public AtmosphereResource suspend(long timeout, TimeUnit timeunit)
AtmosphereResource
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.
suspend
in interface AtmosphereResource
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 valuepublic AtmosphereResource suspend(long timeout)
AtmosphereResource
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.
suspend
in interface AtmosphereResource
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
.public AtmosphereRequest getRequest(boolean enforceScope)
public AtmosphereResponse getResponse(boolean enforceScope)
public AtmosphereRequest getRequest()
AtmosphereResource
AtmosphereRequest
request.getRequest
in interface AtmosphereResource
AtmosphereRequest
the underlying request.public AtmosphereResponse getResponse()
AtmosphereResource
AtmosphereResponse
.getResponse
in interface AtmosphereResource
AtmosphereResponse
the underlying response.public Broadcaster getBroadcaster()
AtmosphereResource
Broadcaster
.getBroadcaster
in interface AtmosphereResource
Broadcaster
public List<Broadcaster> broadcasters()
AtmosphereResource
Broadcaster
s associated with this resourcebroadcasters
in interface AtmosphereResource
Broadcaster
protected Broadcaster getBroadcaster(boolean autoCreate)
public AtmosphereResource setBroadcaster(Broadcaster broadcaster)
AtmosphereResource
Broadcaster
associated with this resource. This Broadcaster
will be returned when AtmosphereResource.getBroadcaster()
is invoked.setBroadcaster
in interface AtmosphereResource
public AtmosphereResource addBroadcaster(Broadcaster broadcaster)
AtmosphereResource
Broadcaster
with this resource.addBroadcaster
in interface AtmosphereResource
public AtmosphereResource removeBroadcaster(Broadcaster broadcaster)
AtmosphereResource
Broadcaster
with this resource.removeBroadcaster
in interface AtmosphereResource
protected AtmosphereResource uniqueBroadcaster(Broadcaster newB)
public AtmosphereConfig getAtmosphereConfig()
AtmosphereResource
AtmosphereConfig
.getAtmosphereConfig
in interface AtmosphereResource
AtmosphereConfig
public Action action()
Action
which represent the state of the response, e.g. suspended, resumed or timed out.Action
public void reset()
public void setIsInScope(boolean isInScope)
isInScope
- public boolean isInScope()
AtmosphereRequest
still is valid.AtmosphereRequest
still is validpublic AtmosphereResource setSerializer(Serializer s)
Serializer
used to write broadcasted objects.setSerializer
in interface AtmosphereResource
s
- public boolean isResumed()
AtmosphereResource
isResumed
in interface AtmosphereResource
public boolean isCancelled()
AtmosphereResource
isCancelled
in interface AtmosphereResource
public AtmosphereResource write(String s)
AtmosphereResource
AtmosphereResource.resumeOnBroadcast()
is true, the underlying connection will be resumed (@link #resume());write
in interface AtmosphereResource
public AtmosphereResource write(byte[] o)
AtmosphereResource
AtmosphereResource.resumeOnBroadcast()
is true, the underlying connection will be resumed (@link #resume());write
in interface AtmosphereResource
public Serializer getSerializer()
AtmosphereResource
Serializer
or null if not defined.getSerializer
in interface AtmosphereResource
Serializer
or null if not definedpublic AtmosphereResource addEventListener(AtmosphereResourceEventListener e)
addEventListener
in interface AtmosphereResource
e
- an instance of AtmosphereResourceEventListenerpublic AtmosphereResource removeEventListener(AtmosphereResourceEventListener e)
AtmosphereResource
AtmosphereResourceEventListener
.removeEventListener
in interface AtmosphereResource
public AtmosphereResource removeEventListeners()
AtmosphereResource
AtmosphereResourceEventListener
s.removeEventListeners
in interface AtmosphereResource
public AtmosphereResource notifyListeners()
AtmosphereResource
AtmosphereResourceEventListener
s.notifyListeners
in interface AtmosphereResource
public AtmosphereResource notifyListeners(AtmosphereResourceEvent event)
AtmosphereResource
AtmosphereResourceEventListener
.notifyListeners
in interface AtmosphereResource
event
- an instance of AtmosphereResourceEventpublic AtmosphereResource removeFromAllBroadcasters()
AtmosphereResource
AtmosphereResource
from all Broadcaster
removeFromAllBroadcasters
in interface AtmosphereResource
public void onThrowable(Throwable t)
AtmosphereResourceEventListener
thah an unexpected exception occured.public ConcurrentLinkedQueue<AtmosphereResourceEventListener> atmosphereResourceEventListener()
public AtmosphereResourceImpl atmosphereHandler(AtmosphereHandler atmosphereHandler)
public void cancel() throws IOException
IOException
public void _destroy()
public AtmosphereResourceImpl disableSuspend(boolean disableSuspend)
public javax.servlet.http.HttpSession session(boolean create)
AtmosphereResource
HttpSession
if supported, and creates it if not already created.session
in interface AtmosphereResource
HttpSession
if supported, and creates it if not already createdpublic void close() throws IOException
AtmosphereResource
AtmosphereResource
}.close
in interface AtmosphereResource
IOException
public void dirtyClose()
public AtmosphereResource forceBinaryWrite(boolean forceBinaryWrite)
AtmosphereResource
forceBinaryWrite
in interface AtmosphereResource
public boolean forceBinaryWrite()
AtmosphereResource
forceBinaryWrite
in interface AtmosphereResource
public javax.servlet.http.HttpSession session()
AtmosphereResource
HttpSession
if supported, null if notsession
in interface AtmosphereResource
HttpSession
if supported, null if notpublic AtmosphereResourceImpl session(javax.servlet.http.HttpSession session)
public AtmosphereResourceImpl cloneState(AtmosphereResource r)
public ConcurrentLinkedQueue<AtmosphereResourceEventListener> listeners()
public AtmosphereResourceImpl disableSuspendEvent(boolean disableSuspendEvent)
AtmosphereResourceEventListener.onSuspend(AtmosphereResourceEvent)
and
AtmosphereResourceEventListener.onPreSuspend(AtmosphereResourceEvent)
. You normally disable those events
after the first onSuspend has been called so all transports behave the same way.
AtmosphereResourceEventListener
marked with AllowInterceptor
will not
be affected by this property.disableSuspendEvent
- public boolean disableSuspendEvent()
AtmosphereResourceEventListener.onSuspend(AtmosphereResourceEvent)
and
AtmosphereResourceEventListener.onPreSuspend(AtmosphereResourceEvent)
events are disabled.public WebSocket webSocket()
public AtmosphereResourceImpl webSocket(WebSocket webSocket)
public boolean getAndSetInClosingPhase()
public boolean isPendingClose()
public boolean getAndSetPendingClose()
Copyright © 2016. All rights reserved.