internal ICollection <string> CombineSubscriptions(List <string> pTopics, out bool WasUpdated, bool AreOwnedSubs = false) { WasUpdated = false; if (pTopics == null) //pTopics = new List<string>(); { return(MySubscriptions.TheKeys); //4.1042: Tuning } lock (CombineSubscriptionLock) { for (int i = 0; i < pTopics.Count; i++) { string tSubTopicRealScope = TheBaseAssets.MyScopeManager.GetRealScopeIDFromTopic(pTopics[i], out string tTopicName); //Medium Frequency if (string.IsNullOrEmpty(tTopicName)) { continue; } if (MyTargetNodeChannel?.HasRScope(tSubTopicRealScope) != true) { TheBaseAssets.MySYSLOG.WriteToLog(296, string.IsNullOrEmpty(tTopicName) || TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM("QueuedSender", $"New Subscription to Topic={pTopics[i]} not allowed due to different Scope", eMsgLevel.l2_Warning)); continue; } if (string.IsNullOrEmpty(tSubTopicRealScope) && !TheBaseAssets.MyServiceHostInfo.AllowUnscopedMesh) { if (TheBaseAssets.MyScopeManager.IsScopingEnabled && !string.IsNullOrEmpty(MyTargetNodeChannel.RealScopeID) && !TheCommonUtils.IsDeviceSenderType(MyTargetNodeChannel.SenderType)) //RScope-OK //IDST-??: check of unscoped telegrams - might need to go to unscoped devices? { TheBaseAssets.MySYSLOG.WriteToLog(296, string.IsNullOrEmpty(tTopicName) || TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM("QueuedSender", $"New Subscription to UNSCOPED Topic={pTopics[i]} not allowed as current node is Scoped!", eMsgLevel.l2_Warning)); continue; } //Coming later for more security: No more Unscoped subscriptions except the plugin service has "IsAllowedUnscopedProcessing" enabled //if (!TheBaseAssets.MyScopeManager.IsScopingEnabled && string.IsNullOrEmpty(tChannelRealScope) && pTopics[i] != eEngineName.ContentService && pTopics[i] != eEngineName.NMIService) //{ // TheBaseAssets.MySYSLOG.WriteToLog(296, string.IsNullOrEmpty(tTopicName) || TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM("QueuedSender", $"New Subscription to UNSCOPED Topic={pTopics[i]} not allowed on unscoped Node!", eMsgLevel.l2_Warning)); // continue; //} } bool WasFound = false; foreach (string t in MySubscriptions.TheKeys) { if (!string.IsNullOrEmpty(tSubTopicRealScope)) { if (tSubTopicRealScope.Equals(MySubscriptions.MyRecords[t].RScopeID) && tTopicName.Equals(MySubscriptions.MyRecords[t].Topic)) { WasFound = true; break; } } else { if (pTopics[i].Equals(t)) { WasFound = true; break; } } } if (!WasFound) { MySubscriptions.AddOrUpdateItemKey(pTopics[i], new TheSubscriptionInfo() { RScopeID = tSubTopicRealScope, Topic = tTopicName, ToServiceOnly = AreOwnedSubs }, null); WasUpdated = true; } } return(MySubscriptions.TheKeys); } }
internal bool MySubscriptionContainsFragment(string pRealTopic) { return(MySubscriptions.MyRecords.Any(s => s.Value?.Topic?.StartsWith(pRealTopic) == true && MyTargetNodeChannel.HasRScope(s.Value?.RScopeID))); }