Comments (8)
+1
For me, this prevents me from using your library. I need to react on all possible OSC messages using the very same handler, since I cannot anticipate what the actual messages will be.
from osc-js.
The feature was shipped for version 2.0.0
from osc-js.
Hi @Audiow! Thank you 😺
Yes, wildcards are possible. The library supports OSC address pattern matching. You can read about this here: http://opensoundcontrol.org/spec-1_0-examples#addressparts or here http://opensoundcontrol.org/spec-1_0
- '?' in the OSC Address Pattern matches any single character
- '*' in the OSC Address Pattern matches any sequence of zero or more characters
- A string of characters in square brackets (e.g., "[string]") in the OSC Address Pattern matches any character in the string. Inside square brackets, the minus sign (-) and exclamation point (!) have special meanings:
- two characters separated by a minus sign indicate the range of characters between the given two in ASCII collating sequence. (A minus sign at the end of the string has no special meaning.)
- An exclamation point at the beginning of a bracketed string negates the sense of the list, meaning that the list matches any character not in the list. (An exclamation point anywhere besides the first character after the open bracket has no special meaning.)
- A comma-separated list of strings enclosed in curly braces (e.g., "{foo,bar}") in the OSC Address Pattern matches any of the strings in the list.
- Any other character in an OSC Address Pattern can match only the same character.
Please note that this is only possible for sending packages, not receiving (to follow the OSC standard):
When an OSC server receives an OSC Message, it must invoke the appropriate OSC Methods in its OSC Address Space based on the OSC Message's OSC Address Pattern. This process is called dispatching the OSC Message to the OSC Methods that match its OSC Address Pattern. All the matching OSC Methods are invoked with the same argument data, namely, the OSC Arguments in the OSC Message.
See an example here: https://github.com/adzialocha/osc-js/wiki/Basic-Usage#receive-messages
from osc-js.
ah right, that's what I meant: is there any way to respond to every osc message that comes in?
from osc-js.
@Audiow no, thats not implemented yet since it wouldnt' follow the OSC standard (at least how I understand it), but one could think of an extension.
from osc-js.
👍 for this enhancement.
Not only would it help for troubleshooting/logging (like the requester's simple example), but also for those of us who need to do dynamic routing.
My specific use case: I have multiple, dynamic clients connecting to my server. Each of those clients may register an OSC namespace prefix (address prefix) for which it wants to receive messages. Within every namespace are potentially hundreds of methods (param1, param2, ..., paramN). So the overall address space looks like:
/ns1/param1
/ns1/param2
...
/ns1/paramN
/ns2/param1
/ns2/param2
...
If every single possible method (fully qualified address) has to have an .on()
set up, it becomes a nightmare to manage! I'd much rather do something like:
osc.on('/ns1/*', message => {
// look up the namespace prefix for this address
var ns = extractNs(message);
// dispatch message to all clients subscribed to this namespace
clients[ns].forEach(client => client.send(message));
});
from osc-js.
The OSC 1.0 spec also says:
An OSC Server's OSC Address Space can be dynamic; that is, its contents and shape can change over time.
To me, anyway, that implies that servers may have a general need to pattern match.
from osc-js.
@derwaldgeist sure, I understand. You are welcome to contribute if you feel like making a PR
from osc-js.
Related Issues (20)
- Difficult to have WSServer and Express on the same port HOT 2
- Accept full URL in osc.open() HOT 1
- Uncaught ReferenceError: OSC is not defined HOT 1
- ModuleNotFoundError: Module not found: Error: Can't resolve 'dgram' in [...] HOT 8
- Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.
- Connecting to another device on the network fails with host: localhost. need 0.0.0.0
- Browser(http) osc message to Reaper(udp) HOT 4
- Use TypeScript HOT 4
- Implement booleans HOT 5
- Integer bundle timetags ignored HOT 3
- Use another documentation generator
- Export `Message` class (and possibly other classes)
- ERR_SOCKET_DGRAM_NOT_RUNNING HOT 1
- Can we avoid using websocket and use the library in the browser? HOT 2
- From maxmsp to browser HOT 1
- TypeScript compile error because of incompatible override of Atomic.unpack by its subclasses HOT 2
- Event listener on server on client connect
- Trouble sending osc message to UDP client in LAN network HOT 1
- Handling errors in unpack in Node.js HOT 2
- Nested bundles cannot be processed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from osc-js.