 <h1>PubNub Unsubscribe All Users from a Specific Channel</h1> <p>Use a control channel to specify which channels all users should subscribe to.</p> <pre><code>// Subscribe to 'control' channel pubnub.subscribe({ channel : 'control', message : function(command) { // Unsubscribe Command if (command.type == 'unsubscribe') return pubnub.unsubscribe({ channel : command.channel }); } }) // Subscribe to other channels pubnub.subscribe({ channel : 'ch1,ch2', message : function(msg) { console.log(msg) } }) </code></pre> <p>This will signal all users listening on the <code>control</code> channel to unsubscribe from a specific channel name. This works pretty well out of the box. And the signal you would send to unsubscribe will look like this:</p> <pre><code>pubnub.publish({ channel : 'control', message : { command : 'unsubscribe', channel : 'channel_to_unsubscribe' } }) </code></pre>