Exemplo n.º 1
0
        private static void MQTT_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            switch (e.Topic)
            {
            case "FDAManager/command":
                //MessageBox.Show("Received command: " + Encoding.UTF8.GetString(e.Message));
                string[] command = Encoding.UTF8.GetString(e.Message).Split(' ');
                if (command.Length < 2)
                {
                    return;
                }
                switch (command[0])
                {
                case "START": HandleStartCommand(command[1], false); break;

                case "STARTCONSOLE": HandleStartCommand(command[1], true); break;
                }
                break;

            // not through MQTT anymore
            //case "FDA/runstatus":
            //    if (e.Message.Length > 0)
            //        UpdateFDAStatusIcon(Encoding.UTF8.GetString(e.Message));
            //    break;
            case "FDA/identifier":
                _FDAName = Encoding.UTF8.GetString(e.Message);
                break;
            }
        }
Exemplo n.º 2
0
        private void Client_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            string message = System.Text.Encoding.UTF8.GetString(e.Message).ToUpperInvariant();

            Debug.WriteLine($"Command Received: {message}");

            switch (message)
            {
            case "RED":
                hat.D2.Color = new FEZHAT.Color(255, 0, 0);
                break;

            case "GREEN":
                hat.D2.Color = new FEZHAT.Color(0, 255, 0);
                break;

            case "BLUE":
                hat.D2.Color = new FEZHAT.Color(0, 0, 255);
                break;

            case "OFF":
                hat.D2.TurnOff();
                break;

            default:
                System.Diagnostics.Debug.WriteLine("Unrecognized command: {0}", message);
                break;
            }
        }
Exemplo n.º 3
0
        private void MqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            var message = Encoding.UTF8.GetString(e.Message);

            if (e.Topic == "/smarthome/news")
            {
                if (message == "off")
                {
                    NavBack();
                }
                else
                {
                    ShowNewsPage();
                }
            }
            else if (e.Topic == "/smarthome/calendar")
            {
                if (message == "off")
                {
                    NavBack();
                }
                else
                {
                    ShowSchedulePage();
                }
            }
            else
            {
                UpdateMessage(message, e.Topic);
            }
        }
Exemplo n.º 4
0
        private void _mqtt_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            var msg = JsonConvert.DeserializeObject <Message>(Encoding.UTF8.GetString(e.Message));

            if (msg.UserId != Setting.GetValue <int>("userid"))
            {
                var data = new Message()
                {
                    DataType  = msg.DataType,
                    UserId    = Setting.GetValue <int>("userid"),
                    StartTime = msg.StartTime,
                    EndTime   = msg.EndTime
                };
                if (msg.DataType == 0) //当前数据
                {
                    data.Body = new List <DataModel>()
                    {
                        new DataModel(Data)
                    };
                }
                else if (msg.DataType == 2) //历史数据
                {
                    data.Body = _db.Table <DataModel>().Where(p => DateTime.Compare(msg.StartTime, p.Time) < 0 && DateTime.Compare(msg.EndTime, p.Time) > 0).ToList();
                }
                _mqtt.PostData(JsonConvert.SerializeObject(data));
            }
        }
Exemplo n.º 5
0
        private void _mqtt_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            if (e.Topic == "FDA/DefaultCommsStatsTable")
            {
                UpdateTableLabel(Encoding.UTF8.GetString(e.Message));
                return;
            }

            string[] topic = e.Topic.Split('/');

            if (topic.Length < 2)
            {
                return;
            }

            if (topic[0] != "DBQUERYRESULT" || topic[1] != _queryID)
            {
                return;
            }

            // unsubscribe from results for this query
            _mqtt.Unsubscribe(new string[] { "DBQUERYRESULT/" + topic[1] });

            HandleResult(e.Message);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 收到消息事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            var message = new MqttMessage
            {
                Topic   = e.Topic,
                Payload = e.Message,
                Qos     = (MqttQosLevel)e.QosLevel,
                Retain  = e.Retain
            };

            Task.Factory.StartNew(() =>
            {
                MessageReceived?.Invoke(this, message);
            });

            Task.Factory.StartNew(() =>
            {
                //消息处理器
                var messageHandlers = serviceProvider.GetServices <IMqttMessageHandler>();

                var handlers = messageHandlers?.Where(x => x.Topic.Any(t => t.Equals(e.Topic)));

                if (handlers != null)
                {
                    foreach (var handler in handlers)
                    {
                        handler?.Execute(message).GetAwaiter().GetResult();
                    }
                }
            });
        }
Exemplo n.º 7
0
        private void Client_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            try
            {
                switch (e.Topic)
                {
                case MqttTopic.RegisterTopic:
                    SmartLockRegister smartLock = new SmartLockRegister(e.Message);
                    byte[]            resArray  = smartLock.PackageResponse();
                    MqttClient        client    = (MqttClient)sender;
                    string            resTopic  = MqttTopic.GetClientTopic("SYS", smartLock.SmartLockClient.IotID, "REG");
                    client.Publish(resTopic, resArray);
                    break;

                case MqttTopic.EventTopic:
                    SmartLockDataPackage dataPackage = new SmartLockDataPackage(e.Message);
                    break;

                case MqttTopic.RespondTopic:
                    break;

                case MqttTopic.DataTopic:
                    break;
                }
            }
            catch (Exception ex)
            {
                MqttErroEventArgs eventArgs = new MqttErroEventArgs((sender as MqttClient).ClientId, ex.Message);
                RaiseMqttErroOccurred(eventArgs);
            }
        }
Exemplo n.º 8
0
        private void Mqttclient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            try
            {
                var methodPayload = Encoding.UTF8.GetString(e.Message);
                Debug.WriteLine("Message from cloud to device: " + methodPayload);
                var methodCallTopic = "$iothub/methods/POST/";
                if (e.Topic.StartsWith(methodCallTopic))                 // direct method call
                {
                    var methodCallSubstring = e.Topic.Substring(methodCallTopic.Length);
                    var methodName          = methodCallSubstring.Split('/')[0];
                    var requestId           = methodCallSubstring.Split('/')[1].Substring(6);

                    Debug.WriteLine($"Method: [{methodName}], Request: [{requestId}]");

                    var    method       = _methodRegistrations[methodName];
                    var    methodResult = method.Invoke(methodPayload);
                    string responseBody = JsonConvert.SerializeObject(methodResult.Value);
                    // respond to server
                    _mqttclient.Publish($"$iothub/methods/res/{methodResult.Key}/?$rid={requestId}", Encoding.UTF8.GetBytes(responseBody));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Exemplo n.º 9
0
        private void MQTT_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            string[] topic = e.Topic.Split('/');
            if (topic[0] != "DBQUERY")
            {
                return;
            }

            // topic must include the elements "DBQUERY" and the query ID
            if (topic.Length < 2)
            {
                return;
            }

            string query = Encoding.UTF8.GetString(e.Message);

            BackgroundWorker worker = new BackgroundWorker();

            switch (_DBManagerType)
            {
            case "DBManagerPG": worker.DoWork += Worker_DoWorkPG; break;

            case "DBManagerSQL": worker.DoWork += Worker_DoWorkSQL; break;
            }
            worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
            lock (currentWorkers) { currentWorkers.Add(worker); }
            worker.RunWorkerAsync(new QueryParameters(topic[1], query));
        }
Exemplo n.º 10
0
 private void MqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
 {
     Dispatcher.CurrentDispatcher.Invoke(() =>
     {
         WriteToConsole(ASCIIEncoding.UTF8.GetString(e.Message));
     });
 }
Exemplo n.º 11
0
        private void Client_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            string message = System.Text.Encoding.UTF8.GetString(e.Message).ToUpperInvariant();

            Debug.WriteLine($"Command Received: {message}");

            // Add Azure IoT Hub MQTT Command and Control support here
        }
Exemplo n.º 12
0
 private void MqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
 {
     // This callback is on a different thread
     dataGridView1.Invoke(new Action(() =>
     {
         System.Diagnostics.Debug.WriteLine("Got msg: " + e.Topic + " " + e.Message.ToString());
         MQTTMessage msg           = new MQTTMessage(e.Topic, Encoding.ASCII.GetString(e.Message));
         int index                 = mqttMessages.Add(msg);
         dataGridView1.CurrentCell = dataGridView1.Rows[index].Cells[0];
     }));
 }
Exemplo n.º 13
0
 private void MqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
 {
     // Debug.Log(Encoding.UTF8.GetString(e.Message));
     if (e.Topic.Equals(this.clientId))
     {
         OnReceiveMsg?.Invoke(this, Encoding.UTF8.GetString(e.Message));
     }
     else
     {
         //Debug.Log(e.Topic + "  "+Encoding.UTF8.GetString(e.Message));
         OnReceiveByteMsg?.Invoke(this, e.Message);
     }
 }
Exemplo n.º 14
0
        static void mqc_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            string msg = new string(Encoding.UTF8.GetChars(e.Message));

            // here we take data [2] (Light) and [3] (poti)
            lastXivelyData2 = (msg.Split('\n')[2].Split(',')[2]); // in this case take 2nd datapoint and get value
            lastXivelyData3 = (msg.Split('\n')[3].Split(',')[2]); // in this case take 3rd datapoint and get value
            Debug.Print("xive light: " + lastXivelyData2);
            Debug.Print("xive thresh: " + lastXivelyData3);
            // since this repeatedly hangs try it on a new thread ....
            var t = new Thread(ActionForXivelyData);

            t.Start();
        }
Exemplo n.º 15
0
        /**
         * \fn SampleMqttClient_MqttMsgPublishReceived
         * \brief callback associated to the subsciption event
         */
        private void SampleMqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            object decoded_message = ElaWirepasLibrary.Model.Wirepas.Payload.WirepasPayloadFactory.GetInstance().Get(e.Message);

            //
            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
            {
                if (null != decoded_message)
                {
                    var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(decoded_message);
                    this.listConsole.Items.Add($"Data Received : {jsonString}");
                }
            }));
        }
Exemplo n.º 16
0
        private void Mqtt_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            string[] topic = e.Topic.Split('/');

            if (topic[0] == "DBQUERY")
            {
                DoQuery(e.Message, topic[1]);
            }

            if (topic[0] == "DBQUERYRESULT")
            {
                HandleResult(e.Message);
            }
        }
Exemplo n.º 17
0
 private static void Client_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
 {
     foreach (Topic topic in Topics)
     {
         if (topic.Expresion.IsMatch(e.Topic))
         {
             for (int i = 0; i < topic.Callbacks.Count; i++)
             {
                 Action <string, string, Topic> callback = topic.Callbacks[i];
                 callback(System.Text.Encoding.UTF8.GetString(e.Message), e.Topic, topic);
             }
         }
     }
 }
Exemplo n.º 18
0
        private static void _mqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            try
            {
                //Find matching topic in subscription list and get the write tag
                int hitem = _MXAccessSettings.subscribetags.Find(x => x.topic.ToLower().Equals(e.Topic)).hitem;

                //Now find the tag in the dictionary to get the correct hitem
                _LMX_Server.Write(_hLMX, hitem, System.Text.ASCIIEncoding.UTF8.GetString(e.Message), 0);
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Exemplo n.º 19
0
        private void Q_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            lock (_weightlock)
            {
                _resetTimer?.Stop();
                if (_hasFinalWeight)
                {
                    return;
                }

                var messageString = Encoding.Default.GetString(e.Message);
                if (string.IsNullOrWhiteSpace(messageString))
                {
                    return;
                }

                var message = JsonConvert.DeserializeObject <ScaleMessage>(messageString);

                _onWeightReceived(message.Weight);

                if (IsTheSameWithTolerance(message.Weight, _lastWeight))
                {
                    if (_weightTimer == null)
                    {
                        _weightTimer = new Stopwatch();
                        _weightTimer.Start();
                    }
                }
                else
                {
                    _weightTimer = null;
                }

                _lastWeight = message.Weight;
                _weightsReceived.Add(message.Weight);

                if (HasFinalWeight())
                {
                    _onFinalWeightReceived(message.Weight);
                }
                else
                {
                    _resetTimer = CreateTimer();
                    _resetTimer.Start();
                }
            }
        }
