OSC source target by ID with # prefix

Targetting source by id should be with '#' + the number (e.g. /vimix/#2/alpha). For backward compatibility the '#' is still optional.
This commit is contained in:
Bruno Herbelin
2023-03-18 10:30:40 +01:00
parent c255b0249f
commit 9a98fb399c
2 changed files with 3 additions and 3 deletions

View File

@@ -191,7 +191,7 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m,
else if ( std::regex_match(target, osc_sourceid_reg_exp) ) else if ( std::regex_match(target, osc_sourceid_reg_exp) )
{ {
int i = 0; int i = 0;
std::string num = target.substr(1); std::string num = target.substr( target.find("#") == std::string::npos ? 1 : 2 );
if ( BaseToolkit::is_a_number(num, &i)){ if ( BaseToolkit::is_a_number(num, &i)){
Source *s = Mixer::manager().sourceAtIndex(i); Source *s = Mixer::manager().sourceAtIndex(i);
if (s) { if (s) {
@@ -201,7 +201,7 @@ void Control::RequestListener::ProcessMessage( const osc::ReceivedMessage& m,
Control::manager().sendSourceAttibutes(remoteEndpoint, target, s); Control::manager().sendSourceAttibutes(remoteEndpoint, target, s);
} }
else else
Log::Info(CONTROL_OSC_MSG "Unknown target '%s' requested by %s.", target.c_str(), sender); Log::Info(CONTROL_OSC_MSG "No source at ID %s targetted by %s.", num.c_str(), sender);
} }
} }
// General case: try to identify the target by name // General case: try to identify the target by name

View File

@@ -27,7 +27,7 @@
#define OSC_ALL "/all" #define OSC_ALL "/all"
#define OSC_SELECTION "/selection" #define OSC_SELECTION "/selection"
#define OSC_SOURCEID "(\\/)[[:digit:]]+$" #define OSC_SOURCEID "(\\/#?)[[:digit:]]+$"
#define OSC_BATCH "(\\/batch#)[[:digit:]]+$" #define OSC_BATCH "(\\/batch#)[[:digit:]]+$"
#define OSC_CURRENT "/current" #define OSC_CURRENT "/current"
#define OSC_NEXT "/next" #define OSC_NEXT "/next"