From ab072ee41693ee95667a06bce86588242c5b5869 Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Sat, 28 Apr 2012 14:24:17 +0200 Subject: [PATCH] doc: document the address object in the cluster listening event --- doc/api/cluster.markdown | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/api/cluster.markdown b/doc/api/cluster.markdown index dc41a9c4401..b4e6a3b25ef 100644 --- a/doc/api/cluster.markdown +++ b/doc/api/cluster.markdown @@ -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 };