because there isn’t an AJAX chat for rails i started to build a very
simple AJAX chat, meant for use with a small amount of users.
This is the first BETA i release so there are some bugs and the plugin
is very simple for the moment.
because there isn’t an AJAX chat for rails i started to build a very
simple AJAX chat, meant for use with a small amount of users.
This is the first BETA i release so there are some bugs and the plugin
is very simple for the moment.
When I tried Ajax, it was too slow. Have you load-tested on a server
yet?
Google Chat uses Ajax because they can reprogram their server. They
leave the
HTTP XML pipe turned on, so the new messages come over by push, not
pull.
It would seem to me that if teh mighty Google cannot use simple Ajax to
chat,
then it can’t be done!
Google Chat uses Ajax because they can reprogram their server. They
leave the
HTTP XML pipe turned on, so the new messages come over by push, not
pull.
Are you sure? Wouldn’t this play havoc with XHR ready states?
It would seem to me that if teh mighty Google cannot use simple Ajax to
chat,
then it can’t be done!
All chats you see on the web are in Flash, right?
Wrong. I’ve seen lots of Ajax chats on public, production sites. I
even worked on a site where my colleague implemented one, I believe from
scratch (I did the main Ajax app interface). That was in PHP, though,
not Ruby.
How do you solve the basic problem that HTTP is Pull and Chat is Push? If I
use periodically_call_remote, and set the frequency low, the chats arrive
too slowly. If I set it high, then both the server and browser bog down with
frequent requests to Pull nothing.
How do you solve the basic problem that HTTP is Pull and Chat is Push? If I
use periodically_call_remote, and set the frequency low, the chats arrive
too slowly. If I set it high, then both the server and browser bog down with
frequent requests to Pull nothing.
You should see the Firebug console log while in Campfire chat.
Are you sure? Wouldn’t this play havoc with XHR ready states?
No, but I’m sure you can google it.
All chats you see on the web are in Flash, right?
Wrong. I’ve seen lots of Ajax chats on public, production sites. I
even worked on a site where my colleague implemented one, I believe from
scratch (I did the main Ajax app interface). That was in PHP, though,
not Ruby.
How do you solve the basic problem that HTTP is Pull and Chat is Push?
If I
use periodically_call_remote, and set the frequency low, the chats
arrive
too slowly. If I set it high, then both the server and browser bog down
with
frequent requests to Pull nothing.
To avoid that every several seconds a new database request is needed the
controller creates a session with the id of the last chat. In the Rails
cache the last id is also saved.
when you do a periodically_call_remote the simple_chat_check action
compares the last Rails cache with the session of the user.
def simple_chat_check
unless Rails.cache.read(“last_message”) == session[:last_message] @chat = Chat.find(:last)
session[:last_message] = @chat.id
Rails.cache.write(“last_message”, @chat.id)
render :action => ‘show_last_chat’
end
end
At te moment the moment sometimes the show_last_action rendered two
times.
This web based chat are not implemmented using just AJAX. thi kind of
chats uses something called “Comet”, which a long-held HTTP request
allows a web server to push data to a browser, without the browser
explicitly requesting it. Now do not thing that this model is an
infinite loop to the server for refreshing data in the client(obviusly
this method will work too, but it will overload the server too much),
COMET model has a whole protocol, servers etc implemented wich can
implement this kind of comunication posible in a nice way.