退订通道在套接字群集上不起作用。
我必须订阅20个频道。现在我要取消订阅10个频道。因此,我们使用以下代码进行订阅。
// For subscribe
SoketManager.client.subscribeAck(channelName:"random") { (str, obj1, obj2) in
print ("Got data for channel", str)
}
// Listening to channel
SoketManager.client.onChannel(channelName:"random", ack: {
(channelName : String , data : AnyObject?) in
print ("Got data for channel", channelName, " object data is ", data ?? "")
})
我们使用下面的代码取消订阅。
// For unsubscribe
SoketManager.client.unsubscribeAck(channelName:"random", ack : {
(channelName : String, error : AnyObject?, data : AnyObject?) in
if (error is NSNull) {
print("Successfully unsubscribed to channel ", channelName)
} else {
print("Got error while unsubscribing ", error ?? "")
}
})
当我调用“ unsubscribeAck”方法时,总是会出错。这是错误。
{
message = "Failed to unsubscribe socket from the [object Object] channel - Socket YFaGYE5Tbu1_8we2AAAG tried to unsubscribe from an invalid channel name";
name = BrokerError;
}
我也正在尝试socketcluster演示,但它对我不起作用。
Github链接:https://github.com/sacOO7/socketcluster-client-swift
感谢您的帮助。
谢谢