How to use the azure-iot-mqtt-base.translateError function in azure-iot-mqtt-base

To help you get started, we’ve selected a few azure-iot-mqtt-base 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 / device / transport / mqtt / src / mqtt.ts View on Github external
_onEnter: (disconnectedCallback, err, result) => {
            if (disconnectedCallback) {
              if (err) {
                /*Codes_SRS_NODE_DEVICE_MQTT_16_019: [The `connect` method shall calls its callback with an `Error` that has been translated from the `MqttBase` error using the `translateError` method if it fails to establish a connection.]*/
                disconnectedCallback(translateError(err));
              } else {
                disconnectedCallback(undefined, result);
              }
            } else {
              /* Codes_SRS_NODE_DEVICE_MQTT_18_026: When MqttTransport fires the close event, the Mqtt object shall emit a disconnect event */
              this.emit('disconnect', err);
            }
          },
          /*Codes_SRS_NODE_DEVICE_MQTT_16_021: [The `disconnect` method shall call its callback immediately with a `null` argument and a `results.Disconnected` second argument if `MqttBase` is already disconnected.]*/
github Azure / azure-iot-sdk-node / device / transport / mqtt / src / mqtt.ts View on Github external
this._mqtt.publish(topic, body.toString(), { qos: 0, retain: false }, (err, puback) => {
              if (err) {
                /* Codes_SRS_NODE_DEVICE_MQTT_18_016: [** If an error occurs in the `sendTwinRequest` method, the `done` callback shall be called with the error as the first parameter. **]** */
                /* Codes_SRS_NODE_DEVICE_MQTT_18_024: [** If an error occurs, the `sendTwinRequest` shall use the MQTT `translateError` module to convert the mqtt-specific error to a transport agnostic error before passing it into the `done` callback. **]** */
                callback(translateError(err));
              } else {
                /* Codes_SRS_NODE_DEVICE_MQTT_18_004: [** If a `done` callback is passed as an argument, The `sendTwinRequest` method shall call `done` after the body has been published. **]** */
                /* Codes_SRS_NODE_DEVICE_MQTT_18_017: [** If the `sendTwinRequest` method is successful, the first parameter to the `done` callback shall be null and the second parameter shall be a MessageEnqueued object. **]** */
                callback(null, new results.MessageEnqueued(puback));
              }
            });
          },
github Azure / azure-iot-sdk-node / device / transport / mqtt / src / mqtt_twin_receiver.ts View on Github external
_onEnter: (callback, err) => {
            this._mqtt.removeListener('message', messageHandler);
            if (callback) {
              callback(err);
            } else if (err) {
              this.emit('error', translateError(err));
            }
          },
          subscribe: (callback) => this._fsm.transition('subscribingToResponseTopic', callback),
github Azure / azure-iot-sdk-node / device / transport / mqtt / src / mqtt.ts View on Github external
this._fsm.handle('connect', (err) => {
              if (err) {
                /*Codes_SRS_NODE_DEVICE_MQTT_16_024: [The `sendEvent` method shall call its callback with an `Error` that has been translated using the `translateError` method if the `MqttBase` object fails to establish a connection.]*/
                sendEventCallback(translateError(err));
              } else {
                this._fsm.handle('sendEvent', topic, payload, options, sendEventCallback);
              }
            });
          },
github Azure / azure-iot-sdk-node / device / transport / mqtt / src / mqtt_twin_client.ts View on Github external
this._mqtt.publish(topic, body.toString(), { qos: 0, retain: false }, (err, puback) => {
      if (err) {
        /*Codes_SRS_NODE_DEVICE_MQTT_TWIN_CLIENT_16_008: [If an error happen while publishing the request message, the `callback` shall be called with the translated version of this error obtained by using the `translateError` method of the `azure-iot-mqtt-base` package.]*/
        /*Codes_SRS_NODE_DEVICE_MQTT_TWIN_CLIENT_16_018: [If an error happen while publishing the request message, the `callback` shall be called with the translated version of this error obtained by using the `translateError` method of the `azure-iot-mqtt-base` package.]*/
        delete this._pendingTwinRequests[requestId];
        callback(translateError(err));
      } else {
        debug('twin request sent: ' + puback);
      }
    });
  }

azure-iot-mqtt-base

MQTT operations used by Azure IoT device and service SDKs

MIT
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis

Similar packages