From cfd37e96216b7f3d9af81860222186618a27fbf2 Mon Sep 17 00:00:00 2001 From: edgarsilva Date: Fri, 30 Jan 2015 13:56:14 -0600 Subject: [PATCH] Updated README with cylon-api-socketio plugin reference. --- README.markdown | 11 +++++++++-- lib/cylon.js | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 9deaddb..19cfa6e 100644 --- a/README.markdown +++ b/README.markdown @@ -274,7 +274,8 @@ For more info on browser support, and for help with different configurations, yo ## API -Cylon's HTTP API plugin can be used to interact with your robots remotely. +Cylon.js has support for different API plugins that can be used to interact with your robots remotely. At this time we have support for `http` and `socket.io` plugins +with more comming in the near future. To use it, install it alongside Cylon: @@ -285,7 +286,13 @@ Then, all you need to do is call `Cylon#api` in your robot's script: ```javascript var Cylon = require("cylon"); -Cylon.api(); + +// For http +Cylon.api('http'); + +// Or for Socket.io +Cylon.api('socketio'); + ``` Then visit `https://localhost:3000/` and you are ready to control your robots from a web browser! diff --git a/lib/cylon.js b/lib/cylon.js index 2b3664c..b5cbe0d 100644 --- a/lib/cylon.js +++ b/lib/cylon.js @@ -85,6 +85,8 @@ Cylon.api = function api(Server, opts) { if (_.isString(Server)) { var req = "cylon-api-" + Server; + opts.name = Server; + try { Server = require(req); } catch (e) { @@ -112,7 +114,6 @@ Cylon.api = function api(Server, opts) { } opts.mcp = this; - var instance = new Server(opts); this.apiInstances.push(instance); instance.listen();