S
S
Sergey Nizhny Novgorod2017-03-23 13:30:08
Django
Sergey Nizhny Novgorod, 2017-03-23 13:30:08

How to update only those chats that the user does not see yet?

Hello.

The logic is this:

- A person went to the site - all the chats were loaded for him
- Then Ajax cuts in, which checks every second if there are new chats and gives out fresh ones.

Here, how to unload only dialogs that the user does not see?

From the obvious - to make some kind of variable where each chat will unload its id and ajax function, each time it will be sent, sorted by it. But is there a better way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2017-03-23
@Terras

he downloaded all the chats
why?
For active chats, make a request every second
In the request, indicate the ID of the last message seen by the user in the active chat

V
Victor, 2017-03-23
@Levhav

In order not to bother with web sockets, it is better not to fence the bike with ajax, but to use the saas comet server . It will work right away, and it doesn’t take much work. And then, when it becomes clear whether it is necessary or not, you can already switch to an open source solution and host it on your own vps. Moreover, these two solutions have the same API and therefore you won’t have to change anything in the code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question