Mercurial > hg > beaglert
comparison resources/osc/node_modules/osc-min/examples/oscheartbeat.coffee @ 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 # This example simply sends a message with several parameter types | |
2 # every two seconds to port 41234 | |
3 | |
4 osc = require 'osc-min' | |
5 dgram = require "dgram" | |
6 | |
7 udp = dgram.createSocket "udp4" | |
8 | |
9 if process.argv[2]? | |
10 outport = parseInt process.argv[2] | |
11 else | |
12 outport = 41234 | |
13 console.log "sending heartbeat messages to http://localhost:" + outport | |
14 | |
15 `//~verbatim:examples[1]~ | |
16 //### Send a bunch of args every two seconds` | |
17 sendHeartbeat = () -> | |
18 buf = osc.toBuffer( | |
19 address : "/heartbeat" | |
20 args : [ | |
21 12 | |
22 "sttttring" | |
23 new Buffer "beat" | |
24 {type : "integer", value : 7} | |
25 ] | |
26 ) | |
27 | |
28 udp.send buf, 0, buf.length, outport, "localhost" | |
29 | |
30 setInterval sendHeartbeat, 2000 |