S
S
Sergey Nizhny Novgorod2017-03-21 05:10:21
Django
Sergey Nizhny Novgorod, 2017-03-21 05:10:21

How to count the number of people online in a Django chat?

Hello everyone
Now I'm faced with the fact that I don't know how to correctly show the number of people on the chat page.
Suppose when a person enters the page, you can pull up a certain model with a number, where to increase this number by one. But how then to reduce this number?
-Mark potential visitor exit paths with ajax requests to dicris?
-Perform maintenance checks that would be counted online (but again, how to count them?)
How is this done correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Shubin, 2017-03-21
@Terras

If your chat works on ajax, then it is better to organize a count of people in online sessions. Let's say, at the first request, we start to assume that the person is online and set the session expiration time, for example, 5 minutes. At repeated request - we prolong session.
In general, of course, it's better to make a chat on WebSocket and just count the number of connections.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question