Forum: Ruby on Rails Ajax and Rails with two people?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5533357293ba87befa4fa55450753ccc?d=identicon&s=25 Dave A. (Guest)
on 2007-07-07 20:48
Hi there,

I'm looking for a little guidance for a project I'd like to start. I'm
fairly familiar with Rails, but still new to Ajax. I want a part of an
app to include a back-and-forth between two people, kind of like a
turn-based strategy game. Is Ajax able to do something like that? Can it
observe when one person has passed it over to the other, and activate
the second person's screen accordingly?

Thanks!

Dave
F48118fe74b0c7f6fd82a0ee422fa34e?d=identicon&s=25 snacktime (Guest)
on 2007-07-07 21:17
(Received via mailing list)
On 7/7/07, Dave A. <rails-mailing-list@andreas-s.net> wrote:
>
> Hi there,
>
> I'm looking for a little guidance for a project I'd like to start. I'm
> fairly familiar with Rails, but still new to Ajax. I want a part of an
> app to include a back-and-forth between two people, kind of like a
> turn-based strategy game. Is Ajax able to do something like that? Can it
> observe when one person has passed it over to the other, and activate
> the second person's screen accordingly?

You need something on the server side to tie the two people together.
Javascript can only communicate with the server it's being served
from.  You can send ajax requests every few seconds to the server to
pick up new events that have happened.  Can lead to a very busy server
though:)

Also, if you have a lot of ajax calls I suggest just using prototype
directly and not use the rails helpers.  It can improve performance
quite a bit.

Chris
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2007-07-07 21:49
(Received via mailing list)
Dave A. wrote:

> I'm looking for a little guidance for a project I'd like to start. I'm
> fairly familiar with Rails, but still new to Ajax. I want a part of an
> app to include a back-and-forth between two people, kind of like a
> turn-based strategy game. Is Ajax able to do something like that? Can it
> observe when one person has passed it over to the other, and activate
> the second person's screen accordingly?

Google for my street name, "how to chat", Rails, and Ajax.

The best raw Ajax can do is a periodically_call_remote with a timer set
to
above a second. If you try to go faster than that, the internets' pipes
will
start thrashing.

If you need split-second resolution, then you need a system that leaves
an
internet connection open. That would be Juggernaut; it uses a small
Flash
dot on your screen to call-back to the server and leave this connection
open. You can get sub-second resolution like this, and both browsers
generally see the update at the exact same time.

--
  Phlip
  http://www.oreilly.com/catalog/9780596510657/
  "Test Driven Ajax (on Rails)"
  assert_xpath, assert_javascript, & assert_ajax
5533357293ba87befa4fa55450753ccc?d=identicon&s=25 Dave A. (Guest)
on 2007-07-07 23:13
> Google for my street name, "how to chat", Rails, and Ajax.
>
> The best raw Ajax can do is a periodically_call_remote with a timer set
> to
> above a second. If you try to go faster than that, the internets' pipes
> will
> start thrashing.
>
> If you need split-second resolution, then you need a system that leaves
> an
> internet connection open. That would be Juggernaut; it uses a small
> Flash
> dot on your screen to call-back to the server and leave this connection
> open. You can get sub-second resolution like this, and both browsers
> generally see the update at the exact same time.

Thanks for your answers. I don't think I'll need an instantaneous
system, a second or two lag is just fine. I am concerned about the
server load, though. I'll look into Juggernaut -- seems promising and
I'm not adverse to a spec of flash.

Thanks again!
This topic is locked and can not be replied to.