This commit is contained in:
Quan HL
2023-07-27 06:36:48 +07:00
parent 38ea9e7411
commit b88a9d4d4d
2 changed files with 16 additions and 2 deletions

View File

@@ -796,7 +796,9 @@ class CallSession extends Emitter {
} }
} }
if (0 === this.tasks.length && this.requestor instanceof WsRequestor && !this.callGone) { if (0 === this.tasks.length && ((this.requestor instanceof WsRequestor && !this.callGone) ||
// Tasks are all done, but dialog is not establish yet, waiting for cancel/handup the call.
!this.dlg)) {
//let span; //let span;
try { try {
//const {span} = this.rootSpan.startChildSpan('waiting for commands'); //const {span} = this.rootSpan.startChildSpan('waiting for commands');
@@ -1790,6 +1792,17 @@ class CallSession extends Emitter {
//this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`); //this.logger.debug(`updating redis with ${JSON.stringify(this.callInfo)}`);
this.updateCallStatus(Object.assign({}, this.callInfo.toJSON()), this.serviceUrl) this.updateCallStatus(Object.assign({}, this.callInfo.toJSON()), this.serviceUrl)
.catch((err) => this.logger.error(err, 'redis error')); .catch((err) => this.logger.error(err, 'redis error'));
if (this.wakeupResolver && !this.dlg && this.isCurrentCallHigherThan(CallStatus.Failed)) {
// Someone is waiting for call to be final
this.wakeupResolver({reason: 'session ended'});
this.wakeupResolver = null;
}
}
isCurrentCallHigherThan(target) {
const obj = Object.values(CallStatus);
return obj.indexOf(this.callStatus) >= obj.indexOf(target);
} }
async executeStatusCallback(callStatus, sipStatus) { async executeStatusCallback(callStatus, sipStatus) {

View File

@@ -31,11 +31,12 @@
}, },
"AllowedSipRecVerbs": ["config", "gather", "transcribe", "listen"], "AllowedSipRecVerbs": ["config", "gather", "transcribe", "listen"],
"CallStatus": { "CallStatus": {
"Queued": "queued",
"Trying": "trying", "Trying": "trying",
"Ringing": "ringing", "Ringing": "ringing",
"EarlyMedia": "early-media", "EarlyMedia": "early-media",
"InProgress": "in-progress", "InProgress": "in-progress",
"Queued": "queued",
"Failed": "failed", "Failed": "failed",
"Busy": "busy", "Busy": "busy",
"NoAnswer": "no-answer", "NoAnswer": "no-answer",