comparison resources/osc/node_modules/osc-min/examples/oscheartbeat.coffee @ 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 # 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