Mercurial > hg > beaglert
comparison resources/osc/node_modules/osc-min/examples/oscbundle_heartbeat.js @ 284:7bfb25a2e158 Doxy prerelease
Merge
author | Robert Jack <robert.h.jack@gmail.com> |
---|---|
date | Tue, 17 May 2016 15:53:24 +0100 |
parents | fb9c28a4676b |
children |
comparison
equal
deleted
inserted
replaced
269:ac8eb07afcf5 | 284:7bfb25a2e158 |
---|---|
1 // Generated by CoffeeScript 1.10.0 | |
2 var dgram, now, 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 now = function() { | |
17 return (new Date()).getTime() / 1000; | |
18 }; | |
19 | |
20 sendHeartbeat = function() { | |
21 var buf; | |
22 buf = osc.toBuffer({ | |
23 timetag: now() + 0.05, | |
24 elements: [ | |
25 { | |
26 address: "/p1", | |
27 args: new Buffer("beat") | |
28 }, { | |
29 address: "/p2", | |
30 args: "string" | |
31 }, { | |
32 timetag: now() + 1, | |
33 elements: [ | |
34 { | |
35 address: "/p3", | |
36 args: 12 | |
37 } | |
38 ] | |
39 } | |
40 ] | |
41 }); | |
42 return udp.send(buf, 0, buf.length, outport, "localhost"); | |
43 }; | |
44 | |
45 setInterval(sendHeartbeat, 2000); | |
46 | |
47 console.log("sending heartbeat messages to http://localhost:" + outport); |