Exemplo n.º 20
0
        // Handle incoming messages
        private static void client_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            string publishReceived = Encoding.UTF8.GetString(e.Message);

            Console.WriteLine("Message received: " + publishReceived);

            switch (publishReceived)
            {
            case PAYLOAD_move12:
            case "Pallet to Tester":
                action_movAtoB();
                while (true)
                {
                    if (actionFinished == true)
                    {
                        publishOK      = client.Publish(TOPIC_result, Encoding.UTF8.GetBytes(PAYLOAD_respOK));
                        actionFinished = false;
                        Console.WriteLine("publish OK and set actionFinished to false");
                        break;
                    }
                    //else if (actionFinished == false)
                    //Console.WriteLine("Waiting for Flag changed");
                }
                break;

            case PAYLOAD_move21:
            case "Tester to Pallet":
                action_movBtoA();
                while (true)
                {
                    if (actionFinished == true)
                    {
                        publishOK      = client.Publish(TOPIC_result, Encoding.UTF8.GetBytes(PAYLOAD_respOK));
                        actionFinished = false;
                        Console.WriteLine("publish OK and set actionFinished to false");
                        break;
                    }
                    //else if (actionFinished == false)
                    //Console.WriteLine("Waiting for Flag changed");
                }
                break;

            default:
                //Console.WriteLine("publishReceived has no event");
                break;
            }
        }
Exemplo n.º 21
0
        private static void _mqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            try
            {
                //sw.Restart();

                SendDataToHistorian(e);

                //sw.Stop();

                //log.Info(sw.ElapsedTicks.ToString());
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Exemplo n.º 22
0
        private void MyMQTTClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            string clientIdSender = "";
            var    Data           = new string(Encoding.UTF8.GetChars(e.Message));

            if (Data.Contains(ClientIdOnDataSeparator.ToString()))
            {
                string[] arrData = Data.Split(ClientIdOnDataSeparator);
                clientIdSender = arrData[0];
                Data           = arrData[1];
            }

            if (OnMqttMsgPublishReceived != null)
            {
                OnMqttMsgPublishReceived(clientIdSender, Data, e.Topic, e.QosLevel, e.Retain);
            }
        }
Exemplo n.º 23
0
        private void MqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            if (this.rtbSubscribe.InvokeRequired)
            {
                rtbSubscribe.Invoke(new MethodInvoker(() =>
                {
                    rtbSubscribe.Text = ASCIIEncoding.UTF8.GetString(e.Message) + Environment.NewLine + rtbSubscribe.Text;
                }));
            }

            //if (this.InvokeRequired)
            //{
            //    this.Invoke(UpdateSubscribedContent, rtbSubscribe, ASCIIEncoding.UTF8.GetString(e.Message));
            //}
            //else
            //{
            //    UpdateSubscribedContent(rtbSubscribe, ASCIIEncoding.UTF8.GetString(e.Message));
            //}
        }
Exemplo n.º 24
0
        private void _mqtt_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            string[] topic = e.Topic.Split('/');
            if (topic.Length < 2)
            {
                return;
            }

            if (topic[0] != "DBQUERYRESULT")
            {
                return;
            }
            if (topic[1] == _queryID)
            {
                // unsubscribe from results for this query
                _mqtt.Unsubscribe(new string[] { "DBQUERYRESULT/" + topic[1] });
                HandleResult(e.Message);
            }
        }
Exemplo n.º 25
0
        // Handle incoming messages
        private static void client_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            string publishReceived = Encoding.UTF8.GetString(e.Message);

            Console.WriteLine("Message received: " + publishReceived);

            switch (publishReceived)
            {
            case PAYLOAD_move12:
                action_movAtoB();
                break;

            case PAYLOAD_move21:
                action_movBtoA();
                break;

            default:
                //Console.WriteLine("publishReceived has no event");
                break;
            }
        }
Exemplo n.º 26
0
        private void MqttClient_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            try
            {
                string  topic     = e.Topic;
                string  msgString = System.Text.Encoding.UTF8.GetString(e.Message);
                JObject msg       = JObject.Parse(msgString);

                Log(topic);
                Log(msgString);

                foreach (var col in config.activeNodes)
                {
                    if (col is JsonNode)
                    {
                        JsonNode n     = (JsonNode)col;
                        JToken   value = msg.SelectToken(n.parentPath + "." + n.name);

                        db.SetParameter(col.dbColumn, value);
                    }
                    else if (col is TopicNode)
                    {
                        Regex  re    = new Regex(((TopicNode)col).regEx);
                        Match  m     = re.Match(topic);
                        string match = "";
                        if (m.Success && m.Groups.Count > 1)
                        {
                            match = m.Groups[1].Value;
                        }
                        db.SetParameter(col.dbColumn, match);
                    }
                }
                db.WriteRecord();
                Log(db.LastCommand);
            }
            catch (Exception ex)
            {
                Log("Failed processing mqtt message: " + ex.ToString());
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// 구독한 Topic의 메시지가 수신되었을 때 수신 메시지 Property에 저장
        /// </summary>
        /// <param name="sender">Event Sender</param>
        /// <param name="e">Event Argument</param>
        private void Client_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            try
            {
                string pubTopic    = e.Topic;
                string pubMsg      = Encoding.Default.GetString(e.Message);
                int    pubQosLevel = Convert.ToInt32(e.QosLevel);
                bool   isRetain    = e.Retain;
                bool   isDup       = e.DupFlag;

                if (subMessage.Keys.Contains(pubTopic))
                {
                    subMessage[pubTopic] = pubMsg;
                }
                else
                {
                    subMessage.Add(pubTopic, pubMsg);
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 28
0
        private void client_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            // handle message received
            this.textBox1.Invoke((Action)(() =>
            {
                textBox1.Text = string.Empty;
                textBox1.Text += string.Format("[{0}][{1}]", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss fff"), e.Topic);
                string msg = Encoding.UTF8.GetString(e.Message);
                textBox1.Text += msg;
                textBox1.Text += "\r\n";

                // raw
                textBox1.Text += string.Format("[{0}]\r\n", BitConverter.ToString(e.rcvbuf));

                {
                    try
                    {
                        // 送受信に利用するIPアドレス、ポート番号
                        int port = Int32.Parse(textBox_UDPPort.Text);
                        System.Net.IPAddress ipaddress = System.Net.IPAddress.Parse(textBox_UDPIP.Text);
                        this.udpdst_ = new System.Net.IPEndPoint(ipaddress, port);

                        // 送信データ
                        byte[] buffer = e.rcvbuf;
                        // UDP送信
                        udp_send_aync(buffer);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("udp port/ipaddress error({0})", ex.Message);
                    }
                }

                // アプリ
                user_app_.MqttMsgPublishReceived(sender, e);
            }));
        }
Exemplo n.º 29
0
        private void _messageHandler_MqttMsgPublishReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            var message = Encoding.Default.GetString(e.Message);

            if (e.Topic == Topics.ScoreUpdate)
            {
                GetGamerFromMessage(message, out GamerMinimal gamerMinimal, out Gamer stored, out Game game);
                if (game == null)
                {
                    return;
                }
                _gamerStorage.UpdateGameScore(game.Id, gamerMinimal.Score);
                game.Score    = gamerMinimal.Score;
                game.Tries    = gamerMinimal.Tries;
                game.MaxTries = gamerMinimal.MaxTries;
                if (gamerMinimal.MaxTries <= gamerMinimal.Tries)
                {
                    _gamerStorage.CompleteGame(game);
                    game.State = GameState.Completed;
                }
                SetCurrentGame(game);
                SyncClientGames();
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Callback for when a message comes in.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RawMsgReceived(object sender, uPLibrary.Networking.M2Mqtt.Messages.MqttMsgPublishEventArgs e)
        {
            // A new message has come it.  Put it in our list.
            string payload = System.Text.Encoding.ASCII.GetString(e.Message);

            // Find the saved message, if any.
            MqttMessage OldMsg = null;
            int         iseq   = 0;

            lock (m_DictLock)
            {
                if (m_SavedMessages.ContainsKey(e.Topic))
                {
                    OldMsg = m_SavedMessages[e.Topic];
                    iseq   = OldMsg.Sequence;
                }
            }
            iseq++;
            MqttMessage m = new MqttMessage(e.Topic, payload, iseq);

            lock (m_DictLock)
            {
                m_SavedMessages[e.Topic] = m;
            }
            if (e.Topic == "robot/jetson/ping")
            {
                double ElapsedSecs = StopWatch.Stop(m_PingStartTime);
                Console.Write(String.Format("\nPing = {0:000.00000}\n\n", ElapsedSecs * 1000.0));
            }

            lock (m_LockInputList)
            {
                m_InputMessages.Add(m);
            }
            TriggerNewMessage();
        }