From 021c1756dcd9012eda044963cd47664f99411417 Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Mon, 8 Sep 2014 13:41:59 -0700 Subject: [PATCH] Auto start by default --- examples/hello/imperative_hello.js | 15 +++++++++++++++ lib/robot.js | 7 +++++++ 2 files changed, 22 insertions(+) create mode 100644 examples/hello/imperative_hello.js diff --git a/examples/hello/imperative_hello.js b/examples/hello/imperative_hello.js new file mode 100644 index 0000000..385ee14 --- /dev/null +++ b/examples/hello/imperative_hello.js @@ -0,0 +1,15 @@ +var Cylon = require('cylon'); + +var robot = new Cylon.Robot({ + connection: { name: 'loopback', adaptor: 'loopback' }, + device: { name: 'ping', driver: 'ping' }, +}); + +setInterval(function() { + console.log("Hello, human!") + console.log(robot.ping.ping()); +}, 1000); + +setTimeout(function() { + console.log("I've been at your command for 5 seconds now.") +}, 5000); diff --git a/lib/robot.js b/lib/robot.js index ab527dd..08ed89a 100644 --- a/lib/robot.js +++ b/lib/robot.js @@ -120,6 +120,12 @@ var Robot = module.exports = function Robot(opts) { this.commands = opts.commands; } + + var auto_start = Config.auto_start || true; + + if (true) { + this.start(); + } }; Utils.subclass(Robot, EventEmitter); @@ -249,6 +255,7 @@ Robot.prototype.start = function() { Logger.fatal(err); } }); + return this; }; // Public: Starts the Robot's connections and triggers a callback