Mercurial > hg > beaglert
comparison 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 |
comparison
equal
deleted
inserted
replaced
270:de37582ce6f3 | 271:fb9c28a4676b |
---|---|
1 // Generated by CoffeeScript 1.10.0 | |
2 var dgram, osc, outport, sendHeartbeat, udp; | |
3 | |
4 osc = require('osc-min'); | |
5 | |
6 dgram = require("dgram"); | |
7 | |
8 udp = dgram.createSocket("udp4"); | |
9 | |
10 if (process.argv[2] != null) { | |
11 outport = parseInt(process.argv[2]); | |
12 } else { | |
13 outport = 41234; | |
14 } | |
15 | |
16 console.log("sending heartbeat messages to http://localhost:" + outport); | |
17 | |
18 //~verbatim:examples[1]~ | |
19 //### Send a bunch of args every two seconds; | |
20 | |
21 sendHeartbeat = function() { | |
22 var buf; | |
23 buf = osc.toBuffer({ | |
24 address: "/heartbeat", | |
25 args: [ | |
26 12, "sttttring", new Buffer("beat"), { | |
27 type: "integer", | |
28 value: 7 | |
29 } | |
30 ] | |
31 }); | |
32 return udp.send(buf, 0, buf.length, outport, "localhost"); | |
33 }; | |
34 | |
35 setInterval(sendHeartbeat, 2000); |