Commit c11ebaeb authored by 李腾's avatar 李腾

feat: 修改websoket提示

parent c57c968c
......@@ -55,7 +55,7 @@ class Socket extends EventEmitter {
// 连接成功触发
onopen = () => {
const { heartBeatTime } = this.options;
console.log('ws:连接成功');
console.log('ws: 连接成功', new Date().getTime());
this.connected = true;
this.heartBeat(heartBeatTime);
this.checkWaitingData();
......@@ -64,14 +64,14 @@ class Socket extends EventEmitter {
// 后端向前端推得数据
onmessage = msg => {
console.log('接收数据:', msg);
console.log('ws:接收数据:', msg);
this.event.emit('message', msg);
// 打印出后端推得数据
};
// 关闭连接触发
onclose = e => {
console.log('关闭socket收到的数据');
console.log('ws: 关闭连接', new Date().getTime());
this.connected = false; // 关闭将标识符改为true
if (this.heartBeatTimer) {
clearTimeout(this.heartBeatTimer);
......@@ -126,9 +126,9 @@ class Socket extends EventEmitter {
// 保持连接-默认每3分钟重置一下服务器关闭时间
heartBeat(time) {
console.log('ws: call heartBeat');
console.log('ws: call heartBeat', new Date().getTime());
this.heartBeatTimer = setTimeout(() => {
console.log('ws: sent heart beat');
console.log('ws: sent heart beat', new Date().getTime());
this.sendMessage('HeartBeat');
this.heartBeat(time);
}, time || 180000);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment