Methods Summary |
---|
public java.lang.String | getChannel()
return BAYEUX_COMET_HANDLER;
|
public static final CometdContext | newCometdContext(CometdRequest req, CometdResponse res, com.sun.grizzly.cometd.bayeux.Verb verb)
return new CometdContext(){
public Verb getVerb(){
return verb;
}
public CometdRequest getRequest(){
return req;
}
public CometdResponse getResponse(){
return res;
}
};
|
public void | onConnect(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
CometdContext cometdContext = (CometdContext)event.attachment();
CometdRequest req = cometdContext.getRequest();
CometdResponse res = cometdContext.getResponse();
Connect connect = (Connect)cometdContext.getVerb();
res.setContentType(DEFAULT_CONTENT_TYPE);
res.write(connect.toJSON());
res.flush();
|
public void | onData(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
CometdContext cometdContext = (CometdContext)event.attachment();
CometdRequest req = cometdContext.getRequest();
CometdResponse res = cometdContext.getResponse();
Data data = (Data)cometdContext.getVerb();
res.setContentType(DEFAULT_CONTENT_TYPE);
res.write(data.toJSON());
res.flush();
event.getCometContext().notify(data);
|
public void | onDisconnect(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
CometdContext cometdContext = (CometdContext)event.attachment();
CometdRequest req = cometdContext.getRequest();
CometdResponse res = cometdContext.getResponse();
Disconnect disconnect = (Disconnect)cometdContext.getVerb();
activeHandler.remove(disconnect.getClientId());
res.setContentType(DEFAULT_CONTENT_TYPE);
res.write(disconnect.toJSON());
res.flush();
|
public void | onHandshake(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
CometdContext cometdContext = (CometdContext)event.attachment();
CometdRequest req = cometdContext.getRequest();
CometdResponse res = cometdContext.getResponse();
Handshake handshake = (Handshake)cometdContext.getVerb();
boolean handshakeOK = true;
String clientId = "";
synchronized(random){
clientId = String.valueOf(Long.toHexString(random.nextLong()));
}
clientIds.add(clientId);
// XXX Why do we need to cache the ID. Memory leak right now
if (handshakeOK){
handshake.setClientId(clientId);
}
res.setContentType(DEFAULT_CONTENT_TYPE);
res.write(handshake.toJSON());
res.flush();
|
public void | onInterrupt(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
// TODO: Use the SelectionKey to find which Handler needs to be cancelled.
|
public void | onPing(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
|
public void | onReconnect(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
CometdContext cometdContext = (CometdContext)event.attachment();
CometdRequest req = cometdContext.getRequest();
CometdResponse res = cometdContext.getResponse();
Reconnect reconnect = (Reconnect)cometdContext.getVerb();
CometContext cometContext = event.getCometContext();
DataHandler requestHandler = new DataHandler();
requestHandler.attach(new Object[]{req,res});
DataHandler prevHandler = activeHandler
.putIfAbsent(reconnect.getClientId(),requestHandler);
// Set the previous channel value.
if (prevHandler != null){
requestHandler.setChannel(prevHandler.getChannel());
}
cometContext.addCometHandler(requestHandler);
res.setContentType(DEFAULT_CONTENT_TYPE);
res.write(reconnect.toJSON());
res.flush();
|
public void | onStatus(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
|
public void | onSubscribe(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
CometdContext cometdContext = (CometdContext)event.attachment();
CometdRequest req = cometdContext.getRequest();
CometdResponse res = cometdContext.getResponse();
Subscribe subscribe = (Subscribe)cometdContext.getVerb();
DataHandler dataHandler = activeHandler.get(subscribe.getClientId());
if (dataHandler != null){
dataHandler.setChannel(subscribe.getSubscription());
}
res.setContentType(DEFAULT_CONTENT_TYPE);
res.write(subscribe.toJSON());
res.flush();
|
public void | onTerminate(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
onInterrupt(event);
|
public void | onUnsubscribe(com.sun.enterprise.web.connector.grizzly.comet.CometEvent event)
CometdContext cometdContext = (CometdContext)event.attachment();
CometdRequest req = cometdContext.getRequest();
CometdResponse res = cometdContext.getResponse();
Unsubscribe unsubscribe = (Unsubscribe)cometdContext.getVerb();
activeHandler.remove(unsubscribe.getClientId());
res.setContentType(DEFAULT_CONTENT_TYPE);
res.write(unsubscribe.toJSON());
res.flush();
|
public void | setChannel(java.lang.String channel)
// Not supported
|