mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-20 09:45:53 +02:00
Better handling of 'socket' io
This commit is contained in:
parent
b5c67ec88f
commit
475fe596f6
1 changed files with 9 additions and 11 deletions
20
core/door.js
20
core/door.js
|
@ -26,22 +26,20 @@ module.exports = class Door {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sockServer = createServer(conn => {
|
this.sockServer = createServer(conn => {
|
||||||
this.sockServer.getConnections( (err, count) => {
|
conn.once('end', () => {
|
||||||
|
return this.restoreIo(conn);
|
||||||
|
});
|
||||||
|
|
||||||
|
conn.once('error', err => {
|
||||||
|
this.client.log.info( { error : err.message }, 'Door socket server connection');
|
||||||
|
return this.restoreIo(conn);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.sockServer.getConnections( (err, count) => {
|
||||||
// We expect only one connection from our DOOR/emulator/etc.
|
// We expect only one connection from our DOOR/emulator/etc.
|
||||||
if(!err && count <= 1) {
|
if(!err && count <= 1) {
|
||||||
this.client.term.output.pipe(conn);
|
this.client.term.output.pipe(conn);
|
||||||
|
|
||||||
conn.on('data', this.doorDataHandler.bind(this));
|
conn.on('data', this.doorDataHandler.bind(this));
|
||||||
|
|
||||||
conn.once('end', () => {
|
|
||||||
return this.restoreIo(conn);
|
|
||||||
});
|
|
||||||
|
|
||||||
conn.once('error', err => {
|
|
||||||
this.client.log.info( { error : err.message }, 'Door socket server connection');
|
|
||||||
return this.restoreIo(conn);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue