hypebeast / go-osc

Open Sound Control (OSC) library for Golang. Implemented in pure Go.
MIT License
200 stars 46 forks source link

AddMsgHandler matches parts of addresses #44

Open CDaxi opened 4 years ago

CDaxi commented 4 years ago

Example code:

  addr := "127.0.0.1:9000"
  d := osc.NewStandardDispatcher()

  d.AddMsgHandler("/time/str", func (msg *osc.Message) {
      fmt.Print("-> ")
      fmt.Println(msg)
  })

Example console output:

-> /time ,f 16743.264
-> /time/str ,s 4:39:03.263
-> /time ,f 16743.36
-> /time/str ,s 4:39:03.359

The code should only match /time/str but the MsgHandler matches /time without str too. This code lines seems to be the reason: https://github.com/hypebeast/go-osc/blob/master/osc/osc.go#L146 https://github.com/hypebeast/go-osc/blob/master/osc/osc.go#L212

Escaping the address with \/ does not help. If I do this, I will get an error unknown escape sequence

Current workaround:

I would be very happy to have this issue fixed because this creates very confusing issues.

Thanks a lot. Christian