Xavi Ramirez | 1 Jun 2009 01:59
Picon
Gravatar

[Lift] Re: JavaScript interface to Comet

Thanks for pointing me into the right direction.  I've created a
simple example (see attachment).  In my example, the user can drag a
div around the screen.  Every time the div moves, the browser sends a
json object with the x and y coordinates to the comet steam.
Unfortunately I've ran into a couple of usability and performance
problems.

Assume the following set up: two browses are open (browser A and B)
are all listening to comet stream K.  Comet stream K broadcasts
commands that update the position of a div.

It seems that whenever browser A notifies comet stream K about an
update to the div's position, stream K broadcasts the message to all
its listeners, including browser A.  In other words, browser A
essentially hears its own echo.  For the user of browser A, this
causes the div to constantly jump between where the user actually
dragged it and the position that comet stream K is currently
broadcasting.

Also there does not seem to be any throttling mechanism for
client-side comet calls.  In my attached example, even a very simple
drag action creates dozens of ajax calls at once.  Firefox does not
handle this well.

I'd greatly appreciate any tips or suggestions.

Thanks,
Xavi

P.S. Random question: Is there a CometActor instance for every browser
(Continue reading)

marius d. | 1 Jun 2009 09:42
Picon
Gravatar

[Lift] Re: JavaScript interface to Comet


On Jun 1, 2:59 am, Xavi Ramirez <xavi....@...> wrote:
> Thanks for pointing me into the right direction.  I've created a
> simple example (see attachment).  In my example, the user can drag a
> div around the screen.  Every time the div moves, the browser sends a
> json object with the x and y coordinates to the comet steam.
> Unfortunately I've ran into a couple of usability and performance
> problems.
>
> Assume the following set up: two browses are open (browser A and B)
> are all listening to comet stream K.  Comet stream K broadcasts
> commands that update the position of a div.
>
> It seems that whenever browser A notifies comet stream K about an
> update to the div's position, stream K broadcasts the message to all
> its listeners, including browser A.  In other words, browser A
> essentially hears its own echo.  For the user of browser A, this
> causes the div to constantly jump between where the user actually
> dragged it and the position that comet stream K is currently
> broadcasting.

This is something your app must handle. Your ShapeTracker actor is
notified by all CometActor with AddListener hence your ShapeActor is
sending messages to all running actors. Your app needs to discriminate
the actors such that to not send the Comet response back if the
notification request pertains to the same session.

BTW Lift has ListenerManager trait such as:

class ShapeDisplay extends CometActor with CometListenee {
(Continue reading)

marius d. | 1 Jun 2009 09:53
Picon
Gravatar

[Lift] Re: JavaScript interface to Comet


Sorry hit send too soon ... continuation below

On Jun 1, 10:42 am, "marius d." <marius.dan...@...> wrote:
> On Jun 1, 2:59 am, Xavi Ramirez <xavi....@...> wrote:
>
>
>
> > Thanks for pointing me into the right direction.  I've created a
> > simple example (see attachment).  In my example, the user can drag a
> > div around the screen.  Every time the div moves, the browser sends a
> > json object with the x and y coordinates to the comet steam.
> > Unfortunately I've ran into a couple of usability and performance
> > problems.
>
> > Assume the following set up: two browses are open (browser A and B)
> > are all listening to comet stream K.  Comet stream K broadcasts
> > commands that update the position of a div.
>
> > It seems that whenever browser A notifies comet stream K about an
> > update to the div's position, stream K broadcasts the message to all
> > its listeners, including browser A.  In other words, browser A
> > essentially hears its own echo.  For the user of browser A, this
> > causes the div to constantly jump between where the user actually
> > dragged it and the position that comet stream K is currently
> > broadcasting.
>
> This is something your app must handle. Your ShapeTracker actor is
> notified by all CometActor with AddListener hence your ShapeActor is
> sending messages to all running actors. Your app needs to discriminate
(Continue reading)


Gmane