public abstract class OnMessage<T> extends AbstractReflectorAtmosphereHandler
AtmosphereHandler that must be used with the AtmosphereResourceLifecycleInterceptor
and BroadcastOnPostAtmosphereInterceptor to reduce the handling of the suspend/resume/disconnect and
broadcast operation.
You can also safely used this class with BroadcasterCache.
methodAbstractReflectorAtmosphereHandler.Default| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
MESSAGE_DELIMITER |
| Constructor and Description |
|---|
OnMessage() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Destroy this handler
|
void |
onDisconnect(AtmosphereResponse response)
This method will be invoked when the underlying WebServer detects a connection has been closed.
|
abstract void |
onMessage(AtmosphereResponse response,
T message)
Implement this method to get invoked every time a new
Broadcaster.broadcast(Object)
occurs. |
void |
onOpen(AtmosphereResource resource)
This method will be invoked when an connection has been received and not haven't yet be suspended.
|
void |
onRequest(AtmosphereResource resource)
When a client sends 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 |
onResume(AtmosphereResponse response)
This method will be invoked during the process of resuming a connection.
|
void |
onStateChange(AtmosphereResourceEvent event)
Write the
AtmosphereResourceEvent.getMessage() back to the client using
the AtmosphereResponseImpl.getOutputStream() or AtmosphereResponseImpl.getWriter(). |
void |
onTimeout(AtmosphereResponse response)
This method will be invoked when a suspended connection times out, e.g no activity has occurred for the
specified time used when suspending.
|
init, postStateChange, useTwoStepWrite, writepublic static final java.lang.String MESSAGE_DELIMITER
public 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 requests 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 AtmosphereResponseImpl.getOutputStream() or AtmosphereResponseImpl.getWriter().
If a Serializer is defined, it will be invoked and the write operation
will be delegated to it.
By default, this method will try to use AtmosphereResponseImpl.getWriter().onStateChange in interface AtmosphereHandleronStateChange in class AbstractReflectorAtmosphereHandlerevent - the AtmosphereResourceEvent.getMessage()java.io.IOExceptionpublic final void destroy()
AtmosphereHandlerdestroy in interface AtmosphereHandlerdestroy in class AbstractReflectorAtmosphereHandlerpublic void onOpen(AtmosphereResource resource) throws java.io.IOException
AtmosphereResourceLifecycleInterceptorresource - an AtmosphereResourcejava.io.IOExceptionpublic abstract void onMessage(AtmosphereResponse response, T message) throws java.io.IOException
Broadcaster.broadcast(Object)
occurs.response - an AtmosphereResponsemessage - a message of type Tjava.io.IOExceptionpublic void onResume(AtmosphereResponse response) throws java.io.IOException
response - an AtmosphereResponse.java.io.IOExceptionpublic void onTimeout(AtmosphereResponse response) throws java.io.IOException
response - an AtmosphereResponse.java.io.IOExceptionpublic void onDisconnect(AtmosphereResponse response) throws java.io.IOException
response - an AtmosphereResponse.java.io.IOExceptionCopyright © 2019. All Rights Reserved.