I’m working on some puredata objects for use with serialosc, to make finding, connecting to and communicating with grids and arcs easier. Right now I’m working on using serialosc’s device add/remove notification feature to enable seamless reconnection to devices which get unplugged, and I’ve come across a couple of odd things.
Firstly, there seems to be a mistake in the serialosc documentation about the
/serialosc/remove messages which are sent to my application on device status changes. The documentation says that the data sent is a single string, the ID of the device. When I actually get the messages however, the data is exactly the same as I get from
/serialosc/device, ssi-formatted id, name, portnumber. If anything this is more useful than just the ID, but if this is intended behaviour then the documentation needs to be corrected.
Secondly, it seems as though sending multiple identical notification requests to
/serialosc/notify results in that number of identical notifications being sent when a device is dis/connected. Seeing as there is no (documented) way to cancel a request for a given (hostname, portnumber) pair, I would expect calls to
/serialosc/notify to be idempotent, where multiple notification requests collapse into one until it’s cleared by a notification being sent.
The specific problem this is causing for me is that when I create a [monome grid] object, it requests a notification. If I then delete the [monome] object and create another one, it’s usually assigned the same port number as the previous one was, but also requests a notification. Then, when a device is added, it gets two notifications (or more if I’ve created the object several times).
It’s difficult to filter out these multiple notifications on the client side as that would require maintaining a list of all the device IDs seen by an object and their current status, which a) is annoyingly difficult to do in puredata and b) seems more like it’s serialosc’s job anyway.
So am I right in thinking that this is a serialosc bug or at least unintended behaviour which could be improved by making notification requests idempotent, or is this a necessary behaviour which I need to work around on the client side?