users@glassfish.java.net

Re: How to make Comet Extensible

From: <glassfish_at_javadesktop.org>
Date: Wed, 30 Apr 2008 10:07:09 PDT

I got the solution with the help of JFA,
In short, The following snippet of code will enable to post/push message to channel in the Context.
      
              String message = "<<Your message>>";
              String user = "<<who am I>>";

              HashMap<String, Object> map = new HashMap<String, Object>();
              map.put("chat", message);
              map.put("user", user);
              Data data = new Data();
              data.setMapData(map);
              data.setChannel("/chat/demo");
              data.setClientId("ejb6312");
              
              CometEngine cometEngine = CometEngine.getEngine().getCometContext(contextPath).notify(data);
              
              Note: HashMap and Data is a wrapper to create a bayeux message of the following form
             /*[{"successful":true,"channel":"/chat/demo","timestamp":"Wed, 30 Apr 2008 15:43:34 GMT","id":"5"},{"id":"5","timestamp":"Wed, 30 Apr 2008 15:43:34 GMT","data":{"chat":"<<Your message>>","user":"<<who am I>>"},"channel":"/chat/demo"}]*/. For more information please look at bayeux spec and JFA's dojo chat application.


Please look at the below link for more details http://forums.java.net/jive/thread.jspa?messageID=272256&#272256
[Message sent by forum member 'sendtopms' (sendtopms)]

http://forums.java.net/jive/thread.jspa?messageID=272263