fix(core): update

This commit is contained in:
Philipp Kunz 2023-07-02 01:46:53 +02:00
parent 378592acc3
commit eadab07f17
3 changed files with 32 additions and 12 deletions

View File

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

View File

@ -218,24 +218,44 @@ 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 = () => {
const closeListener = () => {
console.log('connection closed');
cleanupConnection();
}
};
const errorListener = () => {
console.log('connection errored');
cleanupConnection();
};
const endListener = () => {
console.log('connection ended');
cleanupConnection();
};
const timeoutListener = () => {
console.log('connection timed out');
cleanupConnection();
};
connection.addListener('close', closeListener);
connection.addListener('error', errorListener);
connection.addListener('end', endListener);
connection.addListener('timeout', timeoutListener);
const cleanupConnection = () => {
connection.removeListener('close', cleanListener);
connection.removeListener('error', cleanListener);
connection.removeListener('end', cleanListener);
connection.removeListener('timeout', cleanListener);
connection.removeListener('close', closeListener);
connection.removeListener('error', errorListener);
connection.removeListener('end', endListener);
connection.removeListener('timeout', timeoutListener);
if (this.socketMap.checkForObject(connection)) {
this.socketMap.remove(connection);
console.log(`removed connection. ${this.socketMap.getArray().length} sockets remaining.`);
connection.destroy();
}
};
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.61',
version: '2.0.62',
description: 'easy serving of static files'
}