Ability to get all namespaces
Is your feature request related to a problem? Please describe.
I'm using socket.io-prometheus-metrics to report metrics about sockets to Prometheus and it works great with SocketIO 1/2, but not not with 3/4 due to the change in variable name for _nsps.
Describe the solution you'd like
Could we get an API method added to the server which will give a list of all namespaces available - something like:
public namespaces() {
return Object.keys(this._nsps);
}
Describe alternatives you've considered
I've got a typing hack in locally at the moment to workaround it.
Additional context
N/A
Thanks! Wonderful to see Socket.IO moving forwards again.
@DataTables I'm working on a (hopefully temporary) fork of socket.io-prometheus-metrics to work with socket.io v4 and I've ran into the same namespaces issue. Would you mind sharing your typing hack workaround?
@joshbwlng If you Click DataTables' handle and then Repositories, you can search for socket.io and find their fork of socket.io-prometheus-metrics. In that repo is a v2 branch and the latest commit is:
https://github.com/DataTables/socket.io-prometheus-metrics/commit/83fe75e8f035da6a6dcad6d6aed28da2e1a68702
It would be great if there was a standardized way to retrieve a list of all namespaces, rather than having to access a private property.
Something like io.namespaces rather than using io._nsps.