Package org.atmosphere.handler
Class OnMessage<T>
java.lang.Object
org.atmosphere.handler.AbstractReflectorAtmosphereHandler
org.atmosphere.handler.OnMessage<T>
- All Implemented Interfaces:
AtmosphereHandler,AtmosphereServletProcessor
Simple
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.
method- Author:
- Jeanfrancois Arcand
-
Nested Class Summary
Nested classes/interfaces inherited from class org.atmosphere.handler.AbstractReflectorAtmosphereHandler
AbstractReflectorAtmosphereHandler.Default -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voiddestroy()Destroy this handlervoidonDisconnect(AtmosphereResponse response) This method will be invoked when the underlying WebServer detects a connection has been closed.abstract voidonMessage(AtmosphereResponse response, T message) Implement this method to get invoked every time a newBroadcaster.broadcast(Object)occurs.voidonOpen(AtmosphereResource resource) This method will be invoked when an connection has been received and not haven't yet be suspended.final voidonRequest(AtmosphereResource resource) When a client sends a request to its associatedAtmosphereHandler, it can decide if the underlying connection can be suspended (creating a Continuation) or handle the connection synchronously.voidonResume(AtmosphereResponse response) This method will be invoked during the process of resuming a connection.final voidWrite theAtmosphereResourceEvent.getMessage()back to the client using theAtmosphereResponseImpl.getOutputStream()orAtmosphereResponseImpl.getWriter().voidonTimeout(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.Methods inherited from class org.atmosphere.handler.AbstractReflectorAtmosphereHandler
init, postStateChange, useTwoStepWrite, write
-
Constructor Details
-
OnMessage
public OnMessage()
-
-
Method Details
-
onRequest
Description copied from interface:AtmosphereHandlerWhen a client sends a request to its associatedAtmosphereHandler, 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.- Parameters:
resource- anAtmosphereResource- Throws:
IOException
-
onStateChange
Description copied from class:AbstractReflectorAtmosphereHandlerWrite theAtmosphereResourceEvent.getMessage()back to the client using theAtmosphereResponseImpl.getOutputStream()orAtmosphereResponseImpl.getWriter(). If aSerializeris defined, it will be invoked and the write operation will be delegated to it. By default, this method will try to useAtmosphereResponseImpl.getWriter().- Specified by:
onStateChangein interfaceAtmosphereHandler- Overrides:
onStateChangein classAbstractReflectorAtmosphereHandler- Parameters:
event- theAtmosphereResourceEvent.getMessage()- Throws:
IOException
-
destroy
public final void destroy()Description copied from interface:AtmosphereHandlerDestroy this handler- Specified by:
destroyin interfaceAtmosphereHandler- Overrides:
destroyin classAbstractReflectorAtmosphereHandler
-
onOpen
This method will be invoked when an connection has been received and not haven't yet be suspended. Note that the connection will be suspended AFTER the method has been invoked when used withAtmosphereResourceLifecycleInterceptor- Parameters:
resource- anAtmosphereResource- Throws:
IOException
-
onMessage
Implement this method to get invoked every time a newBroadcaster.broadcast(Object)occurs.- Parameters:
response- anAtmosphereResponsemessage- a message of type T- Throws:
IOException
-
onResume
This method will be invoked during the process of resuming a connection. By default this method does nothing.- Parameters:
response- anAtmosphereResponse.- Throws:
IOException
-
onTimeout
This method will be invoked when a suspended connection times out, e.g no activity has occurred for the specified time used when suspending. By default this method does nothing.- Parameters:
response- anAtmosphereResponse.- Throws:
IOException
-
onDisconnect
This method will be invoked when the underlying WebServer detects a connection has been closed. Please note that not all WebServer supports that features (see Atmosphere's WIKI for help). By default this method does nothing.- Parameters:
response- anAtmosphereResponse.- Throws:
IOException
-