@mixd-id/web-scaffold 0.1.230406277 → 0.1.230406278
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/wss.js +15 -13
package/package.json
CHANGED
package/src/utils/wss.js
CHANGED
|
@@ -197,20 +197,22 @@ class WSS extends EventEmitter2{
|
|
|
197
197
|
return socket.close(1002, e.message);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
socket.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
200
|
+
if(this._opt.ping !== false){
|
|
201
|
+
const ping = async() => {
|
|
202
|
+
socket.send(await this.toBinaryData({ ping:1 }))
|
|
203
|
+
socket.pinging = true
|
|
204
|
+
|
|
205
|
+
setTimeout(() => {
|
|
206
|
+
if(socket.pinging){
|
|
207
|
+
socket.close(1002, 'ping timeout')
|
|
208
|
+
}
|
|
209
|
+
else{
|
|
210
|
+
setTimeout(ping, (Math.round(Math.random() * 10) % 5) * 5000)
|
|
211
|
+
}
|
|
212
|
+
}, 3000)
|
|
213
|
+
}
|
|
214
|
+
setTimeout(ping, (Math.round(Math.random() * 10) % 5) * 5000)
|
|
212
215
|
}
|
|
213
|
-
setTimeout(ping, (Math.round(Math.random() * 10) % 5) * 5000)
|
|
214
216
|
})
|
|
215
217
|
}
|
|
216
218
|
|