CheckSubscriptionsResult CheckSubscriptions(string topic, MqttQualityOfServiceLevel applicationMessageQoSLevel, string senderClientId)
        {
            ulong topicHashMask; // not needed
            bool  hasWildcard;   // not needed

            MqttSubscription.CalculateTopicHash(topic, out var topicHash, out topicHashMask, out hasWildcard);
            return(_subscriptionsManager.CheckSubscriptions(topic, topicHash, applicationMessageQoSLevel, senderClientId));
        }
Example #2
0
        static void CompareAndAssert(string topic, string filter, MqttTopicFilterCompareResult expectedResult)
        {
            Assert.AreEqual(expectedResult, MqttTopicFilterComparer.Compare(topic, filter));

            ulong topicHash;
            ulong topicHashMask;
            bool  topicHasWildcard;

            MqttSubscription.CalculateTopicHash(topic, out topicHash, out topicHashMask, out topicHasWildcard);


            ulong filterTopicHash;
            ulong filterTopicHashMask;
            bool  filterTopicHasWildcard;

            MqttSubscription.CalculateTopicHash(filter, out filterTopicHash, out filterTopicHashMask, out filterTopicHasWildcard);

            if (expectedResult == MqttTopicFilterCompareResult.IsMatch)
            {
                // If it matches then the hash evaluation should also indicate a match
                Assert.IsTrue((topicHash & filterTopicHashMask) == filterTopicHash, "Incorrect topic hash (is equal)");
            }
        }