in digital-shadow/demo-car/js/aws-iot/aws-iot.js [16355:16422]
this.register = function(thingName, options, callback) {
if (!thingShadows.hasOwnProperty(thingName)) {
var ignoreDeltas = false;
var topicSpecs = [];
thingShadows[thingName] = {
persistentSubscribe: true,
debug: false,
discardStale: true,
enableVersioning: true,
qos: 0,
pending: true
};
if (!isUndefined(options)) {
if (!isUndefined(options.ignoreDeltas)) {
ignoreDeltas = options.ignoreDeltas;
}
if (!isUndefined(options.persistentSubscribe)) {
thingShadows[thingName].persistentSubscribe = options.persistentSubscribe;
}
if (!isUndefined(options.debug)) {
thingShadows[thingName].debug = options.debug;
}
if (!isUndefined(options.discardStale)) {
thingShadows[thingName].discardStale = options.discardStale;
}
if (!isUndefined(options.enableVersioning)) {
thingShadows[thingName].enableVersioning = options.enableVersioning;
}
if (!isUndefined(options.qos)) {
thingShadows[thingName].qos = options.qos;
}
}
if (ignoreDeltas === false) {
topicSpecs.push({
operations: ['update'],
statii: ['delta']
});
}
if (thingShadows[thingName].persistentSubscribe === true) {
topicSpecs.push({
operations: ['update', 'get', 'delete'],
statii: ['accepted', 'rejected']
});
}
if (topicSpecs.length > 0) {
this._handleSubscriptions(thingName, topicSpecs, 'subscribe', function(err, failedTopics) {
if (isUndefined(err) && isUndefined(failedTopics)) {
thingShadows[thingName].pending = false;
}
if (!isUndefined(callback)) {
callback(err, failedTopics);
}
});
} else {
thingShadows[thingName].pending = false;
if (!isUndefined(callback)) {
callback();
}
}
} else {
if (deviceOptions.debug === true) {
console.error('thing already registered: ', thingName);
}
}
};