使用swift(iOS)在socketcluster中取消订阅频道不工作

使用swift(iOS)在socketcluster中取消订阅频道不工作,ios,swift,websocket,socket.io,socketcluster,Ios,Swift,Websocket,Socket.io,Socketcluster,取消订阅在socketcluster上不工作的频道 我必须订阅20频道。现在我想退订10频道。所以我们使用下面的代码进行订阅 // For subscribe SoketManager.client.subscribeAck(channelName:"random") { (str, obj1, obj2) in print ("Got data for channel", str) } // Listening to channel

取消订阅在socketcluster上不工作的频道

我必须订阅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 ?? "")
          }
 })
我们使用下面的代码取消订阅

//  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链接:

谢谢你的帮助


谢谢

您确定要取消订阅以前订阅的频道吗?你发布的代码片段没有演示你的应用程序的流程。是的,我确定,目前我正在准备演示。因此,将频道名称硬编码为“随机”。您确定要取消订阅以前订阅的频道吗?你发布的代码片段没有演示你的应用程序的流程。是的,我确定,目前我正在准备演示。因此,将频道名称硬编码为“随机”。