annotate resources/osc/node_modules/osc-min/examples/oscbundle_heartbeat.js @ 323:b99b8ab317dd
prerelease
Using make commands within build_project.sh instead of explicit command lines
author |
Giulio Moro <giuliomoro@yahoo.it> |
date |
Thu, 02 Jun 2016 02:15:40 +0100 |
parents |
fb9c28a4676b |
children |
|
rev |
line source |
l@271
|
1 // Generated by CoffeeScript 1.10.0
|
l@271
|
2 var dgram, now, 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 now = function() {
|
l@271
|
17 return (new Date()).getTime() / 1000;
|
l@271
|
18 };
|
l@271
|
19
|
l@271
|
20 sendHeartbeat = function() {
|
l@271
|
21 var buf;
|
l@271
|
22 buf = osc.toBuffer({
|
l@271
|
23 timetag: now() + 0.05,
|
l@271
|
24 elements: [
|
l@271
|
25 {
|
l@271
|
26 address: "/p1",
|
l@271
|
27 args: new Buffer("beat")
|
l@271
|
28 }, {
|
l@271
|
29 address: "/p2",
|
l@271
|
30 args: "string"
|
l@271
|
31 }, {
|
l@271
|
32 timetag: now() + 1,
|
l@271
|
33 elements: [
|
l@271
|
34 {
|
l@271
|
35 address: "/p3",
|
l@271
|
36 args: 12
|
l@271
|
37 }
|
l@271
|
38 ]
|
l@271
|
39 }
|
l@271
|
40 ]
|
l@271
|
41 });
|
l@271
|
42 return udp.send(buf, 0, buf.length, outport, "localhost");
|
l@271
|
43 };
|
l@271
|
44
|
l@271
|
45 setInterval(sendHeartbeat, 2000);
|
l@271
|
46
|
l@271
|
47 console.log("sending heartbeat messages to http://localhost:" + outport);
|