hi, is there a way (with rails) to have live updates triggerred by the server on the client side? is there a little javascript lib i didn''t know that can listen to incoming server orders.... a friend of mine thought about an hidden .swf to make the socket connection and that can launch javascript instructions into the client web page. any working solutions to point me to ? thanks
There is no interrupt model for Javascript -- you''re stuck with polling (timed XmlHttpRequests), which is far from efficient or elegant. A SWF opening a socket is how I would handle this sort of scenario. Your onData (etc) callback in the SWF can call JS as needed. olivier Hericord wrote:> hi, > > is there a way (with rails) to have live updates triggerred by the > server on the client side? > is there a little javascript lib i didn''t know that can listen to > incoming server orders.... > > > a friend of mine thought about an hidden .swf to make the socket > connection and that can launch javascript instructions into the client > web page. > > > any working solutions to point me to ? > > thanks > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
In Java land I use something called ''pushlets'' to achieve this - it basically opens up a connection to the web server and keeps the connection open so that the server can stream info back up to the client. Works great. Javascript on the client manages the connection, the XML content etc. The project is opensource, so make a name for yourself and convert it or jruby it or something :-) Good luck, Geoff On 23/12/05, Toby Boudreaux <rails-lb8SQxIZKShBDgjK7y7TUQ@public.gmane.org> wrote:> > There is no interrupt model for Javascript -- you''re stuck with polling > (timed XmlHttpRequests), which is far from efficient or elegant. > > A SWF opening a socket is how I would handle this sort of scenario. Your > onData (etc) callback in the SWF can call JS as needed. > > > > olivier Hericord wrote: > > hi, > > > > is there a way (with rails) to have live updates triggerred by the > > server on the client side? > > is there a little javascript lib i didn''t know that can listen to > > incoming server orders.... > > > > > > a friend of mine thought about an hidden .swf to make the socket > > connection and that can launch javascript instructions into the client > > web page. > > > > > > any working solutions to point me to ? > > > > thanks > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Just a thought, but couldn''t you make an AJAX call back to the server, and the server, instead of replying right away, waits until an event happens and then replies to the AJAX request? This gets the "open connection waiting for an event" and lets you stay in ruby/rails (assuming you can wait on the reply like that without adverse effects on the server). I think for this to work you''d have to unhook the AJAX call from being tied to a particular button/link (like how rails does it), and instead make the AJAX call as part of the page onLoad handler, so it could be listening in the background. You''d also need a way to start a new AJAX request after you received each event. Sounds like it could work ...> olivier Hericord wrote: > >> hi, >> >> is there a way (with rails) to have live updates triggerred by the >> server on the client side? >> is there a little javascript lib i didn''t know that can listen to >> incoming server orders.... >> >> >> a friend of mine thought about an hidden .swf to make the socket >> connection and that can launch javascript instructions into the client >> web page. >> >> >> any working solutions to point me to ? >> >> thanks >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >
On 12/23/05, Jeff de Vries <jdevries-aUxvbT+8UwsAvxtiuMwx3w@public.gmane.org> wrote:> Just a thought, but couldn''t you make an AJAX call back to the server, > and the server, instead of replying right away, waits until an event > happens and then replies to the AJAX request? This gets the "open > connection waiting for an event" and lets you stay in ruby/rails > (assuming you can wait on the reply like that without adverse effects on > the server).I thought about this, but you might face a browser or server timeout error.
Josh Charles wrote:>On 12/23/05, Jeff de Vries <jdevries-aUxvbT+8UwsAvxtiuMwx3w@public.gmane.org> wrote: > > >>Just a thought, but couldn''t you make an AJAX call back to the server, >>and the server, instead of replying right away, waits until an event >>happens and then replies to the AJAX request? This gets the "open >>connection waiting for an event" and lets you stay in ruby/rails >>(assuming you can wait on the reply like that without adverse effects on >>the server). >> >> > >I thought about this, but you might face a browser or server timeout error. > >what about using periodically_call_remote? call the server every 30 seconds or so. the server would only hold the connection open for 29.5 seconds. The client would reestablish the connection every x seconds. call