コード例 #1
0
 private static void LoopPublish()
 {
     while (true)
     {
         SensorInfo value = SensorFaker.Generate();
         CurrValue = JsonConvert.SerializeObject(value, Formatting.Indented);
         BrokerClient.Publish("home/device/data", Encoding.Default.GetBytes(CurrValue));
         Console.WriteLine($"Published: {CurrValue}");
         Thread.Sleep(1000);
     }
 }
コード例 #2
0
        private void LoopPublish()
        {
            while (true)
            {
                SensorInfo value = SensorFaker.Generate();
                CurrValue = JsonConvert.SerializeObject(value, Formatting.Indented);
                BrokerClient.Publish("home/device/data", Encoding.Default.GetBytes(CurrValue));
                this.Invoke(new Action(() =>
                {
                    RtbLog.AppendText($"Published: {CurrValue}\n");
                    RtbLog.ScrollToCaret();
                }));

                Thread.Sleep(1000);
            }
        }
コード例 #3
0
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            while (true)
            {
                SensorInfo ThisValue = SensorFaker.Generate();
                CurrValue = JsonConvert.SerializeObject(ThisValue, Formatting.Indented);

                BrokerClient.Publish("home/device/data/", Encoding.Default.GetBytes(CurrValue));
                //Console.WriteLine($"Published : {CurrValue}");
                string publishtext = $"Published : {CurrValue}\n\n";
                RTBLog.AppendText(publishtext);
                RTBLog.ScrollToCaret();

                Thread.Sleep(1000);
            }
        }