Salut,
aalcamo_at_gofurthercorp.com wrote:
> Jeanfrancois,
> Thank you for this info. I was wondering why, however, the servlet needs
> to have a 'ping' timer scheduled. Shouldn't it be enough to register in
> the init, and context.notify() each message to the client in the doPost?
Yes this is just for demonstration purpose. Your solution should works.
A+
-- Jeanfrancois
> Thanks,
> Anthony
>
>
> Salut,
>
> first, I apologize for the recent regressions observed with cometd, in
> both GlassFish v2 (grizzly 1.0.22) and v3 (1.9.x). We wioll improve our
> testing and avoid such major regressions.
>
>
> we recently updated the way cometd/bayeux has been implemented on top of
> Grizzly Comet. During that re-factoring we have made some major
> performance improvement and modified a little how the JavaAPI can be
> used. A simple demo can be downloaded here:
>
> http://download.java.net/maven/2/com/sun/grizzly/samples/grizzly-cometd-bayeux/1.9.5-SNAPSHOT/
>
>
> Mainly, you can test it using the grizzly-cometd-webserver.jar
> downloaded from here (hudson seems broken, so make sure you download the
> 20090126 war file).
>
> http://download.java.net/maven/2/com/sun/grizzly/grizzly-cometd-webserver/1.9.5-SNAPSHOT/
>
> You can run the demo by doing:
>
> java -jar grizzly-cometd-webserver.jar -p 8080 -a
> grizzly-cometd-bayeux.war com.sun.grizzly.bayeux.BayeuxExternalServlet.
>
> In that demo, request which takes the form of:
>
> http://host:port/BayeuxExternalServlet/?message=hello,user=moi
>
> will update the cometd-chat demo bu using the JavaAPI. The demo is
> simple and can be read from here:
>
> https://grizzly.dev.java.net/nonav/xref/com/sun/grizzly/bayeux/BayeuxExternalServlet.html
>
> The code looks like:
>
>> 133 @Override
>> 134 public void doPost(HttpServletRequest request,
>> HttpServletResponse response) throws ServletException, IOException {
>> 135 String message = request.getParameter("message");
>> 136 String user = request.getParameter("user");
>> 137 ServletOutputStream out = response.getOutputStream();
>> 138
>> 139 CometEngine engine = CometEngine.getEngine();
>> 140 CometContext context = engine.getCometContext(channel);
>> 141
>> 142 if (context != null && message != null) {
>> 143 Map<String, Object> map = new HashMap<String, Object>();
>> 144 map.put("chat", message);
>> 145 map.put("user", user);
>> 146 Data data = new Data();
>> 147 data.setMapData(map);
>> 148 data.setChannel("/chat/demo");
>> 149
>> 150 DeliverResponse deliverResponse = new DeliverResponse();
>> 151 deliverResponse.setChannel("/chat/demo");
>> 152 deliverResponse.setClientId("");
>> 153 deliverResponse.setData(data);
>> 154 deliverResponse.setLast(true);
>> 155 deliverResponse.setFollow(true);
>> 156 deliverResponse.setFinished(true);
>> 157
>> 158 context.notify(deliverResponse);
>> 159
>> 160 out.println("Data is sent.");
>> 161 System.out.println("Data is sent.");
>> 162 } else {
>> 163 out.println("No data is sent.");
>> 164 System.out.println("No data is sent.");
>> 165 }
>
> The main changes from previous version are:
>
> + No needs for invoking DeliveryResponse.setFinished(...); This was
> added after Shing Wai blog and it seemed to break backward
> compatibility. Hence we have listened and removed this new API.
>
> + Now you can lookup CometContext using the channel instead of the
> context-path of the Servlet. This was required to allow more than one
> channel update from a single Servlet.
>
> All of those changes has been backported to Grizzly 1.0.23. Please gives
> us feedback so we can fix regression as soon as possible.
>
> Thanks
>
> -- Jeanfancois
>
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>