PubNub取消订阅所有的特定频道
使用的控制信道的用户指定哪个声道的所有用户应该订阅。
// 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) }
})
这将标志着所有用户监听的control
通道从一个特定的频道名称退订。这项工作非常有效。您要发送取消订阅的信号如下所示:
pubnub.publish({
channel : 'control',
message : {
command : 'unsubscribe',
channel : 'channel_to_unsubscribe'
}
})
如何向通道发送“取消订阅({})”的控制通道? – PubNub