@voice-ping/cognitive-services-speech
Version:
VoicePing Cognitive Services Speech SDK for JavaScript forked from Microsoft
82 lines (80 loc) • 2.93 kB
JavaScript
;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
var Exports_1 = require("../../common/Exports");
/**
* Placeholder class for the Conversation Request Session. Based off RequestSession.
* TODO: define what telemetry is required.
*/
var ConversationRequestSession = /** @class */ (function () {
function ConversationRequestSession(sessionId) {
var _this = this;
this.privIsDisposed = false;
this.privDetachables = new Array();
this.onPreConnectionStart = function (authFetchEventId, connectionId) {
_this.privSessionId = connectionId;
};
this.onAuthCompleted = function (isError, error) {
if (isError) {
_this.onComplete();
}
};
this.onConnectionEstablishCompleted = function (statusCode, reason) {
if (statusCode === 200) {
return;
}
else if (statusCode === 403) {
_this.onComplete();
}
};
this.onServiceTurnEndResponse = function (continuousRecognition) {
if (!continuousRecognition) {
_this.onComplete();
}
else {
_this.privRequestId = Exports_1.createNoDashGuid();
}
};
this.dispose = function (error) {
if (!_this.privIsDisposed) {
// we should have completed by now. If we did not its an unknown error.
_this.privIsDisposed = true;
for (var _i = 0, _a = _this.privDetachables; _i < _a.length; _i++) {
var detachable = _a[_i];
detachable.detach();
}
}
};
this.onComplete = function () {
//
};
this.privSessionId = sessionId;
this.privRequestId = Exports_1.createNoDashGuid();
this.privRequestCompletionDeferral = new Exports_1.Deferred();
}
Object.defineProperty(ConversationRequestSession.prototype, "sessionId", {
get: function () {
return this.privSessionId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ConversationRequestSession.prototype, "requestId", {
get: function () {
return this.privRequestId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ConversationRequestSession.prototype, "completionPromise", {
get: function () {
return this.privRequestCompletionDeferral.promise();
},
enumerable: true,
configurable: true
});
return ConversationRequestSession;
}());
exports.ConversationRequestSession = ConversationRequestSession;
//# sourceMappingURL=ConversationRequestSession.js.map