Determine # of Websocket clients?
Posted: Sun Mar 10, 2024 7:42 pm
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?
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?