fix(core): update

This commit is contained in:
Philipp Kunz 2023-07-02 01:38:49 +02:00
parent 078730153d
commit f885e49e34
3 changed files with 13 additions and 14 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiglobal/typedserver',
version: '2.0.60',
version: '2.0.61',
description: 'easy serving of static files'
}

View File

@ -218,25 +218,24 @@ export class Server {
this.httpServer.on('connection', (connection: plugins.net.Socket) => {
this.socketMap.add(connection);
console.log(`added connection. now ${this.socketMap.getArray().length} sockets connected.`);
const cleanListener = () => {
cleanupConnection();
}
const cleanupConnection = () => {
connection.removeListener('close', cleanListener);
connection.removeListener('error', cleanListener);
connection.removeListener('end', cleanListener);
connection.removeListener('timeout', cleanListener);
if (this.socketMap.checkForObject(connection)) {
this.socketMap.remove(connection);
console.log(`removed connection. ${this.socketMap.getArray().length} sockets remaining.`);
connection.destroy();
}
};
connection.on('close', () => {
cleanupConnection();
});
connection.on('error', () => {
cleanupConnection();
});
connection.on('end', () => {
cleanupConnection();
});
connection.on('timeout', () => {
cleanupConnection();
});
connection.addListener('close', cleanListener);
connection.addListener('error', cleanListener);
connection.addListener('end', cleanListener);
connection.addListener('timeout', cleanListener);
});
// finally listen on a port

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiglobal/typedserver',
version: '2.0.60',
version: '2.0.61',
description: 'easy serving of static files'
}