iccanobif / gikopoi2

37 stars 17 forks source link

Not all calls to setUserAsActive are followed by a server-user-active message #497

Closed gyudon-addict closed 8 months ago

gyudon-addict commented 8 months ago

The only place where it does this is on a user-ping message, which the client only emits on reconnects. It would be the right thing to do it for each one, since the client already handles the message, but normally keeps track by setting activity on a user-msg, which is kind of sloppy.

iccanobif commented 8 months ago

This is intentional: user-ping messages are sent not only on reconnects but on also on actions like moving the mouse or focusing poipoi's tab (with a 10 minutes debounce). server-user-active events are only useful when an inactive user becomes active again (and their avatar stops being transparent), and normally they do so by moving the mouse or doing other actions that send a user-ping message before performing other actions that can call setUserAsActive() (such as posting a message or moving their avatar). setUserAsActive() on the other hand also updates the date in user.lastAction so it performs a slightly different role. Not sending unneeded server-user-active messages saves bandwidth: do you really want to send one to all clients for every single avatar movement or message that happens in a room?

The only situation where these assumptions might be not true is bots, the use of which is not supported (and kinda frowned upon).