Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to build a web-based chat client without a socket-based framework?

I have heard that web-based chat clients tend to use networking frameworks such as the twisted framework.

But would it be possible to build a web-based chat client without a networking framework - using only ajax connections?

I would like to build a session-based one-to-one web chat client that uses sessions to indicate when a chat has ended. Would this be possible in Rails using only ajax and without a networking framework?

What effect does it have to use a networking framework and what impact would it have on my app to not use one? Also any general recommendations for approaching this project would be appreciated.

like image 915
terrestrial Avatar asked Nov 18 '25 00:11

terrestrial


1 Answers

If i understand you correctly, you want to have to clients connect to you server and send messaged to each other to each other through ajax, via the server. This is possible, there are two approaches to do this.

The easy approach is to have both client poll every few seconds to check for new messages posted by the other. Drawback is that the messages are not instantly delivered. I think this is an example found in the rails book.

The more complex approach is to keep an open connection and sent the messages to the client as soon as they are received by the server. To do this you can use something like Juggernaut

I would like to add that though the latter works, it is not something http was meant for and it a bit of hack, but hey, whatever gets the job done. A working example of this is the rails chat project which uses a juggernaut derivative.

like image 118
Arthur Avatar answered Nov 19 '25 12:11

Arthur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!