to.etc.webapp.ajax.eventmanager
Class EventCometContext
java.lang.Object
to.etc.webapp.ajax.eventmanager.EventCometContext
- All Implemented Interfaces:
- CometContext
public class EventCometContext
- extends java.lang.Object
- implements CometContext
Comet context for the Ajax Event manager. All browsers waiting on events
have one of these open.
The browser request is a JSON message which looks like this:
{
key: 121648764328,
nexteventid: 56785,
channels: [ "tehchannel", "morechannel", "thingydoodle" ],
lingertime: 1500, // Linger time in ms, optional.
}
- Author:
- Frits Jalvingh
Created on Oct 25, 2006
Method Summary |
void |
begin(javax.servlet.http.HttpServlet slet,
javax.servlet.http.HttpServletRequest req,
Continuation cont)
|
javax.servlet.http.HttpServletRequest |
getHttpServletRequest()
|
java.lang.String |
getRemoteUser()
|
void |
respond(javax.servlet.http.HttpServletResponse resp,
boolean timeout)
Called when the condition we're waiting for has been fulfilled. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EventCometContext
public EventCometContext()
getHttpServletRequest
public javax.servlet.http.HttpServletRequest getHttpServletRequest()
begin
public void begin(javax.servlet.http.HttpServlet slet,
javax.servlet.http.HttpServletRequest req,
Continuation cont)
throws java.lang.Exception
- Specified by:
begin
in interface CometContext
- Throws:
java.lang.Exception
respond
public void respond(javax.servlet.http.HttpServletResponse resp,
boolean timeout)
throws java.lang.Exception
- Called when the condition we're waiting for has been fulfilled. This
takes the event list and returns it as an event response structure. This
structure is a JSON structure. The returned base structure is an object
with status and key fields. If events are returned this base object has
a field 'eventlist' which is an array of event objects and the associated
data.
{
key: 2131244, // This server's key. Must be repeated in the next request
nexteventid: 2131, // The last event ID seen. Must be passed in the next request,
status: "eventcode", // The status of the call (see below)
eventlist: [ // Optional, only if events are found
{
channel: "channelname",
eventid: 2131,
data: .... // Whatever event data was present
},
// repeatedly
]
}
- Specified by:
respond
in interface CometContext
- Throws:
java.lang.Exception
- See Also:
CometContext.respond(javax.servlet.http.HttpServletResponse, boolean)
getRemoteUser
public java.lang.String getRemoteUser()