| 1 |
// test OSC wildcards pattern matching |
| 2 |
// added 1.5.2.2 |
| 3 |
|
| 4 |
OscIn oin; |
| 5 |
OscMsg msg; |
| 6 |
|
| 7 |
// the port |
| 8 |
12003 => int OSC_PORT; |
| 9 |
OSC_PORT => oin.port; |
| 10 |
|
| 11 |
// address to listen for, with wildcard |
| 12 |
oin.addAddress( "/test/*, is" ); |
| 13 |
|
| 14 |
// spork sender |
| 15 |
spork ~ send(); |
| 16 |
|
| 17 |
// wait on OSC |
| 18 |
oin => now; |
| 19 |
|
| 20 |
// get the message |
| 21 |
oin.recv(msg); |
| 22 |
|
| 23 |
// test |
| 24 |
if( msg.getInt(0) == 42 && msg.getString(1) == "hello!" ) |
| 25 |
{ <<< "success" >>>; } else { <<< "failure" >>>; } |
| 26 |
|
| 27 |
// send function |
| 28 |
fun void send() |
| 29 |
{ |
| 30 |
1::samp => now; |
| 31 |
|
| 32 |
while(true) |
| 33 |
{ |
| 34 |
OscOut xmit; |
| 35 |
xmit.dest( "localhost", OSC_PORT ); |
| 36 |
// OSC address |
| 37 |
xmit.start( "/test/foo" ); |
| 38 |
// add data |
| 39 |
xmit.add(42); |
| 40 |
xmit.add("hello!"); |
| 41 |
// send |
| 42 |
xmit.send(); |
| 43 |
// wait |
| 44 |
1::second => now; |
| 45 |
} |
| 46 |
} |