
import WebsocketHeartbeat from "./WebsocketHeartbeat";

var server = "";
if (process.env.NODE_ENV === 'development') {
    server = 'ws://127.0.0.1:7771/app/webSocket/msg';
}else{
    server = "wss://qwtool.ylrzcloud.com/app/webSocket/msg";
}

export default {
    socket: {},
    hasLogin:false,
    initSocket: function(appKey,reset) {
        if(typeof(WebSocket) === "undefined"){
        }else{
            // 实例化socket
            if(!this.socket || reset){
                //this.socket = new WebSocket(server+uid);
                this.socket=new WebsocketHeartbeat({
                    url: server+appKey,
                    // userId:"r:"+uid,
                    pingTimeout: 15000,
                    pongTimeout: 10000
                });
                this.hasLogin=true;
            }
        }
    }
}
