annotate resources/osc/node_modules/osc-min/examples/oscheartbeat.js @ 271:fb9c28a4676b prerelease

Added osc example project and node script for testing
author Liam Donovan <l.b.donovan@qmul.ac.uk>
date Tue, 17 May 2016 16:01:06 +0100
parents
children
rev   line source
l@271 1 // Generated by CoffeeScript 1.10.0
l@271 2 var dgram, osc, outport, sendHeartbeat, udp;
l@271 3
l@271 4 osc = require('osc-min');
l@271 5
l@271 6 dgram = require("dgram");
l@271 7
l@271 8 udp = dgram.createSocket("udp4");
l@271 9
l@271 10 if (process.argv[2] != null) {
l@271 11 outport = parseInt(process.argv[2]);
l@271 12 } else {
l@271 13 outport = 41234;
l@271 14 }
l@271 15
l@271 16 console.log("sending heartbeat messages to http://localhost:" + outport);
l@271 17
l@271 18 //~verbatim:examples[1]~
l@271 19 //### Send a bunch of args every two seconds;
l@271 20
l@271 21 sendHeartbeat = function() {
l@271 22 var buf;
l@271 23 buf = osc.toBuffer({
l@271 24 address: "/heartbeat",
l@271 25 args: [
l@271 26 12, "sttttring", new Buffer("beat"), {
l@271 27 type: "integer",
l@271 28 value: 7
l@271 29 }
l@271 30 ]
l@271 31 });
l@271 32 return udp.send(buf, 0, buf.length, outport, "localhost");
l@271 33 };
l@271 34
l@271 35 setInterval(sendHeartbeat, 2000);