Skip to content
shundroid edited this page Jul 17, 2016 · 4 revisions

events.on("command", callback)

どれかの Client に対して、有効である command が送られ、実行された時に発生します。

callback の引数:

  • key (string) : 送信元である Client の Key。
  • command (string) : コマンド名。ex: rollcolor
  • args (Array) : コマンドに対する引数

例:

var spheroWebSocket = require("sphero-websocket");
var spheroWS = spheroWebSocket({ /* config */});

spheroWS.events.on("command", function(key, command, args) {
  console.log("command received from " + key);
  console.log("orb." + command + "(" + args.join(", "); + ");"); // ex. orb.roll(100, 30)
});

Clone this wiki locally