org.atmosphere.gwt.server
Class AtmosphereGwtHandler
java.lang.Object
org.atmosphere.handler.AbstractReflectorAtmosphereHandler
org.atmosphere.gwt.server.AtmosphereGwtHandler
- All Implemented Interfaces:
- Executor, AtmosphereHandler, AtmosphereServletProcessor
public class AtmosphereGwtHandler
- extends AbstractReflectorAtmosphereHandler
- implements Executor, AtmosphereServletProcessor
- Author:
- p.havelaar
|
Method Summary |
void |
broadcast(List<?> messages,
GwtAtmosphereResource resource)
|
void |
broadcast(Object message,
GwtAtmosphereResource resource)
|
void |
cometTerminated(GwtAtmosphereResource cometResponse,
boolean serverInitiated)
When the connection has died this method will be called to let you know about it. |
protected int |
computeHeartbeat(int requestedHeartbeat)
|
protected Object |
deserialize(char[] data,
SerialMode mode)
|
protected Object |
deserialize(String data,
SerialMode mode)
|
void |
destroy()
|
void |
disconnect(GwtAtmosphereResource resource)
|
int |
doComet(GwtAtmosphereResource resource)
This is the main entrypoint on the server that you will want to hook into and override. |
void |
doPost(javax.servlet.http.HttpServletRequest postRequest,
javax.servlet.http.HttpServletResponse postResponse,
List<?> messages,
GwtAtmosphereResource cometResource)
Called when a message is sent from the client using the post method. |
protected void |
doServerMessage(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
int connectionID)
|
void |
execute(Runnable command)
Execute a task in a seperate thread, the thread pool will grow and shrink depending on demand |
protected GwtRpcDeserializer |
getGwtRpc()
|
int |
getHeartbeat()
|
protected JSONDeserializer |
getJSONDeserializer()
|
javax.servlet.ServletContext |
getServletContext()
|
void |
init(javax.servlet.ServletConfig servletConfig)
|
boolean |
isEscapeText()
|
protected GwtAtmosphereResource |
lookupResource(int connectionId)
This can be used to lookup a resource for instance if you are implementing a remote service call
You will need to pass the connectionID, which you can pass as an url parameter {getConnectionID()} or
directly in your remote call |
void |
onRequest(AtmosphereResource resource)
|
void |
post(javax.servlet.http.HttpServletRequest postRequest,
javax.servlet.http.HttpServletResponse postResponse,
List<?> messages,
GwtAtmosphereResource cometResource)
|
protected void |
reapResources()
|
void |
setEscapeText(boolean escapeText)
|
void |
setHeartbeat(int heartbeat)
|
void |
terminate(GwtAtmosphereResource cometResponse,
boolean serverInitiated)
|
String |
toString()
|
NO_TIMEOUT
public static final int NO_TIMEOUT
- See Also:
- Constant Field Values
GWT_BROADCASTER_ID
public static final String GWT_BROADCASTER_ID
- See Also:
- Constant Field Values
logger
protected final org.slf4j.Logger logger
AtmosphereGwtHandler
public AtmosphereGwtHandler()
doComet
public int doComet(GwtAtmosphereResource resource)
throws javax.servlet.ServletException,
IOException
- This is the main entrypoint on the server that you will want to hook into and override.
This method is called when a client has request a new connection. Best practice is to do all your
required setup here and tie the AtmosphereResource to a Broadcaster, but do not send anything to
the client yet. If you wish to do so it is best to let the client send a notification to the server
using the
AtmosphereClient#post method in the onConnected event.
- Parameters:
resource -
- Returns:
-
- Throws:
javax.servlet.ServletException
IOException
cometTerminated
public void cometTerminated(GwtAtmosphereResource cometResponse,
boolean serverInitiated)
- When the connection has died this method will be called to let you know about it.
- Parameters:
cometResponse - serverInitiated -
doPost
public void doPost(javax.servlet.http.HttpServletRequest postRequest,
javax.servlet.http.HttpServletResponse postResponse,
List<?> messages,
GwtAtmosphereResource cometResource)
- Called when a message is sent from the client using the post method.
Default implementation echo's the message back to the client
- Parameters:
messages - cometResource -
lookupResource
protected GwtAtmosphereResource lookupResource(int connectionId)
- This can be used to lookup a resource for instance if you are implementing a remote service call
You will need to pass the connectionID, which you can pass as an url parameter {getConnectionID()} or
directly in your remote call
- Parameters:
connectionId -
- Returns:
init
public void init(javax.servlet.ServletConfig servletConfig)
throws javax.servlet.ServletException
- Specified by:
init in interface AtmosphereServletProcessor
- Throws:
javax.servlet.ServletException
destroy
public void destroy()
- Specified by:
destroy in interface AtmosphereHandler
isEscapeText
public boolean isEscapeText()
setEscapeText
public void setEscapeText(boolean escapeText)
getHeartbeat
public int getHeartbeat()
setHeartbeat
public void setHeartbeat(int heartbeat)
getServletContext
public javax.servlet.ServletContext getServletContext()
reapResources
protected void reapResources()
onRequest
public void onRequest(AtmosphereResource resource)
throws IOException
- Specified by:
onRequest in interface AtmosphereHandler
- Throws:
IOException
doServerMessage
protected void doServerMessage(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
int connectionID)
throws IOException
- Throws:
IOException
deserialize
protected Object deserialize(char[] data,
SerialMode mode)
throws SerializationException
- Throws:
SerializationException
deserialize
protected Object deserialize(String data,
SerialMode mode)
throws SerializationException
- Throws:
SerializationException
getGwtRpc
protected GwtRpcDeserializer getGwtRpc()
getJSONDeserializer
protected JSONDeserializer getJSONDeserializer()
post
public final void post(javax.servlet.http.HttpServletRequest postRequest,
javax.servlet.http.HttpServletResponse postResponse,
List<?> messages,
GwtAtmosphereResource cometResource)
broadcast
public void broadcast(Object message,
GwtAtmosphereResource resource)
broadcast
public void broadcast(List<?> messages,
GwtAtmosphereResource resource)
disconnect
public void disconnect(GwtAtmosphereResource resource)
execute
public void execute(Runnable command)
- Execute a task in a seperate thread, the thread pool will grow and shrink depending on demand
- Specified by:
execute in interface Executor
- Parameters:
command -
computeHeartbeat
protected int computeHeartbeat(int requestedHeartbeat)
terminate
public void terminate(GwtAtmosphereResource cometResponse,
boolean serverInitiated)
toString
public String toString()
- Overrides:
toString in class Object
Copyright © 2012. All Rights Reserved.