{
for (var i = 0; i < data.length; i++)
{
- console.log("key:" + data[i].key + " / value:" + data[i].value);
+ var key = data[i].key;
+ switch(key)
+ case "command":
+ console.log("key:" + key + " / value:" + data[i].value);
+ break;
+ case "data":
+ case "byteData":
+ console.log("key:" + key + " / value:[");
+ for (var j = 0; j < data[i].value.length; j++)
+ {
+ console.log(data[i].value[j] + ", ")
+ }
+ console.log("]");
+ break;
+ case "bytesData":
+ console.log("key:" + key + " / value:[");
+ for (var j = 0; j < data[i].value.length; j++)
+ {
+ console.log("[");
+ for (var k = 0; k < data[i].value.length; k++)
+ {
+ console.log(data[i].value[j] + ", ")
+ }
+ console.log("]");
+ }
+ console.log("]");
+ break;
+ }
}
if (replyPort)
{
var messageData =
[
{key:"command", value:"begin"},
- {key:"data", value:"dummy"}
+ }
+ }
+ if (replyPort)
+ {
+ console.log("replyPort given: " + replyPort.messagePortName);
+ }
+});
+</pre> </li>
+<li><p>Use the <span style="font-family: Courier New,Courier,monospace">sendMessage()</span> method of the <span style="font-family: Courier New,Courier,monospace">RemoteMessagePort</span> interface to send a message:</p> <pre class="prettyprint">
+var messageData =
+[
+ {key:"command", value:"begin"},
+ {key:"data", value:{"dummy1", "dummy2"}},
+ {key:"byteData", value:[12, 23, 34, 45, 56, 67, 78]},
+ {key:"bytesData", value:[[1, 2, 3, 255], [8, 9, 3, 4, 5]]}
];
remotePort.sendMessage(messageData);
</pre>