Fixed awaiting

This commit is contained in:
hydrabolt
2015-11-21 20:59:33 +00:00
parent ddfed4da6c
commit d916e5719b
5 changed files with 58 additions and 9 deletions

View File

@@ -804,6 +804,25 @@ var Client = (function (_EventEmitter) {
});
};
// def awaitResponse
Client.prototype.awaitResponse = function awaitResponse(msg) {
var _this = this;
var callback = arguments.length <= 1 || arguments[1] === undefined ? function (e, newMsg) {} : arguments[1];
return new Promise(function (resolve, reject) {
_this.internal.awaitResponse(msg).then(function (newMsg) {
resolve(newMsg);
callback(null, newMsg);
})["catch"](function (e) {
callback(e);
reject(e);
});
});
};
Client.prototype.setStatusIdle = function setStatusIdle() {
this.setStatus("idle");
};