As it turns out, most new web applications over the next couple years will
need to push data from the server to the browser whenever that data becomes
ready.

> Uwe wrote:
> You can't really actively "send" information from the server to the
client,
> unless there is some kind of connection established. Normal http connects,
> reads or writes and disconnects, but a browser doesn't maintain any kind
of
> connection to the server.

Indeed, this didn't used to be the case, but if you take a look at the html5
standard for the event-source dom element (
http://www.whatwg.org/specs/web-apps/current-work/multipage/section-server-sent-events.html#server-sent-events),
you'll see that this has changed. Granted, event-source only currently
works in opera9. But there are many other methods that can be used.

Paul Wrote: Orbited
> (http://brbx.com/orbited/) is a library that I've successfully used to
> do Comet with TurboGears.


I'm one of the core developers of orbited, and it sounds like this is
exactly what you want. Take a look at this tutorial:
http://orbited.org/tutorials/cherrychat.html and you'll get a better idea of
what the library is capable of.

Assuming you don't want to use an external library, what you want is to use
the javascript function setInterval to have each browser make an XHR request
for the the presence data every X seconds (10 would be reasonable in your
case.) Your turbogears app can keep track of the last set of data it sent
each client in that browser's session object on the tg server, and then
respond with json in a format somewhat like: [ 'unchanged', {} ] or [
'changed', { 'user1': 'away', 'user2': 'here' } ]. Then you just check the
first array element of the returned data to see if you need to update the
DOM or not.

Just keep in mind, that this will only work for a couple dozens users at
best before your server becomes somewhat unresponsive. In order to achieve
high concurrency you need to use a project like Orbited.

-Michael Carter

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to