Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does in-browser chat work?

Tags:

browser

chat

Just curious. How exactly does chatting in a browser work? Usually if a user goes to a web page, his/her webbrowser requests the page content. A server produces output and sends it to the user's computer. But with chatting it's a little bit the other way around (well not exactly). It's not the user requesting a chat message from some server, but rather the server that sends it directly. Now this is really simple to achieve with a "normal" server, but the thing that the server sends it to a browser directly confuses me. The posting the message part is all clear, it's simple. You just post the data to the server with for example ajax or something. But how does the other computer instantly "know" that a message has been written to it? It must obviously be the server sending it to the other computer as soon as it has been written. But somehow that doesn't compute in my brain. In my brain, the browser only request things, it doesn't just get them. How exactly do you do that?

Take google talk in gmail for example. How does that work? How is it implemented?

like image 978
quano Avatar asked Aug 02 '09 18:08

quano


People also ask

How does live chat work on a website?

Live chat is a form of customer messaging software that allows customers to speak directly with a company's representatives — usually those in customer service and technical support and other roles. Live chat is a messaging system for business which works as a pop-up chat window within a company's website.

How does a chat feature work?

When using chat features, your messages are sent over Wi-Fi and mobile data. As long as you're connected to a Wi-Fi network that you don't have to pay to use, there should be no cost to send and receive messages. If your messages are sent using mobile data, the cost is based on your mobile data plan.


1 Answers

There are some push technologies, such as Comet, but they're not widely implemented. Most of the time this is accomplished via polling at some small interval with AJAX and downloading any new messages that are available since the last downloaded message.

like image 145
tvanfosson Avatar answered Oct 02 '22 18:10

tvanfosson