l@271: # Same thing as the oscheartbeat example but with oscbundles. l@271: l@271: osc = require 'osc-min' l@271: dgram = require "dgram" l@271: l@271: udp = dgram.createSocket "udp4" l@271: l@271: if process.argv[2]? l@271: outport = parseInt process.argv[2] l@271: else l@271: outport = 41234 l@271: l@271: # Get the unix timestamp in seconds l@271: now = -> (new Date()).getTime() / 1000; l@271: l@271: sendHeartbeat = () -> l@271: buf = osc.toBuffer( l@271: timetag : now() + 0.05 # 0.05 seconds from now l@271: elements : [ l@271: { l@271: address : "/p1" l@271: args : new Buffer "beat" l@271: } l@271: { l@271: address : "/p2" l@271: args : "string" l@271: } l@271: { l@271: timetag: now() + 1 # 1 second from now l@271: elements : [ l@271: { l@271: address : "/p3" l@271: args : 12 l@271: } l@271: ] l@271: } l@271: ] l@271: ) l@271: l@271: udp.send buf, 0, buf.length, outport, "localhost" l@271: l@271: setInterval sendHeartbeat, 2000 l@271: l@271: console.log "sending heartbeat messages to http://localhost:" + outport