Beispiel #1
0
        private void MqttMsgReceived(MqttMsgPublishEventArgs e)
        {
            var message = new MqttMessage { Message = Encoding.UTF8.GetString(e.Message), Topic = e.Topic };

            List<Action<MqttMessage>> actions = new List<Action<MqttMessage>>();

            lock (_handlers)
            {
                foreach (var handler in _handlers)
                {
                    if (_topicMatcher.TopicsMatch(message, handler.Topic, e.Topic))
                        actions.Add(handler.Action);
                }
            }

            foreach (var action in actions)
                action(message);
        }