users@grizzly.java.net

Re: Info about notify()

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Wed, 25 Feb 2009 12:08:20 -0500

Salut,

Stefano Ruffolo wrote:
> Hi,
>
> I'm a new bie of comet-grizzly,
>
> I make a simple chat with gwt and comet-grizzly (Only Gwt for client
> side e server side) but I didn't undestand how to function a notify();
>
> For example when I make a login, must insert a contact in a list?and
> after how to make a notification to other contact that are online?

What about looking at:

http://docs.sun.com/app/docs/doc/820-4496/ggrgy

In short, you suspend a connection by doing:

CometContext.addCometHandler(GWTCometHandler);

You resume the connection by doing:

CometContext.resumeCometHandler(GWTCometHandler).

When a connection is suspended, the way you can push data to those
suspended connection (represented by your GWTCometHandler) is by doing:

CometContext.notify("Sharing Some Data");

When doing that, all suspended connections (aka GWTCometHandler) will be
invoked:

GWTCometHandler.onEvent(CometEvent).

The CometEvent.attachment() will return "Sharing Some Data". From you
GWTCometHandler, you can decide what to do with the push. Most of the
time you will just write it using:

HttpServletResponse.getWriter().write(...);

Does it help? Let me know if not.

A+

-- Jeanfrancois



>
> I looked at the
> examples(http://weblogs.java.net/blog/jfarcand/archive/2008/11/writing_a_twitt.html
> , and
> <http://weblogs.java.net/blog/jfarcand/archive/2008/11/writing_a_twitt.html>http://download.java.net/maven/2/com/sun/grizzly/samples/)
> but i didn't understand well. Is there any other example?
>
>
> Thanks
> Stefano