Page 1 of 1

Determine # of Websocket clients?

Posted: Sun Mar 10, 2024 7:42 pm
by SteanX
Is there a way to determine how many websocket clients are connected at any point in time?

I have a timer based routine that computes a Javascript structure to be sent to connected clients via JSCRIPT command. But it is not necessary if nobody is connected, so I'd prefer to RETURN from the timer routine early in such cases. I thought I might do this by just incrementing a "connected" client variable inside the onHTMLRELOAD event, but I have no way of knowing when a websocket disconnects to decrement such a variable.

Since Annex must maintain a list of sockets somewhere internally, I was hoping there was perhaps an undocumented feature that could tell me how many such sockets exist? :-)

Re: Determine # of Websocket clients?

Posted: Sun Mar 10, 2024 8:33 pm
by cicciocb
No, it is not possible to know how many websocket connections are active.
However, if there are no clients connected, the commands HTML, CSS, JSCRIPT ..... are simply ignored.

Re: Determine # of Websocket clients?

Posted: Sun Mar 10, 2024 8:41 pm
by SteanX
Thanks for clarifying cicciocb!