add sip decline testcase

This commit is contained in:
Quan HL
2023-07-27 11:52:38 +07:00
parent 2b4fc478b0
commit cf8d47cb94
3 changed files with 63 additions and 7 deletions

View File

@@ -796,9 +796,9 @@ class CallSession extends Emitter {
}
}
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)) {
if (0 === this.tasks.length && ((this.requestor instanceof WsRequestor && !this.callGone)||
// Tasks are all done, but outgoing dialog is not establish yet, waiting for cancel/handup the call.
!this.dlg && !this.isFinalStatus() && this.direction === CallDirection.Outbound)) {
//let span;
try {
//const {span} = this.rootSpan.startChildSpan('waiting for commands');
@@ -1793,16 +1793,15 @@ class CallSession extends Emitter {
this.updateCallStatus(Object.assign({}, this.callInfo.toJSON()), this.serviceUrl)
.catch((err) => this.logger.error(err, 'redis error'));
if (this.wakeupResolver && !this.dlg && this.isCurrentCallStatusHigherThan(CallStatus.Failed)) {
if (this.wakeupResolver && !this.dlg && this.isFinalStatus()) {
// Someone is waiting for call to be final
this.wakeupResolver({reason: 'session ended'});
this.wakeupResolver = null;
}
}
isCurrentCallStatusHigherThan(target) {
const obj = Object.values(CallStatus);
return obj.indexOf(this.callStatus) >= obj.indexOf(target);
isFinalStatus() {
return [CallStatus.Failed, CallStatus.Busy, CallStatus.NoAnswer, CallStatus.Completed].includes(this.callStatus)
}
async executeStatusCallback(callStatus, sipStatus) {