Cocos creator uses socket.io module to report error

problem description:

clipboard.png

< hr >

Code javascript script code is as follows

onLoad() {
    let self = this
    // 
    if (cc.sys.isNative) {
        window.io = SocketIO
    } else {
        // socket.io.js
        require("socket.io")
    }
    let socket = io("ws://localhost:3000")
    socket.on("connected", (msg) => {
        console.log("..")
    })
    socket.emit("data", "dagger")
}
Mar.16,2021
In

cocos, you can use the websocket push service provided by GoEasy. You don't need to build your own websocket server, but you can use typescript to introduce it. It supports wss, heartbeat, disconnection, reconnection and other mechanisms. Our company's Mini Game project is done with GoEasy, with good stability. https://www.goeasy.io/

Menu