public abstract class OnMessage<T> extends AbstractReflectorAtmosphereHandler
AtmosphereHandler that can be used with the AtmosphereResourceLifecycleInterceptor
and BroadcastOnPostAtmosphereInterceptor to reduce the handling of the suspend/resume/disconnect and
broadcast operation.| Constructor and Description |
|---|
OnMessage() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Destroy this handler
|
abstract void |
onMessage(AtmosphereResponse response,
T message)
Implement this method to get invoked every time a new
Broadcaster.broadcast(Object)
occurs. |
void |
onRequest(AtmosphereResource resource)
When a client send a request to its associated
AtmosphereHandler, it can decide
if the underlying connection can be suspended (creating a Continuation)
or handle the connection synchronously. |
void |
onStateChange(AtmosphereResourceEvent event)
Write the
AtmosphereResourceEvent.getMessage() back to the client using
the AtmosphereResponse.getOutputStream() or AtmosphereResponse.getWriter(). |
postStateChangepublic final void onRequest(AtmosphereResource resource) throws java.io.IOException
AtmosphereHandlerAtmosphereHandler, it can decide
if the underlying connection can be suspended (creating a Continuation)
or handle the connection synchronously.
It is recommended to only suspend request for which HTTP method is a GET
and use the POST method to send data to the server, without marking the
connection as asynchronous.resource - an AtmosphereResourcejava.io.IOExceptionpublic final void onStateChange(AtmosphereResourceEvent event) throws java.io.IOException
AbstractReflectorAtmosphereHandlerAtmosphereResourceEvent.getMessage() back to the client using
the AtmosphereResponse.getOutputStream() or AtmosphereResponse.getWriter().
If a Serializer is defined, it will be invoked and the writ operation
will be delegated to to it.
By default, this method will try to use AtmosphereResponse.getWriter().onStateChange in interface AtmosphereHandleronStateChange in class AbstractReflectorAtmosphereHandlerevent - the AtmosphereResourceEvent.getMessage()java.io.IOExceptionpublic final void destroy()
AtmosphereHandlerpublic abstract void onMessage(AtmosphereResponse response, T message) throws java.io.IOException
Broadcaster.broadcast(Object)
occurs.message - a message of type Tjava.io.IOExceptionCopyright © 2018. All Rights Reserved.