AJAX : Server to Client callback possible ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

AJAX : Server to Client callback possible ?

olivier Hericord
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
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: AJAX : Server to Client callback possible ?

Toby Boudreaux
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
> [hidden email]
> http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: AJAX : Server to Client callback possible ?

Geoff Hopson
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 <[hidden email]> 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
> [hidden email]
> http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails


_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: AJAX : Server to Client callback possible ?

Jeff de Vries
In reply to this post by Toby Boudreaux
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
>> [hidden email]
>> http://lists.rubyonrails.org/mailman/listinfo/rails
>
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: AJAX : Server to Client callback possible ?

Josh Charles
On 12/23/05, Jeff de Vries <[hidden email]> 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.
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: AJAX : Server to Client callback possible ?

Jason Edgecombe
Josh Charles wrote:

>On 12/23/05, Jeff de Vries <[hidden email]> 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
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails