public async Task SendReadings(SensorReadings readings) { if (sendToAzure) { await azureServiceBus.Send(readings); } }
public async Task Send(SensorReadings readings) { try { var message = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(readings)); var eventData = new EventData(message); // Write the body of the message to the console Console.WriteLine($"Sending message: {Encoding.UTF8.GetString(message)}"); await eventHubClient.SendAsync(eventData); } catch (Exception exception) { Console.WriteLine($"{DateTime.Now} > Exception: {exception.Message}"); } }