// global.js 文件
export default {
    ws: {},
    setWs: function(newWs) {
        this.ws = newWs
    },
    sendWs: function(val) {
        if (!val) return
        if (this.ws && this.ws.readyState == 1) {
            this.ws.send(JSON.stringify(val));
        } else {
            setTimeout(() => {
                this.sendWs(val)
            }, 1)
        }
    }
}