コード例 #1
0
        public string subscribe(string uid, string topic_filter, Action <PythonDictionary> callback)
        {
            if (topic_filter == null)
            {
                throw new ArgumentNullException(nameof(topic_filter));
            }
            if (callback == null)
            {
                throw new ArgumentNullException(nameof(callback));
            }

            return(_mqttService.Subscribe(uid, topic_filter, message =>
            {
                var pythonMessage = new PythonDictionary
                {
                    ["client_id"] = message.ClientId,
                    ["topic"] = message.ApplicationMessage.Topic,
                    ["payload"] = message.ApplicationMessage.Payload,
                    ["qos"] = (int)message.ApplicationMessage.QualityOfServiceLevel,
                    ["retain"] = message.ApplicationMessage.Retain
                };

                callback(pythonMessage);
            }));
        }