OGeek|极客世界-中国程序员成长平台

标题: ios - swift - 我可以连接到 socket.io 服务器,但我不能发出事件 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 18:18
标题: ios - swift - 我可以连接到 socket.io 服务器,但我不能发出事件

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

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



Best Answer-推荐答案


我终于解决了这个问题:

socket.on("connect")
        {data, ack in
            print("socket connected")



            socket.emit("chat message",myJSON)

        }

关于ios - swift - 我可以连接到 socket.io 服务器,但我不能发出事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45126249/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4