You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
430 B
19 lines
430 B
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(); |
|
}; |
|
}
|
|
|