Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Commit

Permalink
Added OSC stuff to the K2 namespace and to the compiled library
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiano-belloni committed Nov 30, 2012
1 parent 0ccce2c commit 4e6587e
Show file tree
Hide file tree
Showing 7 changed files with 554 additions and 94 deletions.
22 changes: 11 additions & 11 deletions comm/OSCHandler.js
@@ -1,12 +1,12 @@
OSCClient = function (localClient, oscHandler) {
K2.OSCClient = function (localClient, oscHandler) {

this.oscHandler = oscHandler;
this.clientID = localClient.clientID;
this.oscCallback = localClient.oscCallback;
this.isListening = localClient.isListening || true;
}
};

OSCClient.prototype.sendOSC = function (oscMessage, args) {
K2.OSCClient.prototype.sendOSC = function (oscMessage, args) {
// Encode it
var binaryMsg = this.oscHandler.OSCEncoder.encode(oscMessage);
var flags = args;
Expand All @@ -22,13 +22,13 @@ OSCClient.prototype.sendOSC = function (oscMessage, args) {
if (flags.sendLocal !== false) {
this.oscHandler.sendLocalMessage.apply (this.oscHandler, [binaryMsg, this.clientID]);
}
}
};

OSCHandler = function (proxyServer, udpServers) {
K2.OSCHandler = function (proxyServer, udpServers) {

this.localClients = {};
this.OSCDecoder = new Decoder();
this.OSCEncoder = new Encoder();
this.OSCDecoder = new K2.OSC.Decoder();
this.OSCEncoder = new K2.OSC.Encoder();
this.udpServers = udpServers || null;
this.proxyServer = proxyServer || null;
this.proxyOK = false;
Expand Down Expand Up @@ -85,16 +85,16 @@ OSCHandler = function (proxyServer, udpServers) {
}
};
/* localclient = {clientID, oscCallback, isListening} */
OSCHandler.prototype.registerClient = function (localClient) {
this.localClients[localClient.clientID] = new OSCClient (localClient, this);
K2.OSCHandler.prototype.registerClient = function (localClient) {
this.localClients[localClient.clientID] = new K2.OSCClient (localClient, this);
return this.localClients[localClient.clientID];
};

OSCHandler.prototype.unregisterClient = function (clientID) {
K2.OSCHandler.prototype.unregisterClient = function (clientID) {
delete this.localClients[clientID];
};

OSCHandler.prototype.sendLocalMessage = function (oscMessage, clientID) {
K2.OSCHandler.prototype.sendLocalMessage = function (oscMessage, clientID) {
// Try to decode it
var received = this.OSCDecoder.decode (oscMessage);
console.log ("decoded OSC = " + received);
Expand Down

0 comments on commit 4e6587e

Please sign in to comment.