ipc: clean and use same method to check connection state on both sides

This commit is contained in:
jean-emmanuel 2018-02-09 10:56:01 +01:00
parent 470804e695
commit a24f8c53a7
3 changed files with 25 additions and 27 deletions

View file

@ -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(()=>{