Getting real time viewer count of a stream

leggza1

New Member
As in the title, is there any way to get current viewer count of a stream through the web SDK (without using REST-API).
 

Max

Administrator
Staff member
Good day.
You can get current streams viewers count from statistics page http://wcs:8081/?action=stat&params=streams_viewers&format=json by HTTP GET query using fetch API or XHR.
 

leggza1

New Member
Good day.
You can get current streams viewers count from statistics page http://wcs:8081/?action=stat&params=streams_viewers&format=json by HTTP GET query using fetch API or XHR.
Thanks for your answer, but I already know this method and I can't access the API atm. Are there any methods in the Web SDK (js) that we use to create sessions and streams that archive the same result?

ref: https://flashphoner.com/docs/api/WCS5/client/web-sdk/latest/Stream.html
 

Max

Administrator
Staff member
Are there any methods in the Web SDK (js) that we use to create sessions and streams that archive the same result?
No, we do not allow any data receiving about stream subscribers on client side due to security reason.
You can delpoy your own backend server which will use HTTP GET query http://wcs:8081/?action=stat&params=streams_viewers&format=json once per second to collect an actual state, then implement your own websocket API to pass the state to the publishing client.
Another way to collect stream subscribers is to deploy a backend server to accept /playStream REST hook. Then again, you can implement your own websocket API to pass the state to the publishing client.
 
Top