Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address matching, glob / wildcards #15

Open
avlapp opened this issue Nov 25, 2022 · 9 comments · May be fixed by #19
Open

Address matching, glob / wildcards #15

avlapp opened this issue Nov 25, 2022 · 9 comments · May be fixed by #19
Assignees

Comments

@avlapp
Copy link

avlapp commented Nov 25, 2022

Is there support for OSC address pattern wildcards like '*', '?', '{,}' and '[]'?

@vlappa
Copy link

vlappa commented Jul 2, 2023

It looks like this is a misunderstanding of the OSC spec:

var invalidAddressRunes = []rune{'*', '?', ',', '[', ']', '{', '}', '#', ' '}

"// ValidateAddress returns an error if addr contains
// characters that are disallowed by the OSC spec."

osc/conn.go

Line 34 in ba4a707

// ValidateAddress returns an error if addr contains

I think the OSC spec doesn't talk about OSC addresses, but about those "printable ASCII characters not allowed in names of OSC Methods or OSC Containers"

https://opensoundcontrol.stanford.edu/spec-1_0.html

@KopiasCsaba
Copy link

KopiasCsaba commented Aug 30, 2023

I've found the same issue, and I've found the soultion too, I think it's a simple accident:

Here:

osc/message.go

Line 92 in 53342a9

exp, err := GetRegex(msg.Address)

should be just

xp, err := GetRegex(address)

When I'll ihave time I might open a PR on that.

@vlappa
Copy link

vlappa commented Aug 30, 2023

Finally someone else who seems to use this library. :) If that works, great find. Yes please a PR would be welcome.

My biggest practical issue with this library is currently this one:
#17

I've to use a external tool which uses the hypebeast/go-osc library to send a empty string (to a client that uses the C/C++ liblo library).

Would be nice if these issues can be sorted out, in general this library is really useful for me.

@vlappa
Copy link

vlappa commented Aug 30, 2023

It indeed attempts to support Regex, so my second msg in this thread is a wrong assumption.

Looking at this func:

osc/message.go

Line 147 in 53342a9

func VerifyParts(m1, m2 string) bool {

It seems to expect that both addresses have the same amount of parts, maybe there it goes wrong?

If the address in the handler is /foo/bar/one

/foo/* wouldn't work, cause it doesn't have the same number of parts, while /foo/*/* should work I think.

@KopiasCsaba KopiasCsaba linked a pull request Sep 1, 2023 that will close this issue
@KopiasCsaba
Copy link

It seems to expect that both addresses have the same amount of parts, maybe there it goes wrong?

Thats true, so the message address should have the same number of parts (splitted by /), and then the pattern matching occurs.

So saying "*" will only match /foo or /bar, not /foo/bar.

So then the pattern matching had a little mixup, for which I just opened the PR to fix.

@vlappa
Copy link

vlappa commented Sep 1, 2023

I doubt this is what 'we' want. I saw @briansorahan was also doing stuff around the Non-Session-Manager api and for broadcasting it seems it has to accept all paths. So it would be good if this library would support this.

From nsm.h which uses the c/c++ liblo library:

lo_server_add_method( _NSM()->_server, "/error", "sis", _nsm_osc_error, _NSM() );
lo_server_add_method( _NSM()->_server, "/reply", "ssss", _nsm_osc_announce_reply, _NSM() );
lo_server_add_method( _NSM()->_server, "/nsm/client/open", "sss", _nsm_osc_open, _NSM() );
lo_server_add_method( _NSM()->_server, "/nsm/client/save", "", _nsm_osc_save, _NSM() );
lo_server_add_method( _NSM()->_server, "/nsm/client/session_is_loaded", "", _nsm_osc_session_is_loaded, _NSM() );
lo_server_add_method( _NSM()->_server, NULL, NULL, _nsm_osc_broadcast, _NSM() );

path | The OSC path to register the method to. If NULL is passed the method will match all paths.
https://liblo.sourceforge.net/docs/group__liblolowlevel.html#ga56c5f1d587c215c27e92e6436e12b1a3

@KopiasCsaba
Copy link

Yes, you are right, I have a PR on adding a regexp matcher already, see: #20!
So the PatternMatcher is the standard compilant one (after my other PR is merged), but we indeed need something else.

But, you can make your own meanwhile just implement the Dispatcher interface!

@KopiasCsaba
Copy link

(Or you can copy from my code, or customize the one from here: https://github.com/scgolang/osc/blob/master/customdispatcher_example_test.go)

@vlappa
Copy link

vlappa commented Sep 1, 2023

Thanks, I'll look at it more closely when I've more time.

@briansorahan briansorahan self-assigned this Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants