Skip to content

Commit

Permalink
Restart relay when closes unexpectedly
Browse files Browse the repository at this point in the history
  • Loading branch information
Llorx committed Jun 8, 2019
1 parent 2768a22 commit a33ef89
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions node_relay_session.js
Expand Up @@ -48,12 +48,29 @@ class NodeRelaySession extends EventEmitter {

this.ffmpeg_exec.on('close', (code) => {
Logger.log('[Relay end] id=', this.id);
this.emit('end', this.id);
this.ffmpeg_exec = null;
if (!this._ended) {
this._runtimeout = setTimeout(() => {
this._runtimeout = null;
this.run();
}, 1000);
} else {
this.emit('end', this.id);
}
});
}

end() {
this.ffmpeg_exec.kill();
this._ended = true;
if (this._runtimeout != null) {
clearTimeout(this._runtimeout);
this._runtimeout = null;
}
if (this.ffmpeg_exec) {
this.ffmpeg_exec.kill();
} else {
this.emit('end', this.id);
}
}
}

Expand Down

0 comments on commit a33ef89

Please sign in to comment.