src/test/03-Modules/osc01.ck
raw| 1 | |
| 2 | OscIn oin; |
| 3 | OscMsg msg; |
| 4 | |
| 5 | 12001 => int OSC_PORT; |
| 6 | |
| 7 | OSC_PORT => oin.port; |
| 8 | oin.addAddress( "/test" ); |
| 9 | |
| 10 | spork ~ send(); |
| 11 | |
| 12 | oin => now; |
| 13 | |
| 14 | oin.recv(msg); |
| 15 | |
| 16 | if(msg.getString(0) == "hello!") |
| 17 | <<< "success" >>>; |
| 18 | else |
| 19 | <<< "failure" >>>; |
| 20 | |
| 21 | fun void send() |
| 22 | { |
| 23 | 1::samp => now; |
| 24 | |
| 25 | while(true) |
| 26 | { |
| 27 | OscOut xmit; |
| 28 | xmit.dest( "localhost", OSC_PORT ); |
| 29 | xmit.start( "/test" ).add("hello!").send(); |
| 30 | |
| 31 | 1::second => now; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 |