| 123456789101112131415161718192021222324252627282930313233 |
- 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"){
- console.log("您的浏览器不支持socket")
- }else{
- // 实例化socket
- if(!this.socket || reset){
- console.log("实例化socket");
- console.log("监听地址为:",server+appKey);
- //this.socket = new WebSocket(server+uid);
- this.socket=new WebsocketHeartbeat({
- url: server+appKey,
- // userId:"r:"+uid,
- pingTimeout: 15000,
- pongTimeout: 10000
- });
- this.hasLogin=true;
- }
- }
- }
- }
|