Skip to content

Instantly share code, notes, and snippets.

@jamesbulpin
Created July 15, 2018 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesbulpin/ed068edb4b09e637c6564a5224614e3d to your computer and use it in GitHub Desktop.
Save jamesbulpin/ed068edb4b09e637c6564a5224614e3d to your computer and use it in GitHub Desktop.
var DeviceClient = require('azure-iot-device').Client
var DeviceProtocol = require('azure-iot-device-amqp').AmqpWs
[...]
var connectionString = "HostName=.....";
[...]
var client = DeviceClient.fromConnectionString(connectionString, DeviceProtocol);
[...]
client.on('message', onMessage);
function onMessage(msg) {
console.log('Id: ' + msg.messageId + ' Body: ' + msg.data);
messageController.exec(JSON.parse(msg.data.toString()));
client.complete(msg, printResultFor('completed'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment