예제 #1
0
        public void MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
        {
            var splitTopic = e.Topic.Split(new char[] { '/' });

            if (splitTopic.Length < 4)
            {
                return;
            }

            var json = JObject.Parse(System.Text.Encoding.UTF8.GetString(e.Message));

            if (splitTopic[2] == WeightConfig.Key[0])
            {
                json = (JObject)(json[WeightConfig.Key[0]] as JArray)[0];
            }
            else if (splitTopic[2] == ActivitySummaryConfig.Root)
            {
                json = (JObject)json[ActivitySummaryConfig.RootMQTT];
            }

            json.Remove("date");
            APIUtils.Post(MQTTConfig.ControllerUrl + splitTopic[2].Replace("-", "") + "?" +
                          QueryParamsConfig.PatientId + "=" + splitTopic[3] + "&" + QueryParamsConfig.DoctorEmail +
                          "=" + splitTopic[1], json.ToString());
        }