Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/osc.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = function(io) {

socket.on('create', function(opts) {
log('server'.magenta, 'created'.grey, '127.0.0.1:' + opts.port);
var server = new osc.UdpReceiver(opts.port);
var server = new osc.UdpReceiver(opts.port, { broadcast: true });

server.on('', function(message) {
log('server'.magenta, ('127.0.0.1:' + opts.port).grey, message.path, message.params);
Expand All @@ -47,7 +47,7 @@ module.exports = function(io) {

socket.on('create', function(opts) {
log('client'.magenta, 'created'.grey, opts.host + ':' + opts.port);
var client = new osc.UdpSender(opts.host, opts.port);
var client = new osc.UdpSender(opts.host, opts.port, { broadcast: true });

socket.on('osc', function(message){
log('client'.magenta, (opts.host + ':' + opts.port).grey, message.path, message.params);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"colors": "0.6.0",
"omgosc": "0.1.0"
"omgosc": "0.1.1"
},
"main": "./lib/osc.io",
"version": "0.0.2"
Expand Down
26 changes: 24 additions & 2 deletions src/client/osc.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,32 @@ var OscClient = Backbone.Model.extend({
},

sendOsc: function(path, param) {
// first, we need to determine the type of argument(s)
var typetag = '';
var args = Array.prototype.slice.call(arguments, 1);
var i;

// TODO where is a function like this supposed to go in idiomatic backbone?
var oscType = function( o ) {
var t = typeof(o);
if ( t === 'string' ) {
return 's';
} else if ( t === 'number' ) {
if ( o === Math.floor(o)) {
return 'i';
} else {
return 'f';
}
}
}

for ( i = 0; i < args.length; ++i ) {
typetag += oscType(args[i]);
}
this.socket.emit('osc', {
path: path,
typetag: 'f',
params: [param]
typetag: typetag,
params: args
});
}

Expand Down