Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ofxOsc - receiving bundles without unwrapping? #2794

Closed
ofTheo opened this Issue Feb 5, 2014 · 11 comments

Comments

Projects
None yet
3 participants
Contributor

ofTheo commented Feb 5, 2014

I started building some features for a project around ofxOscBundle, which looked great for sending a collection of messages as a group.

However I was surprised to see that it is not possible to receive bundles and that bundled messages are unpacked by OscPacketListener / ofxOscListener as un-bundled messages.

It doesn't seem to hard to add in the possibility of receiving bundles - but I just wanted to check with @DamianZ and others to see if there was a specific reason why this is not included in the current addon.

Any thoughts would be most appreciated.

Thanks!

Owner

bilderbuchi commented Feb 5, 2014

huh, I thought we do everything bundled in ofxOSC? (it's been a time since I looked at it, though)
edit: indeed, #1804

Owner

bilderbuchi commented Feb 5, 2014

also, cf. #1911

Owner

bilderbuchi commented Feb 5, 2014

bundled messages are unpacked by OscPacketListener / ofxOscListener as un-bundled messages.

could you explain what you mean? bundles are only for transmission, afaik the bundles must be unpacked at the endpoint so that you can get at the messages in the bundles, right?

Contributor

ofTheo commented Feb 5, 2014

@bilderbuchi

yeah I am not sure :)
This is why I was asking as I am not entirely sure if bundles are meant to come through as a structure.

an example:

I send:

bundle
  - msg a
  - msg b
  - msg c 
  - bundle 
     - msg 1 
     - mag 2

I get:

- msg a 
- msg b
- msg c 
- msg 1 
- msg 2 

what I want to get:

bundle
  - msg a
  - msg b
  - msg c 
  - bundle 
     - msg 1 
     - mag 2 

I actually already wrote the code for this since posting the issue.
It works great and didn't require oscpack modification.

With ofxOscBundle it is very easy to traverse the bundle and get messages.
The main thing is that you get back what you sent and you can associate the messages together, where as with the current implementation you can't.

Anyway, curious if this is breaking the spec or actually fully implementing it :)

Owner

bilderbuchi commented Feb 5, 2014

Ah I think I see. Bundles within bundles are covered by the spec. It doesn't say if bundles within bundles should be recursively unpacked, but if I read it right, messages should be unpacked on receipt (and the OSC messages processed) anyway.
I'm still wondering what you want to do with the not-unwrapped bundles after receiving them, though? Don't you want the OSC messages within to be processed and emitted? 😕

Owner

bilderbuchi commented Feb 5, 2014

I edited the title to clarify its meaning (as we can currently receive bundles alright)

Contributor

ofTheo commented Feb 5, 2014

thanks @bilderbuchi.
yes, it does seem a little vague.

In a sense I am still getting the messages, but I am just getting them via the bundle structure.

Here is the current approach I have: https://gist.github.com/ofTheo/8833459
If you call ofxOscReceiver::setReceiveBundles(true) then unbundled messages still come through in the ofxOscReceiver::getNextMessage(ofxOscMessage_) call, but bundled messages are feteched via ofxOscReceiver::getNextBundle( ofxOscBundle_ ) call.
If ofxOscReceiver::setReceiveBundles(false) is called ( which is the default and current behavior ) messages are fully unpacked from the bundle and you have no way if knowing which bundle they were in.

The main reason for this is that I am serializing classes of different types into a bundle and I want to be able to associate all the messages which represent parameters as coming from one class instance on receipt.

Having the messages just come in unpacked and un-nested makes figuring out which class and which class instance they have come from really hard.

Not sure if that helps in anyway.
To me bundles seem really useful, but only if you can have that info pass through.

Owner

bilderbuchi commented Feb 6, 2014

AFAIK, what bundles are meant for (according to the spec) are to

  • make sure a set of OSC messages are processed in a certain order (which is only guaranteed for messages in a bundle) and immediately after one another
  • trigger a (set of) OSC message(s) at the receiver at a certain time (given by the bundle time tag)

To achieve what you want in an alternative way, I think you could add some hash of the class instance as an additional parameter to the respective OSC messages. Then the hash value unambiguously defines which messages belong together.

You could also use the order-of-processing feature of bundles to achieve this if you pack into bundles as before, but add an "instance-starts" message at the beginning of the bundle, and an "instance-ends" at the end. then you could also identify instances unambiguously, as the bundle guarantees that those messages will bracket the messages belonging to one instance (even if they are fully unpacked on receipt!).
This has the additional upside that you are not relying on a probably-out-of-spec mechanism for your stuff to work correctly, and as such would be able to communicate with other (read non-OF) OSC agents.

Contributor

ofTheo commented Feb 6, 2014

Thanks @bilderbuchi !

This was exactly the type of response I was hoping for opening this issue.
It wasn't super clear to me, but looking at other osc libraries I see the same logic that you described.

I appreciate your time looking at this.
Going to close this issue and see if I can do this in a purely message based way :)

@ofTheo ofTheo closed this Feb 6, 2014

Owner

arturoc commented Feb 6, 2014

@ofTheo don't remember exactly how :) but the osc (de)serializer for ofParameter(Group) works in a hierarchical way with the current structure in ofxOsc, it's in ofxOscReceiver and ofxOscSender

Contributor

ofTheo commented Feb 7, 2014

thanks!
I actually used it as a reference :)

On Feb 6, 2014, at 8:48 AM, arturo notifications@github.com wrote:

@ofTheo don't remember exactly how :) but the osc (de)serializer for ofParameter(Group) works in a hierarchical way with the current structure in ofxOsc, it's in ofxOscReceiver and ofxOscSender


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment