Exemplo n.º 1
0
        private async void Room_OnDeviceMoved(object sender, DeviceMoveEventArgs e)
        {
            //Send the event to IoTHub
            if (null != deviceClient)
            {
                try
                {
                    GeofenceEvent geoEvent = new Models.GeofenceEvent()
                    {
                        geofence_event = e.Event,
                        geofence_id    = e.geofence_id,
                        geofence_name  = e.RoomName,
                        hashed_sta_mac = e.DeviceId,
                        dwell_time     = e.dwell_time
                    };
                    Message message = new Message(Encoding.UTF8.GetBytes(await JsonConvert.SerializeObjectAsync(geoEvent)));
                    await deviceClient.SendEventAsync(message);

                    Console.WriteLine($"Wow, I've already sent {++numberMessages} messages during this session ");
                }
                catch (Exception exception)
                {
                    Console.WriteLine("Something unforeseen happend and I can't continue. See details below:");
                    Console.WriteLine(exception.Message);
                    Console.Write(exception.StackTrace);
                }
            }
        }
Exemplo n.º 2
0
        void OnDeviceMove(DeviceMoveEventArgs args)
        {
            //Create the message and send it

            //await deviceClient.SendEventAsync(message);
        }