comparison resources/osc/node_modules/osc-min/examples/oscbundle_heartbeat.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, 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);