Better handling of 'socket' io

This commit is contained in:
Bryan Ashby 2018-08-02 22:13:42 -06:00
parent b5c67ec88f
commit 475fe596f6
1 changed files with 9 additions and 11 deletions

View File

@ -26,14 +26,6 @@ module.exports = class Door {
} }
this.sockServer = createServer(conn => { this.sockServer = createServer(conn => {
this.sockServer.getConnections( (err, count) => {
// We expect only one connection from our DOOR/emulator/etc.
if(!err && count <= 1) {
this.client.term.output.pipe(conn);
conn.on('data', this.doorDataHandler.bind(this));
conn.once('end', () => { conn.once('end', () => {
return this.restoreIo(conn); return this.restoreIo(conn);
}); });
@ -42,6 +34,12 @@ module.exports = class Door {
this.client.log.info( { error : err.message }, 'Door socket server connection'); this.client.log.info( { error : err.message }, 'Door socket server connection');
return this.restoreIo(conn); return this.restoreIo(conn);
}); });
this.sockServer.getConnections( (err, count) => {
// We expect only one connection from our DOOR/emulator/etc.
if(!err && count <= 1) {
this.client.term.output.pipe(conn);
conn.on('data', this.doorDataHandler.bind(this));
} }
}); });
}); });