Example #1
0
        /// <summary>
        /// Just tick data every second
        /// </summary>
        public static void Sensor()
        {
            while (true)
            {
                //Send data if lower than or equal to the threshold set from the client
                var r = new Random().Next(50);
                if (r <= threshold)
                {
                    _client.Publish("change", r, "sensor");
                }

                Thread.Sleep(1000);
            }
        }
Example #2
0
 /// <summary>
 /// Send a message to XSockets if the button is pressed
 /// </summary>
 /// <param name="data1"></param>
 /// <param name="data2"></param>
 /// <param name="time"></param>
 static void button_OnInterrupt(uint data1, uint data2, DateTime time)
 {
     _conn.Publish("chatmessage", new ChatMessage {
         Text = "Hello from Netduino"
     }, "iot");
 }