SocketCluster / socketcluster

Highly scalable realtime pub/sub and RPC framework
https://socketcluster.io
MIT License
6.15k stars 314 forks source link

listing channels on unsubscribe #499

Closed sylvesterdsouza closed 5 years ago

sylvesterdsouza commented 5 years ago

How do I get a list of channels that a socket was subscribed to on disconnect or unsubscribe?

I tried socket.subscriptions() but it does not return any data.

socket.on('unsubscribe', function (object) { console.log("socket id : " + socket.id + " Un-Subscribed from channels : " + socket.subscriptions() ); });

sylvesterdsouza commented 5 years ago

Figured it out, the below code works for me

  socket.on('unsubscribe', function (channelname) {
    console.log("socket id : " + socket.id + " Un-Subscribed from : " +channelname );
    });