예제 #1
0
        private void InitPassMessagesToSubscribers()
        {
            Receive <MqttMessageEvent>(mqttEvent =>
            {
                var i = 0;
                //todo resolve double match topic checking inside actor and here
                foreach (var sub in _subs
                         .Where(x => x.Type == TriggerTypeEnum.Mqtt &&
                                x is SubToMqtt mx &&
                                MqttHelper.IsSubscribed(patternTopic: mx.Topic, actualTopic: mqttEvent.Topic) &&
                                !x.Subscriber.IsNobody()))
                {
                    i++;
                    sub.Subscriber.Tell(mqttEvent);
                }

                _logger.Debug($"{nameof(MqttMessageEvent)} delivered to {i} actors");
            });
            Receive <ActionResultEvent>(actionEvent =>
            {
                var i = 0;
                //todo resolve double match action checking inside actor and here
                foreach (var sub in _subs
                         .Where(x => x.Type == TriggerTypeEnum.Action &&
                                x is SubToAction ma &&
                                actionEvent.ActionName.Equals(ma.ActionName, StringComparison.InvariantCultureIgnoreCase)))
                {
                    i++;
                    sub.Subscriber.Tell(actionEvent);
                }

                _logger.Debug($"{nameof(ActionResultEvent)} delivered to {i} actors");
            });
        }
예제 #2
0
 public void IsSubscribedTests(string patternTopic, string topic, bool expected)
 {
     Assert.Equal(expected, MqttHelper.IsSubscribed(patternTopic, topic));
 }