How to use the azure-iot-device.SharedAccessKeyAuthenticationProvider.fromConnectionString function in azure-iot-device

To help you get started, we’ve selected a few azure-iot-device examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-iot-sdk-node / longhaultests / src / d2c_sender.ts View on Github external
constructor(connStr: string, protocol: any, sendInterval: number, sendTimeout: number) {
    super();
    this._sendInterval = sendInterval;
    this._sendTimeout = sendTimeout;
    const authProvider = SharedAccessKeyAuthenticationProvider.fromConnectionString(connStr);
    this._client = Client.fromAuthenticationProvider(authProvider, protocol);
    this._client.on('error', (err) => {
      debug('error emitted by client: ' + err.toString());
      this.stop((stopErr) => {
        debug('error stopping: ' + stopErr.toString());
      });
    });

    this._client.on('disconnect', (err) => {
      this.stop((stopErr) => {
        debug('error stopping: ' + stopErr.toString());
      });
    });
  }