/** * Copyright (c) 2013 Yahoo! Inc. All rights reserved. * * Copyrights licensed under the MIT License. See the accompanying LICENSE file * for terms. */ var zookeeper = require('../index.js'); var client = zookeeper.createClient(process.argv[2], { retries : 2 }); var path = process.argv[3]; function listChildren(client, path) { client.getChildren( path, function (event) { console.log('Got watcher event: %s', event); listChildren(client, path); }, function (error, children, stat) { if (error) { console.log( 'Failed to list children of node: %s due to: %s.', path, error ); return; } console.log('Children of node: %s are: %j.', path, children); } ); } client.once('connected', function () { console.log('Connected to ZooKeeper.'); listChildren(client, path); }); client.connect();