ExistentialAudio/SwiftOSC

removing "/" safeguards from OSCAddressPattern

jcurtis-cc opened this issue · 12 comments

Hi Devin,

New to Swift, but loving SwiftOSC.

I've got an OSC server inside an app that is already written to parse specific OSC Address paths that don't include the opening "/" character.

I can send messages using other OSC frameworks (oscP5, ofxOSC, MaxMSP etc) without the opening slash - and the server successfully parses these messages. Rebuilding this server from source and altering the parser isn't feasible.

I'd like to be able to use SwiftOSC, but can't seem to successfully send any messages after changing the OSCAddressPattern to remove the opening slash "/"

Having a dig through OSCAddressPattern.swift I think I can see that it's probably returning false when the opening slash is removed. Can this be overridden safely?

Commenting out this feels hacky.. but works.

if address.first != "/" { return false }

Actually, commenting out these lines only worked in the OSCTest example.

In the project I'm using where SwiftOSC was installed via CocoaPods, commenting out these lines doesn't work.

Is there an easy fix?

Sorry wrong button.

It will be safer if you change to the following.

if address.first != "/" {
    self.string = "/" + address
}

Haven't tested but it should work. The will not work without the leading "/" so this way you make it optional to add and add it if it doesn't exist.

For context:

How oscP5 servers handle addresspatterns without opening slashes from clients:

screen shot 2018-11-23 at 12 46 41 pm

How SwiftOSC servers handle addresspatterns without opening slashes from clients:

screen shot 2018-11-23 at 12 50 55 pm

Thanks. That was a good read. I think I agree with @colinbdclark on this. Best of luck with your app.