|
@@ -13,7 +13,10 @@ class IMManager {
|
13
|
13
|
}
|
14
|
14
|
|
15
|
15
|
reconnect() {
|
|
16
|
+ if (!this.option) return;
|
|
17
|
+ if (this.socketOpen) return;
|
16
|
18
|
if (this.lockReconnect) return;
|
|
19
|
+
|
17
|
20
|
this.lockReconnect = true;
|
18
|
21
|
clearTimeout(this.timer)
|
19
|
22
|
console.log('reconnect')
|
|
@@ -54,6 +57,7 @@ class IMManager {
|
54
|
57
|
this.wss.onClose(res => {
|
55
|
58
|
console.log('已关闭', res)
|
56
|
59
|
close && close(res)
|
|
60
|
+ this.socketOpen = false
|
57
|
61
|
|
58
|
62
|
// 手动关闭的就不要重启了
|
59
|
63
|
if (!this.selfClose) {
|
|
@@ -64,6 +68,8 @@ class IMManager {
|
64
|
68
|
this.wss.onError(err => {
|
65
|
69
|
console.log('打印错误', err)
|
66
|
70
|
fail && fail(err)
|
|
71
|
+ this.socketOpen = false
|
|
72
|
+
|
67
|
73
|
if (!this.selfClose) {
|
68
|
74
|
this.reconnect()
|
69
|
75
|
}
|
|
@@ -91,6 +97,7 @@ class IMManager {
|
91
|
97
|
code: 1000,
|
92
|
98
|
reason: '退出页面'
|
93
|
99
|
})
|
|
100
|
+ this.socketOpen = false
|
94
|
101
|
console.log('已退出 scoket')
|
95
|
102
|
} else {
|
96
|
103
|
console.error('scoket 没有启动')
|