| | |
| | | this.socketTask.send({ |
| | | data: JSON.stringify(message), |
| | | success: () => { |
| | | // console.log('WebSocket消息发送成功:', message) |
| | | useGlobalWS(); |
| | | console.log('WebSocket消息发送成功:', message) |
| | | // useGlobalWS(); |
| | | }, |
| | | fail: (error) => { |
| | | // console.error('WebSocket消息发送失败:', error) |
| | |
| | | } |
| | | |
| | | // 开始心跳检测 |
| | | startPing() { |
| | | this.stopPing() |
| | | // 每25秒发送一次心跳 |
| | | this.pingTimer = setInterval(() => { |
| | | if (this.connected) { |
| | | this.send('ping', 'system') |
| | | } |
| | | }, 25000) |
| | | } |
| | | // startPing() { |
| | | // this.stopPing() |
| | | // // 每25秒发送一次心跳 |
| | | // this.pingTimer = setInterval(() => { |
| | | // if (this.connected) { |
| | | // this.send('ping', 'system') |
| | | // } |
| | | // }, 25000) |
| | | // } |
| | | |
| | | // 停止心跳检测 |
| | | stopPing() { |