Answer the question
In order to leave comments, you need to log in
How were online chats done before?
Good afternoon!
WebSockets appeared in 2010, Ajax in 2005.
How were online chats made before the advent of Ajax and WebSockets?
I remember in 2003-2004 there were chats on narod.ru and it was updated without reloading the page, how was it possible to implement online chats at that time?
UPD: most likely with a flash.
Answer the question
In order to leave comments, you need to log in
Somewhere in 2007, long pooling technology appeared (maybe earlier, but it got its name then).
There is a script on the backend that does not return (is in the standby mode, i.e. sleep) data until it is necessary to send a message to the client.
At the same time, there was no ajax as such (xhtmlrequest appeared just in 2007), and in order to receive data from the server, it was easiest to generate javascipt initialization constants for this data, passed to the function that is a callback for receiving them. Accordingly, to start waiting for a message on the client, you need to connect a script with the appropriate url in the script tag.
To prevent a long connection from being closed, long poling must periodically send some data while waiting, for example, a space once a minute.
as a result, the backend forms with a pause and returns a script like:
................................
messageReceived({user:'vasya',message:'Hi!'});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question