doc: document the address object in the cluster listening event

This commit is contained in:
Andreas Madsen 2012-04-28 14:24:17 +02:00 committed by Ben Noordhuis
parent 12a90e98bf
commit ab072ee416

View File

@ -109,13 +109,19 @@ being executed.
## Event: 'listening'
* `worker` {Worker object}
* `address` {Object}
When calling `listen()` from a worker, a 'listening' event is automatically assigned
to the server instance. When the server is listening a message is send to the master
where the 'listening' event is emitted.
cluster.on('listening', function (worker) {
console.log("We are now connected");
The event handler is executed with two arguments, the `worker` contains the worker
object and the `address` object contains the following connection properties:
`address`, `port` and `addressType`. This is very useful if the worker is listening
on more than one address.
cluster.on('listening', function (worker, address) {
console.log("A worker is now connected to " + address.address + ":" + address.port);
});
## Event: 'disconnect'
@ -408,11 +414,12 @@ on the specified worker.
### Event: 'listening'
* `worker` {Worker object}
* `address` {Object}
Same as the `cluster.on('listening')` event, but emits only when the state change
on the specified worker.
cluster.fork().on('listening', function (worker) {
cluster.fork().on('listening', function (worker, address) {
// Worker is listening
};