[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

http chat: webrick or roll-my-own webserver?

Joe Edelman

4/2/2005 7:54:00 PM

I want to build an HTTP-based chat server. The idea is that there
would be one URL to post a message, and another to "listen". This
latter request would never completely finish loading in browsers;
rather, connections would remain open, and posted text would be sent to
all listening browsers. There are existing HTTP chat clients that work
this way.

Webrick, it seems, is too abstract and servlet-oriented to operate well
this way. I need an httpd toolkit at a much lower level -- something
that will let me keep hundreds of connections open on the listen side
while quickly dispatching posts on the other side in the same process
and hopefully in the very same thread. I also need to become aware of
when the listening connections are closed, so that I can update the
chat roster.

Perl's HTTP::Daemon is well designed for this kind of thing. Is there
something similar in ruby-land, or is there someone who knows webrick
guts well enough to say how to misuse it in this way?

Thanks,

--Joe

P.S. Although I've said "chat" above, in reality I'm going to be
passing arbitrary javascript messages around, thus creating a platform
for enabling complex real-time programmatic interaction between all
users of a site.

1 Answer

Pat Maddox

4/2/2005 8:10:00 PM

0

Have you looked at Ajax? You could use that to take care of the
asynchronous messaging.


On Apr 2, 2005 12:54 PM, Joe Edelman <joe.edelman@gmail.com> wrote:
> I want to build an HTTP-based chat server. The idea is that there
> would be one URL to post a message, and another to "listen". This
> latter request would never completely finish loading in browsers;
> rather, connections would remain open, and posted text would be sent to
> all listening browsers. There are existing HTTP chat clients that work
> this way.
>
> Webrick, it seems, is too abstract and servlet-oriented to operate well
> this way. I need an httpd toolkit at a much lower level -- something
> that will let me keep hundreds of connections open on the listen side
> while quickly dispatching posts on the other side in the same process
> and hopefully in the very same thread. I also need to become aware of
> when the listening connections are closed, so that I can update the
> chat roster.
>
> Perl's HTTP::Daemon is well designed for this kind of thing. Is there
> something similar in ruby-land, or is there someone who knows webrick
> guts well enough to say how to misuse it in this way?
>
> Thanks,
>
> --Joe
>
> P.S. Although I've said "chat" above, in reality I'm going to be
> passing arbitrary javascript messages around, thus creating a platform
> for enabling complex real-time programmatic interaction between all
> users of a site.
>
>