Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(config: Client.Config, baseClient?: BaseAmqpClient) {
super();
this._config = config;
this._amqp = baseClient || new BaseAmqpClient(false, 'azure-iot-device/' + packageJson.version);
this._amqp.setDisconnectHandler((err) => {
debug('disconnected event handler: ' + (err ? err.toString() : 'no error'));
this._fsm.handle('disconnect', () => {
this.emit('disconnect', getTranslatedError(err, 'AMQP client disconnected'));
});
});
this._deviceMethodClient = new AmqpDeviceMethodClient(this._config, this._amqp);
/*Codes_SRS_NODE_DEVICE_AMQP_16_041: [Any `error` event received on any of the links used for device methods shall trigger the emission of an `error` event by the transport, with an argument that is a `MethodsDetachedError` object with the `innerError` property set to that error.]*/
this._deviceMethodClient.on('error', (err) => {
let methodsError = new errors.DeviceMethodsDetachedError('Device Methods AMQP links failed');
methodsError.innerError = err;
this.emit('error', methodsError);
});
this._twinClient = new AmqpTwinClient(this._config, this._amqp);
constructor(config: Client.TransportConfigOptions, amqpBase?: Base) {
super();
this._amqp = amqpBase ? amqpBase : new Base(true);
this._config = config;
this._renewalTimeout = null;
this._amqp.setDisconnectHandler((err) => {
this._fsm.handle('amqpError', err);
});
this._c2dErrorListener = (err) => {
debug('Error on the D2C link: ' + err.toString());
this._c2dLink = null;
};
this._feedbackErrorListener = (err) => {
debug('Error on the message feedback link: ' + err.toString());
this._feedbackReceiver = null;
};
function Amqp(config, amqpBase) {
var _this = _super.call(this) || this;
_this._renewalNumberOfMilliseconds = 2700000;
_this._c2dEndpoint = '/messages/devicebound';
_this._feedbackEndpoint = '/messages/serviceBound/feedback';
_this._fileNotificationEndpoint = '/messages/serviceBound/filenotifications';
_this._amqp = amqpBase ? amqpBase : new azure_iot_amqp_base_1.Amqp(true, packageJson.name + '/' + packageJson.version);
_this._config = config;
_this._renewalTimeout = null;
_this._amqp.setDisconnectHandler(function (err) {
_this._fsm.handle('amqpError', err);
});
_this._c2dErrorListener = function (err) {
debug('Error on the D2C link: ' + err.toString());
_this._c2dLink = null;
};
_this._feedbackErrorListener = function (err) {
debug('Error on the message feedback link: ' + err.toString());
_this._feedbackReceiver = null;
};
_this._fileNotificationErrorListener = function (err) {
debug('Error on the file notification link: ' + err.toString());
_this._fileNotificationReceiver = null;
constructor(amqpBase?: Base) {
super();
this._amqpBase = amqpBase || new Base(true);
this._config.pollingInterval = ProvisioningDeviceConstants.defaultPollingInterval;
const amqpErrorListener = (err) => this._amqpStateMachine.handle('amqpError', err);
const responseHandler = (msg) => {
debug('got message with correlation_id: ' + msg.correlation_id);
/*Codes_SRS_NODE_PROVISIONING_AMQP_16_007: [The `registrationRequest` method shall call its callback with a `RegistrationResult` object parsed from the body of the response message which `correlation_id` matches the `correlation_id` of the request message sent on the sender link.]*/
/*Codes_SRS_NODE_PROVISIONING_AMQP_16_017: [The `queryOperationStatus` method shall call its callback with a `RegistrationResult` object parsed from the body of the response message which `correlation_id` matches the `correlation_id` of the request message sent on the sender link.]*/
const registrationResult = JSON.parse(msg.body.content);
if (this._operations[msg.correlation_id]) {
debug('Got the registration/operationStatus message we were looking for.');
const requestCallback = this._operations[msg.correlation_id];
delete this._operations[msg.correlation_id];
let retryAfterInMilliseconds: number;
/*Codes_SRS_NODE_PROVISIONING_AMQP_06_010: [If the amqp response to a request contains the application property`retry-after`, it will be interpreted as the number of seconds that should elapse before the next attempted operation. Otherwise default.] */
if (msg.application_properties && msg.application_properties[MessagePropertyNames.retryAfter]) {
function Amqp(config) {
var uri = 'amqps://';
uri += encodeURIComponent(config.keyName) +
'%40sas.root.' +
config.hubName +
':' +
encodeURIComponent(config.sharedAccessSignature) +
'@' +
config.host;
this._amqp = new Base(uri, true, 'azure-iothub/' + PackageJson.version);
this._config = config;
}