File: osc_test.js

package info (click to toggle)
freej 0.10git20100110-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 32,080 kB
  • ctags: 22,705
  • sloc: cpp: 156,254; ansic: 25,531; sh: 13,538; perl: 4,624; makefile: 3,278; python: 2,889; objc: 1,284; asm: 1,125; ruby: 126
file content (36 lines) | stat: -rw-r--r-- 1,025 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// testing OSC messaging

osc = new OscController("9696"); // open an OSC listener on port 9696

// auxiliary keyboard
kbd = new KeyboardController();
register_controller( kbd );
kbd.released_q = function() { quit(); };

// pressing 'm' will send a test message to itself
kbd.released_m = function() {
    osc.send("/test","ifs",123,4.5,"hello");
}



 // define the function that will be called
osc.test_callback =  function test_callback(i,f,s) {
     echo("OSC remote call to my test function");
     echo("int argument is: " + i);
     echo("float argument is: " + f);
     echo("string argument is: " + s);
     return true;
};

// create a /my_new_method call on OSC, taking one integer as argument, that
// will call the remote_called_function() defined in javascript:
osc.add_method("/test","ifs","test_callback");
osc.send_to("localhost","9696");

// starts the osc listener thread
osc.start();
// to stop it during execution use osc.stop();

// and don't forget to register the controller
register_controller(osc);