Forum: Ruby on Rails AJAX based chat plugin (beta)

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.
64c2bf0418867581e807d0ba22f6d0ea?d=identicon&s=25 Gerda Gorter (gerda)
on 2009-05-16 10:28
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/
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-05-16 14:57
(Received via mailing list)
Gerda Gorter 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
Dd2d775dea75b381edb1bbf0600a0907?d=identicon&s=25 Marnen Laibow-Koser (marnen)
on 2009-05-16 15:32
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
marnen@marnen.org
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-05-16 15:53
(Received via mailing list)
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.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-05-16 17:15
(Received via mailing list)
On May 16, 2:52 pm, "Phlip" <phlip2...@gmail.com> 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 :-)

Fred
834a5b9ae16a115b7ba667472650ab13?d=identicon&s=25 Marko Anastasov (markoa)
on 2009-05-16 18:21
(Received via mailing list)
On May 16, 3:52 pm, "Phlip" <phlip2...@gmail.com> 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
64c2bf0418867581e807d0ba22f6d0ea?d=identicon&s=25 Gerda Gorter (gerda)
on 2009-05-17 15:04
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.
64c2bf0418867581e807d0ba22f6d0ea?d=identicon&s=25 Gerda Gorter (gerda)
on 2009-05-19 10:11
I changed a little bit on the script.

When you click on the button the chat would imeditaly respond
64c2bf0418867581e807d0ba22f6d0ea?d=identicon&s=25 Gerda Gorter (gerda)
on 2009-05-19 10:12
Gerda Gorter 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
64c2bf0418867581e807d0ba22f6d0ea?d=identicon&s=25 Gerda Gorter (gerda)
on 2009-05-23 13:10
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/
070ccc073378648141f63e8dba78d4a4?d=identicon&s=25 Piyush Gupta (jhonny)
on 2009-05-24 11:12
(Received via mailing list)
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 Gorter <rails-mailing-l...@andreas-s.net>
482517e3e7f1be3c858dbdb4b8f288a1?d=identicon&s=25 fRAnKEnSTEin (Guest)
on 2009-05-24 12:05
(Received via mailing list)
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
This topic is locked and can not be replied to.