websocket细节之~sendMsg

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/themagickeyjianan/article/details/87721604
send: function (message) {
        if (!this._ws || !cc.sys.isObjectValid(this._ws) || (this._ws.readyState !== WebSocket.OPEN)) {
            return;
        }

        //
        this._ws.send(JSON.stringify(message));
    },

关键之处在于readyState这个判断

猜你喜欢

转载自blog.csdn.net/themagickeyjianan/article/details/87721604
今日推荐