Use the request from CallSession for cancel (#268)

* Use the req from CallSession for cancel

* Check cs is set

---------

Co-authored-by: Matt Preskett <matt.preskett@netcall.com>
This commit is contained in:
two56
2023-02-23 14:13:44 +00:00
committed by GitHub
parent a5cd342e46
commit 803a944240

View File

@@ -27,7 +27,7 @@ class TaskRestDial extends Task {
*/
async exec(cs) {
await super.exec(cs);
this.req = cs.req;
this.canCancel = true;
this._setCallTimer();
await this.awaitTaskDone();
@@ -36,15 +36,15 @@ class TaskRestDial extends Task {
kill(cs) {
super.kill(cs);
this._clearCallTimer();
if (this.req) {
this.req.cancel();
this.req = null;
if (this.canCancel && cs?.req) {
this.canCancel = false;
cs.req.cancel();
}
this.notifyTaskDone();
}
async _onConnect(dlg) {
this.req = null;
this.canCancel = false;
const cs = this.callSession;
cs.setDialog(dlg);
@@ -79,7 +79,7 @@ class TaskRestDial extends Task {
_onCallStatus(status) {
this.logger.debug(`CallStatus: ${status}`);
if (status >= 200) {
this.req = null;
this.canCancel = false;
this._clearCallTimer();
if (status !== 200) this.notifyTaskDone();
}