Menu

#23 dispatch_method on wildcards broken

open
nobody
None
5
2008-11-09
2008-11-09
Ryan Pavlik
No

The handling of pattern methods appears to be broken:

* lo_server_add_method ignores requests to add pattern method handlers (server.c:961)
* lo_server_del_method deletes methods based on pattern match (server.c:1010)
* dispatch_method determines whether to match a pattern based on the _incoming_ path (server.c:705)

What seems much more useful:

* lo_server_add_method tags each method as being a pattern match or not
* dispatch_method does lo_pattern_match(path, it->path) rather than the opposite
* lo_server_del_method only deletes explicitly-registered handlers, pattern or otherwise

Attached is a patch to change this. It does not address testlo.c as I'm not exactly sure what's going on there. I can't imagine any possible use for _sending_ wildcards.

Discussion

  • Ryan Pavlik

    Ryan Pavlik - 2008-11-09

    Patch to make wildcards match from the method rather than the incoming message.

     
  • Stephen Sinclair

    Thanks. It's interesting to consider pattern matching from the opposite point of view, writing methods which accept various matched messages. It could have a use case.

    However I think the current way LibLo does pattern matching is more useful -> you add methods for specific messages, and then the user can send a message to several handlers at once by sending a pattern. In your suggestion, method handlers might need to then parse the path manually if they need to know something about it.

     
  • Ryan Pavlik

    Ryan Pavlik - 2009-02-01

    Oh, rereading the spec I see this is how they specify it. It seems pretty useless: in what scenario would you want to invoke a pattern-match of messages? Perhaps if you wish to send "all notes off" to every device or something, but this is of highly limited use. In realistic cases you want to send *specific* methods:

    /sequencer/block1 play
    /synth/note 64
    /window/drawcircle x y r

    ...and then write a method for "/sequencer/*", "/synth/*", etc. I can dispatch these manually I guess, liblo isn't doing anything particularly magical.

    (I'd love to see a realistic, common use for *sending* patterns rather than *receiving* them. Can't argue with the spec though... even if it's dumb.)

     

Log in to post a comment.