Last change
on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
518 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | module.exports = function makeKillable(server) {
|
---|
| 2 | var sockets = [];
|
---|
| 3 |
|
---|
| 4 | server.on('connection', function (socket) {
|
---|
| 5 | //add socket to list
|
---|
| 6 | sockets.push(socket);
|
---|
| 7 |
|
---|
| 8 | socket.once('close', function () {
|
---|
| 9 | //remove socket from list
|
---|
| 10 | sockets.splice(sockets.indexOf(socket), 1);
|
---|
| 11 | });
|
---|
| 12 | });
|
---|
| 13 |
|
---|
| 14 | server.kill = function (cb) {
|
---|
| 15 | server.close(cb);
|
---|
| 16 | sockets.forEach(function (socket) {
|
---|
| 17 | socket.destroy();
|
---|
| 18 | });
|
---|
| 19 | // reset so the server can be restarted
|
---|
| 20 | sockets = [];
|
---|
| 21 | };
|
---|
| 22 |
|
---|
| 23 | return server;
|
---|
| 24 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.