mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #1861 from SPIRIT-21/master
Allows MQTT Shared Subscriptions for MQTT-In core node
This commit is contained in:
commit
3a55528552
@ -24,6 +24,19 @@ module.exports = function(RED) {
|
|||||||
if (ts == "#") {
|
if (ts == "#") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/* The following allows shared subscriptions (as in MQTT v5)
|
||||||
|
http://docs.oasis-open.org/mqtt/mqtt/v5.0/cs02/mqtt-v5.0-cs02.html#_Toc514345522
|
||||||
|
|
||||||
|
4.8.2 describes shares like:
|
||||||
|
$share/{ShareName}/{filter}
|
||||||
|
$share is a literal string that marks the Topic Filter as being a Shared Subscription Topic Filter.
|
||||||
|
{ShareName} is a character string that does not include "/", "+" or "#"
|
||||||
|
{filter} The remainder of the string has the same syntax and semantics as a Topic Filter in a non-shared subscription. Refer to section 4.7.
|
||||||
|
*/
|
||||||
|
else if(ts.startsWith("$share")){
|
||||||
|
ts = ts.replace(/^\$share\/[^#+/]+\/(.*)/g,"$1");
|
||||||
|
|
||||||
|
}
|
||||||
var re = new RegExp("^"+ts.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g,"\\$1").replace(/\+/g,"[^/]+").replace(/\/#$/,"(\/.*)?")+"$");
|
var re = new RegExp("^"+ts.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g,"\\$1").replace(/\+/g,"[^/]+").replace(/\/#$/,"(\/.*)?")+"$");
|
||||||
return re.test(t);
|
return re.test(t);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user