node-red-contrib-osc
node-red-contrib-osc copied to clipboard
Allow OSC receive parser to work with TCP packets
OSC 1.0 standard says that messages sent over TCP must be prefixed with the message length, encoded as 4 bytes.
In a stream-based protocol such as TCP, the stream should begin with an int32 giving the size of the first packet, followed by the contents of the first packet, followed by the size of the second packet, etc.
Since the OSC module does not know messages have been received by a TCP connection rather than UDP, this PR adds a TCP checkbox to tell the node module to remove and ignore the first 4 bytes, allowing it to successfully parse OSC messages.
Thanks for this !
In theory I think you could get rid of the checkbox and do it automatically by checking the incoming message for session type:
Automatic detection now in place and working. Checkbox removed.
Is it worth checking that the payload is the size that the length field says it should be?
This has been a voyage of discovery. It turns out our implementation of the length bytes was the wrong endian according to the spec - but we had followed the endianness of TouchOSC who also had it wrong. They have now fixed their implementation in the latest beta, so we should be able to line everything up now.