H
H
have_a_questions2016-04-14 13:42:24
In contact with
have_a_questions, 2016-04-14 13:42:24

How is the chat in contact?

Please tell me how the chat in contact is arranged. I implemented a chat that is not very similar to the chat system in VK. There it is proposed to make a request to the server after a certain period of time for the presence of new messages in the database for a user with a certain id. It seems to me that this is not the best option for implementing this functionality, because making an infinite number of requests to the server after a very short period of time is not very optimal. Accordingly, it seems to me that on the initiative of the server, a connection is established with the client if there are messages for him in the database, after which a message is sent to him. Please correct me if I'm wrong and help me learn how the VK chat works. And what do they use: web sockets, sse, comet

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
coderisimo, 2016-04-14
@coderisimo

Open the console and see that your browser is constantly sending requests to the server.

L
Lumore, 2016-04-14
@Lumore

long polling/websocket

V
Viktor, 2016-04-16
@Levhav

What you need is called comet, for example, my article on this topic and here is another one

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question