Pibd-21_Alekseev_I.S._Inter.../IP/node_modules/server-destroy/index.js

20 lines
430 B
JavaScript
Raw Permalink Normal View History

2023-12-21 21:08:22 +04:00
module.exports = enableDestroy;
function enableDestroy(server) {
var connections = {}
server.on('connection', function(conn) {
var key = conn.remoteAddress + ':' + conn.remotePort;
connections[key] = conn;
conn.on('close', function() {
delete connections[key];
});
});
server.destroy = function(cb) {
server.close(cb);
for (var key in connections)
connections[key].destroy();
};
}