【问题标题】:swift - I can connect to socket.io server but I can't emit eventswift - 我可以连接到 socket.io 服务器,但我不能发出事件
【发布时间】:2017-07-16 16:19:35
【问题描述】:

我是 socket.io 的初学者 现在我可以连接到套接字服务器和服务器记录我的连接 但我无法向服务器发出事件 这是我的代码:

 let socket =  SocketIOClient(socketURL: URL(string: "http://xxxxxxx:3000")!)
    socket.connect()
     let username = "yay"
    socket.emit("add", username)

【问题讨论】:

    标签: ios node.js swift xcode sockets


    【解决方案1】:

    我终于解决了这个问题:

    socket.on("connect")
            {data, ack in
                print("socket connected")
    
    
    
                socket.emit("chat message",myJSON)
    
            }
    

    【讨论】:

      猜你喜欢
      • 2016-09-04
      • 2023-03-26
      • 1970-01-01
      • 2021-03-31
      • 2021-08-02
      • 2016-07-14
      • 1970-01-01
      • 2013-08-13
      • 1970-01-01
      相关资源
      最近更新 更多