Open synzhu opened 4 years ago
You can create your own list by adding the following code to server.js
let subscriptionList = [];
(async () => {
for await (let {socket, channel} of agServer.listener('subscription')) {
subscriptionList.push(channel);
console.log("subscriptionList: ",subscriptionList);
}
})();
(async () => {
for await (let {socket, channel} of agServer.listener('unsubscription')) {
const index = subscriptionList.indexOf(channel);
if (index > -1) {
subscriptionList.splice(index, 1);
}
console.log("subscriptionList: ",subscriptionList);
}
})();
There is a way to do that.
for (let i = 0; i < Object.keys(AGServer.clients).length; i++) {
const clientId = Object.keys(AGServer.clients)[i]; // id of the socket
// This will return an object of channels eg { testChannel: true }, which means the client is subscribed to testChannel and cleared if the client unsubscribes again
console.log(AGServer.clients[clientId].channelSubscriptions)
}
However I didn't test this across node / machines but I presume it should work.
Hey guys, so I've seen from the documentation that it's possible to get the list of channels that a client is subscribed to. Is there any way to see a list of clients ID's (across all nodes / machines) that are subscribed to a particular channel?