Determine # of Websocket clients?

All that relates to Javascript, CSS, HTML, ....
Post Reply
SteanX
Posts: 39
Joined: Sat Jun 19, 2021 10:33 pm
Has thanked: 17 times
Been thanked: 6 times

Determine # of Websocket clients?

Post 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? :-)
User avatar
cicciocb
Site Admin
Posts: 2194
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 470 times
Been thanked: 1461 times
Contact:

Re: Determine # of Websocket clients?

Post 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.
SteanX
Posts: 39
Joined: Sat Jun 19, 2021 10:33 pm
Has thanked: 17 times
Been thanked: 6 times

Re: Determine # of Websocket clients?

Post by SteanX »

Thanks for clarifying cicciocb!
Post Reply