| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 58b5c1e commit 660ec9f
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,13 +58,11 @@ SocketListSend.prototype.getConnections = function getConnections(callback) { | |||
| 58 | 58 | function SocketListReceive(slave, key) { | |
| 59 | 59 | EventEmitter.call(this); | |
| 60 | 60 | ||
| 61 | - var self = this; | ||
| 62 | - | ||
| 63 | 61 | this.connections = 0; | |
| 64 | 62 | this.key = key; | |
| 65 | 63 | this.slave = slave; | |
| 66 | 64 | ||
| 67 | - function onempty() { | ||
| 65 | + function onempty(self) { | ||
| 68 | 66 | if (!self.slave.connected) return; | |
| 69 | 67 | ||
| 70 | 68 | self.slave.send({ | |
@@ -73,36 +71,34 @@ function SocketListReceive(slave, key) { | |||
| 73 | 71 | }); | |
| 74 | 72 | } | |
| 75 | 73 | ||
| 76 | - this.slave.on('internalMessage', function(msg) { | ||
| 77 | - if (msg.key !== self.key) return; | ||
| 74 | + this.slave.on('internalMessage', (msg) => { | ||
| 75 | + if (msg.key !== this.key) return; | ||
| 78 | 76 | ||
| 79 | 77 | if (msg.cmd === 'NODE_SOCKET_NOTIFY_CLOSE') { | |
| 80 | 78 | // Already empty | |
| 81 | - if (self.connections === 0) return onempty(); | ||
| 79 | + if (this.connections === 0) return onempty(this); | ||
| 82 | 80 | ||
| 83 | 81 | // Wait for sockets to get closed | |
| 84 | - self.once('empty', onempty); | ||
| 82 | + this.once('empty', onempty); | ||
| 85 | 83 | } else if (msg.cmd === 'NODE_SOCKET_GET_COUNT') { | |
| 86 | - if (!self.slave.connected) return; | ||
| 87 | - self.slave.send({ | ||
| 84 | + if (!this.slave.connected) return; | ||
| 85 | + this.slave.send({ | ||
| 88 | 86 | cmd: 'NODE_SOCKET_COUNT', | |
| 89 | - key: self.key, | ||
| 90 | - count: self.connections | ||
| 87 | + key: this.key, | ||
| 88 | + count: this.connections | ||
| 91 | 89 | }); | |
| 92 | 90 | } | |
| 93 | 91 | }); | |
| 94 | 92 | } | |
| 95 | 93 | util.inherits(SocketListReceive, EventEmitter); | |
| 96 | 94 | ||
| 97 | 95 | SocketListReceive.prototype.add = function(obj) { | |
| 98 | - var self = this; | ||
| 99 | - | ||
| 100 | 96 | this.connections++; | |
| 101 | 97 | ||
| 102 | 98 | // Notify previous owner of socket about its state change | |
| 103 | - obj.socket.once('close', function() { | ||
| 104 | - self.connections--; | ||
| 99 | + obj.socket.once('close', () => { | ||
| 100 | + this.connections--; | ||
| 105 | 101 | ||
| 106 | - if (self.connections === 0) self.emit('empty'); | ||
| 102 | + if (this.connections === 0) this.emit('empty', this); | ||
| 107 | 103 | }); | |
| 108 | 104 | }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments