sojamo / oscp5

An Open Sound Control (OSC) implementation for Java and Processing
GNU Lesser General Public License v2.1
132 stars 51 forks source link

Parse bundle wrong data is taken #2

Closed cansik closed 8 years ago

cansik commented 9 years ago

There is a bug in the method parseBundle() in OscPatcher where you choose the wrong data map. Instead of the one you just split, you take the bundle map:

...
m0.put( "data" , Bytes.copy( bytes , myPosition , myMessageLength ) );
m0.put( "socket-ref" , m.get( "socket-ref" ) );
m0.put( "socket-address" , m.get( "socket-address" ) );
m0.put( "socket-port" , m.get( "socket-port" ) );
m0.put( "local-port" , m.get( "local-port" ) );

messages.add( new OscMessage( m ) );
...

So it should be:

messages.add( new OscMessage( m0 ) );

Took me some hours to notice this bug. Cheers Florian

sojamo commented 9 years ago

thanks for spotting this. I have just updated to 2.0.4. Bundles can now be received via oscEvent(OscBundle), see the oscP5bundle example.

cansik commented 9 years ago

Oh ok, that could have saved me some hours of extending your code haha :+1: Is version 2.0.4 also in the processing repository? I just find the version 0.9.9?

Bundle support works, thank you! But because of the default-size of the message array, I always get too much messages to process (by default 10). How can I get the number of the received messages? Wouldn't it be better to use an ArrayList?

sojamo commented 9 years ago

2.0.4 is only available from this github repo. the processing library manager currently still picks up 0.9.9, this repo's version has still some hiccups like this bundle issue.

Not sure if I understand the second part though, by 'the message array' are you referring to an array inside your code? Messages inside a Bundle are stored inside an ArrayList. you can get the size of that list by calling theBundle.size().

cansik commented 9 years ago

Ah ok, yeah maybe it's a wrong implementation of the osc sender. I'm not the developer of the sender, only of the receiver. Yeah it's a list sorry, i was just confused by the processing debugger which still is a bit strange.

Thank you for the fast response!