Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
f7966e1f58 | |||
9828f7bc13 | |||
dab87b274d | |||
85171cb736 | |||
0fd5e0a209 | |||
eadab07f17 | |||
378592acc3 | |||
f885e49e34 |
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@apiglobal/typedserver",
|
||||
"version": "2.0.60",
|
||||
"version": "2.0.64",
|
||||
"description": "easy serving of static files",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiglobal/typedserver',
|
||||
version: '2.0.60',
|
||||
version: '2.0.64',
|
||||
description: 'easy serving of static files'
|
||||
}
|
||||
|
@ -218,25 +218,45 @@ 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 cleanupConnection = () => {
|
||||
|
||||
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 = async () => {
|
||||
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.`);
|
||||
await plugins.smartdelay.delayFor(0);
|
||||
connection.destroy();
|
||||
}
|
||||
};
|
||||
connection.on('close', () => {
|
||||
cleanupConnection();
|
||||
});
|
||||
connection.on('error', () => {
|
||||
cleanupConnection();
|
||||
});
|
||||
connection.on('end', () => {
|
||||
cleanupConnection();
|
||||
});
|
||||
connection.on('timeout', () => {
|
||||
cleanupConnection();
|
||||
});
|
||||
});
|
||||
|
||||
// finally listen on a port
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiglobal/typedserver',
|
||||
version: '2.0.60',
|
||||
version: '2.0.64',
|
||||
description: 'easy serving of static files'
|
||||
}
|
||||
|
Reference in New Issue
Block a user