Package org.atmosphere.cpr
Class AtmosphereResourceEventImpl
java.lang.Object
org.atmosphere.cpr.AtmosphereResourceEventImpl
- All Implemented Interfaces:
AtmosphereResourceEvent
- Direct Known Subclasses:
HeartbeatAtmosphereResourceEvent
AtmosphereResourceEvent implementation.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAtmosphereResourceEventImpl(AtmosphereResourceImpl resource, boolean isCancelled, boolean isResumedOnTimeout) AtmosphereResourceEventImpl(AtmosphereResourceImpl resource, boolean isCancelled, boolean isResumedOnTimeout, boolean isClosedByClient, Throwable throwable) AtmosphereResourceEventImpl(AtmosphereResourceImpl resource, boolean isCancelled, boolean isResumedOnTimeout, Throwable throwable) -
Method Summary
Modifier and TypeMethodDescriptionReturn the broadcaster associated with theAtmosphereResourcethis object contains.booleanWhether an HTTP transport's close message ended this event's resource withHeaderConfig.X_ATMOSPHERE_CLOSE_REASONgoing-away: the page that held the connection was hidden or unloaded (a reload, a navigation), which a WebSocket reports with a 1001 close.closedGoingAway(boolean goingAway) Records that the close message ending this event's resource said its page is going away; set before the disconnect is dispatched.destroy()voidThe disconnect callback this caller claimed withgetAndSetDisconnectDispatched()has returned or thrown; a close waiting to tear the resource down may proceed.booleanbooleanClaims the dispatch of the handler's disconnect callback (e.g.Return the object that was passed toBroadcaster.broadcast(java.lang.Object).Return theAtmosphereResourceassociated with this event.inthashCode()booleanReturn true when the remote client close the connection.booleanReturn true if the application closed the connection usingAtmosphereResource.close().booleanReturn true if the client closed the connection and send the Atmosphere close message.isClosedByClient(boolean isClosedByClient) booleanReturn true is the response gets resumed after a timeout.booleanReturn true ifAtmosphereResource.resume()has been invoked.booleanReturn true ifAtmosphereResource.suspend()has been invoked and set to true.setCancelled(boolean isCancelled) setCloseByApplication(boolean b) protected AtmosphereResourceEventImplsetIsResumedOnTimeout(boolean isResumedOnTimeout) setMessage(Object message) Set an Object that can be retrieved withAtmosphereResourceEvent.getMessage().Return aThrowableif an unexpected exception occured.toString()uuid()The UUID of theAtmosphereResourcethis event was created for.intThe status code of the WebSocket close that ended this event's resource:1000for a client that closed on purpose,1001for a browser leaving or reloading the page,1006for a lost connection.webSocketCloseCode(int closeCode) Records the status code of the WebSocket close that ends this event's resource; set before the disconnect is dispatched.
-
Field Details
-
message
-
resource
-
-
Constructor Details
-
AtmosphereResourceEventImpl
-
AtmosphereResourceEventImpl
public AtmosphereResourceEventImpl(AtmosphereResourceImpl resource, boolean isCancelled, boolean isResumedOnTimeout) -
AtmosphereResourceEventImpl
public AtmosphereResourceEventImpl(AtmosphereResourceImpl resource, boolean isCancelled, boolean isResumedOnTimeout, Throwable throwable) -
AtmosphereResourceEventImpl
public AtmosphereResourceEventImpl(AtmosphereResourceImpl resource, boolean isCancelled, boolean isResumedOnTimeout, boolean isClosedByClient, Throwable throwable)
-
-
Method Details
-
uuid
The UUID of theAtmosphereResourcethis event was created for. Captured at construction time, so it remains available afterdestroy()has stripped the resource reference — containers (Tomcat) can fire async error/cancel listeners with a recycled request, and disconnect-cleanup paths need the resource identity even then.- Returns:
- the originating resource UUID; never null
-
getAndSetDisconnectDispatched
public boolean getAndSetDisconnectDispatched()Claims the dispatch of the handler's disconnect callback (e.g.@Disconnect) for this event's resource. A close and an in-flight broadcast can both hand the handler a cancelled event: the close thread runs the disconnect, and a broadcast that passed the broadcaster's validity check just before the cancel delivers the same event again. Only the first caller may dispatch (Invariant #2). The claim survivesdestroy(). A caller that claimed it must calldisconnectDispatchDone()once the callback returns: the resource is not torn down while it runs.- Returns:
- true if the disconnect was already dispatched, false if this call claimed it
-
disconnectDispatchDone
public void disconnectDispatchDone()The disconnect callback this caller claimed withgetAndSetDisconnectDispatched()has returned or thrown; a close waiting to tear the resource down may proceed. -
isResuming
public boolean isResuming()Description copied from interface:AtmosphereResourceEventReturn true ifAtmosphereResource.resume()has been invoked.- Specified by:
isResumingin interfaceAtmosphereResourceEvent- Returns:
- true if
AtmosphereResource.resume()has been invoked and set to true
-
isSuspended
public boolean isSuspended()Description copied from interface:AtmosphereResourceEventReturn true ifAtmosphereResource.suspend()has been invoked and set to true.- Specified by:
isSuspendedin interfaceAtmosphereResourceEvent- Returns:
- true if
AtmosphereResource.suspend()has been invoked and set to true
-
isClosedByClient
public boolean isClosedByClient()Description copied from interface:AtmosphereResourceEventReturn true if the client closed the connection and send the Atmosphere close message. You must use theOnDisconnectInterceptorin order to receive the proper value, and atmosphereProtocol must be set to true on the client side (enabledProtocol is true by default).- Specified by:
isClosedByClientin interfaceAtmosphereResourceEvent- Returns:
-
isClosedByApplication
public boolean isClosedByApplication()Description copied from interface:AtmosphereResourceEventReturn true if the application closed the connection usingAtmosphereResource.close().- Specified by:
isClosedByApplicationin interfaceAtmosphereResourceEvent- Returns:
- if the application.
-
setCloseByApplication
-
getMessage
Description copied from interface:AtmosphereResourceEventReturn the object that was passed toBroadcaster.broadcast(java.lang.Object).- Specified by:
getMessagein interfaceAtmosphereResourceEvent- Returns:
- the object that was passed to
Broadcaster.broadcast(java.lang.Object)
-
setMessage
Description copied from interface:AtmosphereResourceEventSet an Object that can be retrieved withAtmosphereResourceEvent.getMessage(). Note that the value may be overridden whenBroadcaster.broadcast(java.lang.Object)gets invoked.- Specified by:
setMessagein interfaceAtmosphereResourceEvent- Parameters:
message- an Object that can be retrieved withAtmosphereResourceEvent.getMessage().
-
isClosedByClient
-
webSocketCloseCode
public int webSocketCloseCode()The status code of the WebSocket close that ended this event's resource:1000for a client that closed on purpose,1001for a browser leaving or reloading the page,1006for a lost connection. Both 1000 and 1001 reportisClosedByClient(); the code is what tells a client that left from one that may come back.- Returns:
- the close code, or
-1when no WebSocket close ended the resource (an HTTP transport, or a resource still open)
-
webSocketCloseCode
Records the status code of the WebSocket close that ends this event's resource; set before the disconnect is dispatched.- Parameters:
closeCode- the WebSocket close status code- Returns:
- this
-
closedGoingAway
public boolean closedGoingAway()Whether an HTTP transport's close message ended this event's resource withHeaderConfig.X_ATMOSPHERE_CLOSE_REASONgoing-away: the page that held the connection was hidden or unloaded (a reload, a navigation), which a WebSocket reports with a 1001 close. Such a resource also reportsisClosedByClient(); a close message without the reason is a client that left on purpose.- Returns:
truewhen the close message said the page is going away
-
closedGoingAway
Records that the close message ending this event's resource said its page is going away; set before the disconnect is dispatched.- Parameters:
goingAway- whether the page is going away- Returns:
- this
-
isResumedOnTimeout
public boolean isResumedOnTimeout()Description copied from interface:AtmosphereResourceEventReturn true is the response gets resumed after a timeout.- Specified by:
isResumedOnTimeoutin interfaceAtmosphereResourceEvent- Returns:
- true is the response gets resumed after a timeout.
-
isCancelled
public boolean isCancelled()Description copied from interface:AtmosphereResourceEventReturn true when the remote client close the connection.- Specified by:
isCancelledin interfaceAtmosphereResourceEvent- Returns:
- true when the remote client close the connection.
-
setCancelled
-
setIsResumedOnTimeout
-
equals
-
hashCode
public int hashCode() -
throwable
Description copied from interface:AtmosphereResourceEventReturn aThrowableif an unexpected exception occured.- Specified by:
throwablein interfaceAtmosphereResourceEvent- Returns:
Throwableif an unexpected exception occured.
-
broadcaster
Description copied from interface:AtmosphereResourceEventReturn the broadcaster associated with theAtmosphereResourcethis object contains.- Specified by:
broadcasterin interfaceAtmosphereResourceEvent
-
getResource
Description copied from interface:AtmosphereResourceEventReturn theAtmosphereResourceassociated with this event.- Specified by:
getResourcein interfaceAtmosphereResourceEvent- Returns:
AtmosphereResource
-
setThrowable
-
destroy
-
toString
-