feat: close passive server when client disconnects

Since a passive server is created for an individual client, when it
disconnects from the server we can assume the server is done and should
close it.
This commit is contained in:
Tyler Stewart
2019-07-19 16:31:25 -06:00
parent b1fe56826c
commit bece42a0c9

View File

@@ -53,6 +53,7 @@ class Passive extends Connector {
this.dataSocket = socket;
this.dataSocket.setEncoding(this.connection.transferType);
this.dataSocket.on('error', (err) => this.server && this.server.emit('client-error', {connection: this.connection, context: 'dataSocket', error: err}));
this.dataSocket.once('close', () => this.closeServer());
if (!this.connection.secure) {
this.dataSocket.connected = true;