A
A
Arseny Sokolov2017-07-05 08:39:27
PHP
Arseny Sokolov, 2017-07-05 08:39:27

How to recognize users when using Nginx Push Stream Module?

I am doing a chat on WebSocket, everything works fine, but there is one gag, how can I determine which user has logged in and which user has logged out using the Nginx Push Stream Module? And in general, is this possible and how do they solve such problems in chat rooms?
Separating all users into different channels will not work, then they stop seeing each other's messages.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
theg4sh, 2017-07-17
@theg4sh

You can authenticate the user using a proxy:
https://github.com/wandenberg/nginx-push-stream-mo...
At a glance: When authorizing, it is enough to write the key during authorization in memcache (or other in-memory db) and update its lifetime when receiving a long-pulling request from the backend proxy.

V
Viktor, 2017-07-18
@Levhav

And in general, is this possible and how do they solve such problems in chat rooms?

I guess there are different solutions. For example, here is an example of how this is solved in CppComet https://comet-server.com/wiki/doku.php/comet:faq:r... that is, the ability to track users is already integrated into the product itself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question