Created
January 7, 2018 14:26
-
-
Save QiMata/0cfaae5234adde9b173ccea2f65a9543 to your computer and use it in GitHub Desktop.
Function for receiving cloud to device messages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static async void ReceiveC2dAsync() | |
{ | |
Console.WriteLine("\nReceiving cloud to device messages from service"); | |
while (true) | |
{ | |
Message receivedMessage = await deviceClient.ReceiveAsync(); | |
if (receivedMessage == null) continue; | |
Console.ForegroundColor = ConsoleColor.Yellow; | |
Console.WriteLine("Received message: {0}", Encoding.ASCII.GetString(receivedMessage.GetBytes())); | |
Console.ResetColor(); | |
await deviceClient.CompleteAsync(receivedMessage); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment