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