public bool Matches(BindingKey routingKey) { if (BindingKey.IsEmpty) { return(true); } if (routingKey.IsJoined && BindingKey.PartCount != 1) { return(MatchesJoinedRoutingKey(routingKey.GetPart(0))); } for (var i = 0; i < routingKey.PartCount; i++) { var evaluatedPart = BindingKey.GetPart(i); if (evaluatedPart == "#") { return(true); } if (evaluatedPart != "*" && routingKey.GetPart(i) != evaluatedPart) { return(false); } } return(routingKey.PartCount == BindingKey.PartCount); }
public int Update(Peer peer, BindingKey subscription, UpdateAction action) { if (IsLeaf(subscription)) { var update = UpdateList(peer, action); _peerCountIncludingChildren += update; return(update); } var nextPart = subscription.GetPart(_nextPartIndex); if (subscription.IsSharp(_nextPartIndex) || nextPart == null) { return(UpdateChildNode(GetOrCreateSharpNode(), peer, subscription, action, null, _removeSharpNode)); } if (subscription.IsStar(_nextPartIndex)) { return(UpdateChildNode(GetOrCreateStarNode(), peer, subscription, action, null, _removeStarNode)); } var childNode = GetOrAddChildNode(nextPart); return(UpdateChildNode(childNode, peer, subscription, action, nextPart, _removeNode)); }
public void Accept(PeerCollector peerCollector, BindingKey routingKey) { if (IsLeaf(routingKey) || _matchesAll) { peerCollector.Offer(_peers); return; } _sharpNode?.Accept(peerCollector, routingKey); _starNode?.Accept(peerCollector, routingKey); var nextPart = routingKey.GetPart(_nextPartIndex); if (nextPart == null) { return; } if (_childrenNodes == null) { return; } SubscriptionNode childNode; if (_childrenNodes.TryGetValue(nextPart, out childNode)) { childNode.Accept(peerCollector, routingKey); } }
public void Accept(PeerCollector peerCollector, BindingKey routingKey) { if (IsLeaf(routingKey)) { peerCollector.Offer(_peers); return; } _sharpNode?.AddAllPeers(peerCollector); _starNode?.Accept(peerCollector, routingKey); var nextPart = routingKey.GetPart(_nextPartIndex); if (nextPart == null || _childNodes == null) { return; } if (_childNodes.TryGetValue(nextPart, out var childNode)) { childNode.Accept(peerCollector, routingKey); } }
public int Update(Peer peer, BindingKey subscription, UpdateAction action) { if (IsLeaf(subscription)) { var update = UpdateList(peer, action); _peerCountIncludingChildren += update; return update; } var nextPart = subscription.GetPart(_nextPartIndex); if (nextPart == "#" || nextPart == null) { var sharpNode = GetOrCreateSharpNode(); return UpdateChildNode(sharpNode, peer, subscription, action, null, _removeSharpNode); } if (nextPart == "*") { var starNode = GetOrCreateStarNode(); return UpdateChildNode(starNode, peer, subscription, action, null, _removeStarNode); } var childNode = GetOrAddChildNode(nextPart); return UpdateChildNode(childNode, peer, subscription, action, nextPart, _removeNode); }
public void Accept(PeerCollector peerCollector, BindingKey routingKey) { if (IsLeaf(routingKey) || _matchesAll) { peerCollector.Offer(_peers); return; } if (_sharpNode != null) _sharpNode.Accept(peerCollector, routingKey); if (_starNode != null) _starNode.Accept(peerCollector, routingKey); var nextPart = routingKey.GetPart(_nextPartIndex); if (nextPart == null) return; if (_childrenNodes == null) return; SubscriptionNode childNode; if (_childrenNodes.TryGetValue(nextPart, out childNode)) childNode.Accept(peerCollector, routingKey); }