const currentMode = process.env.NODE_ENV
let socketUrl;
if (currentMode === "development") {
    socketUrl = "ws://192.168.1.6:8006/mosty-api/mosty-websocket/socket"
} else {
    socketUrl = "ws://aqgl.gzyc.yun/mosty-api/mosty-websocket/socket"
}

class WebSocketClass {
  constructor(props) {}
  connect(obj){
    const {ssbmid,userId} = obj
    let uuid =  generateUUIDv4()
    if(ssbmid && userId){
        return new WebSocket(`${socketUrl}/${ssbmid}/${userId}/${uuid}`)
    }
  }
}


// 生成uuid
const generateUUIDv4 = ()=> {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = (Math.random() * 16) | 0,
            v = c === 'x' ? r : (r & 0x3) | 0x8;
        return v.toString(16);
    });
}
export default WebSocketClass