ipc: clean and use same method to check connection state on both sides
This commit is contained in:
parent
470804e695
commit
a24f8c53a7
3 changed files with 25 additions and 27 deletions
|
|
@ -47,7 +47,7 @@ class Socket extends EventEmitter {
|
|||
this.hearbeat = setInterval(()=>{
|
||||
this.socket.send(`["ping"]`)
|
||||
this.hearbeatTimeout = setTimeout(()=>{
|
||||
this.socket.close()
|
||||
if (this.connected()) this.socket.close()
|
||||
}, hearbeatTimeout)
|
||||
}, hearbeatInterval)
|
||||
|
||||
|
|
@ -56,6 +56,7 @@ class Socket extends EventEmitter {
|
|||
close() {
|
||||
|
||||
this.hearbeat = clearInterval(this.hearbeat)
|
||||
this.hearbeatTimeout = clearTimeout(this.hearbeatTimeout)
|
||||
|
||||
this.dieTimeout = setTimeout(()=>{
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue