Removing device client promissification

This commit is contained in:
Pericles Alves 2020-02-10 12:22:15 -08:00
Родитель 0085a16f4d
Коммит ab27883d3e
1 изменённых файлов: 3 добавлений и 4 удалений

Просмотреть файл

@ -7,7 +7,6 @@ const crypto = require('crypto');
const request = require('request-promise-native');
const Device = require('azure-iot-device');
const DeviceTransport = require('azure-iot-device-http');
const util = require('util');
const StatusError = require('../error').StatusError;
@ -52,10 +51,10 @@ module.exports = async function (context, device, measurements, timestamp) {
message.properties.add('iothub-creation-time-utc', timestamp);
}
await util.promisify(client.open.bind(client))();
await client.open();
context.log('[HTTP] Sending telemetry for device', device.deviceId);
await util.promisify(client.sendEvent.bind(client))(message);
await util.promisify(client.close.bind(client))();
await client.sendEvent(message);
await client.close();
} catch (e) {
// If the device was deleted, we remove its cached connection string
if (e.name === 'DeviceNotFoundError' && deviceCache[device.deviceId]) {