Comparing version
(function() { | ||
//~readme.out~ | ||
//[](http://travis-ci.org/russellmcc/node-osc-min) | ||
//# osc-min | ||
@@ -5,0 +6,0 @@ // |
{ | ||
"name": "osc-min", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"main": "lib/index", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -0,1 +1,2 @@ | ||
[](http://travis-ci.org/russellmcc/node-osc-min) | ||
# osc-min | ||
@@ -41,44 +42,56 @@ | ||
## Examples | ||
### A simple OSC printer | ||
```coffee-script | ||
sock = udp.createSocket "udp4", (msg, rinfo) -> | ||
try | ||
console.log osc.fromBuffer msg | ||
catch error | ||
console.log "invalid OSC packet" | ||
sock.bind inport | ||
### A simple OSC printer; | ||
```javascript | ||
sock = udp.createSocket("udp4", function(msg, rinfo) { | ||
try { | ||
return console.log(osc.fromBuffer(msg)); | ||
} catch (error) { | ||
return console.log("invalid OSC packet"); | ||
} | ||
}); | ||
sock.bind(inport); | ||
``` | ||
### Send a bunch of args every two seconds | ||
```coffee-script | ||
sendHeartbeat = () -> | ||
buf = osc.toBuffer( | ||
address : "/heartbeat" | ||
args : [ | ||
12 | ||
"sttttring" | ||
new Buffer "beat" | ||
{type : "integer", value : 7} | ||
] | ||
) | ||
### Send a bunch of args every two seconds; | ||
```javascript | ||
udp.send buf, 0, buf.length, outport, "localhost" | ||
setInterval sendHeartbeat, 2000 | ||
sendHeartbeat = function() { | ||
var buf; | ||
buf = osc.toBuffer({ | ||
address: "/heartbeat", | ||
args: [ | ||
12, "sttttring", new Buffer("beat"), { | ||
type: "integer", | ||
value: 7 | ||
} | ||
] | ||
}); | ||
return udp.send(buf, 0, buf.length, outport, "localhost"); | ||
}; | ||
setInterval(sendHeartbeat, 2000); | ||
``` | ||
### A simple OSC redirecter | ||
```coffee-script | ||
sock = udp.createSocket "udp4", (msg, rinfo) -> | ||
try | ||
redirected = osc.applyAddressTransform msg, (address) -> "/redirect" + address | ||
sock.send( | ||
redirected, | ||
0, | ||
redirected.length, | ||
outport, | ||
"localhost" | ||
) | ||
catch error | ||
console.log "error redirecting: " + error | ||
sock.bind inport | ||
### A simple OSC redirecter; | ||
```javascript | ||
sock = udp.createSocket("udp4", function(msg, rinfo) { | ||
var redirected; | ||
try { | ||
redirected = osc.applyAddressTransform(msg, function(address) { | ||
return "/redirect" + address; | ||
}); | ||
return sock.send(redirected, 0, redirected.length, outport, "localhost"); | ||
} catch (error) { | ||
return console.log("error redirecting: " + error); | ||
} | ||
}); | ||
sock.bind(inport); | ||
``` | ||
@@ -85,0 +98,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
83395
28.73%22
57.14%468
201.94%212
6.53%6
Infinity%