AJAX based chat plugin (beta)

Sorry for my bad English

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.

http://gagorter.com/

Gerda G. wrote:

Sorry for my bad English

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.

http://gagorter.com/

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!

All chats you see on the web are in Flash, right?


Phlip
http://flea.sourceforge.net/resume.html

Phlip wrote:
[…]

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.


Phlip
http://flea.sourceforge.net/resume.html

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On May 16, 2:52 pm, “Phlip” [email protected] wrote:

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.

long polling :slight_smile:

Fred

On May 16, 3:52 pm, “Phlip” [email protected] wrote:>

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.

Marko

Marnen Laibow-Koser wrote:

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.

I changed a little bit on the script.

When you click on the button the chat would imeditaly respond

Gerda G. wrote:

I changed a little bit on the script.

When you click on the button the chat would imeditaly respond

That means the client that clicks will get his/her message imeditaly.
That gives more stability on the chat

This chat is for small amount of users i sad.

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.

I have launched the website with a demo of the chat.

the chat is still in beta please report when it goes wrong

http://simple-chat.com/

So you are firing a AJAX call on click of ENTER , right ?

Then how do you handle when you have many channels , like many rooms
in CHAT ?

I like juggernaut because it does the same without any hastle , only
issue is its FLASH based but its lovley .

Also XHRR based chat servers are cool .

On May 23, 4:10 pm, Gerda G. [email protected]

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.

You can take a look here:

http://cometdproject.dojotoolkit.org/

Just googleit you will find all about this issue.

Cheers,

Shirkavand