publish function
Implementation
int publish(String to,
{dynamic data, String? rpath, bool sticky = false, bool propagate = true}) {
var msg = Message(to: to, resp: rpath, data: data);
var touch = 0;
if (sticky) {
_sticky[msg.to] = msg._cloneSticky();
}
var chunks = msg.to.split('.');
while (chunks.isNotEmpty) {
var topic = chunks.join('.');
if (_subscriptions.containsKey(topic)) {
var subsTopic = _subscriptions[topic];
if (subsTopic != null) {
for (var sub in subsTopic) {
sub._send(msg);
if (!sub.hidden) {
touch++;
}
}
}
}
if (!propagate) break;
chunks.removeLast();
}
return touch;
}