| 226 | |
| 227 | // Round-robin connection. |
| 228 | function onconnection(message, handle) { |
| 229 | const key = message.key; |
| 230 | const server = handles.get(key); |
| 231 | let accepted = server !== undefined; |
| 232 | |
| 233 | if (accepted && server[owner_symbol]) { |
| 234 | const self = server[owner_symbol]; |
| 235 | if (self.maxConnections != null && |
| 236 | self._connections >= self.maxConnections && |
| 237 | !self.dropMaxConnection) { |
| 238 | accepted = false; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | send({ ack: message.seq, accepted }); |
| 243 | |
| 244 | if (accepted) |
| 245 | server.onconnection(0, handle); |
| 246 | else |
| 247 | handle.close(); |
| 248 | } |
| 249 | |
| 250 | function send(message, cb) { |
| 251 | return sendHelper(process, message, null, cb); |