mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-19 04:17:44 +00:00
Support sipindialog for conference (#1050)
* fix: add _onRequestWithinDialog catch block * feat: support sipindialog for conference * fix: remove any existing listener before adding new
This commit is contained in:
@@ -2478,12 +2478,14 @@ Duration=${duration} `
|
||||
} else if (sip_method === 'MESSAGE') {
|
||||
res.send(202);
|
||||
} else {
|
||||
this.logger.info(`CallSession:_onRequestWithinDialog unsported method: ${req.method}`);
|
||||
this.logger.warn(`CallSession:_onRequestWithinDialog unsupported method: ${req.method}`);
|
||||
res.send(501);
|
||||
return;
|
||||
}
|
||||
const params = {sip_method, sip_body: req.body, sip_headers: req.headers};
|
||||
this.currentTask.performHook(this, this.sipRequestWithinDialogHook, params);
|
||||
this.currentTask.performHook(this, this.sipRequestWithinDialogHook, params).catch((err) => {
|
||||
this.logger.error({err}, 'CallSession:_onRequestWithinDialog - error calling sipRequestWithinDialogHook');
|
||||
});
|
||||
}
|
||||
|
||||
async _onReinvite(req, res) {
|
||||
|
||||
@@ -83,7 +83,11 @@ class Conference extends Task {
|
||||
// reset answer time if we were transferred from another feature server
|
||||
if (this.connectTime) dlg.connectTime = this.connectTime;
|
||||
|
||||
|
||||
if (cs.sipRequestWithinDialogHook) {
|
||||
/* remove any existing listener to escape from duplicating events */
|
||||
this._removeSipIndialogRequestListener(this.dlg);
|
||||
this._initSipIndialogRequestListener(cs, dlg);
|
||||
}
|
||||
this.ep.on('destroy', this._kicked.bind(this, cs, dlg));
|
||||
|
||||
try {
|
||||
@@ -103,6 +107,7 @@ class Conference extends Task {
|
||||
|
||||
this.logger.debug(`Conference:exec - conference ${this.confName} is over`);
|
||||
if (this.callMoved !== false) await this.performAction(this.results);
|
||||
this._removeSipIndialogRequestListener(dlg);
|
||||
} catch (err) {
|
||||
this.logger.info(err, `TaskConference:exec - error in conference ${this.confName}`);
|
||||
}
|
||||
@@ -416,6 +421,20 @@ class Conference extends Task {
|
||||
}
|
||||
}
|
||||
|
||||
_initSipIndialogRequestListener(cs, dlg) {
|
||||
dlg.on('info', this._onRequestWithinDialog.bind(this, cs));
|
||||
dlg.on('message', this._onRequestWithinDialog.bind(this, cs));
|
||||
}
|
||||
|
||||
_removeSipIndialogRequestListener(dlg) {
|
||||
dlg && dlg.removeAllListeners('message');
|
||||
dlg && dlg.removeAllListeners('info');
|
||||
}
|
||||
|
||||
_onRequestWithinDialog(cs, req, res) {
|
||||
cs._onRequestWithinDialog(req, res);
|
||||
}
|
||||
|
||||
/**
|
||||
* The conference we have been waiting for has started.
|
||||
* It may be on this server or a different one, and we are
|
||||
|
||||
@@ -499,7 +499,7 @@ class TaskDial extends Task {
|
||||
dlg && dlg.removeAllListeners('info');
|
||||
}
|
||||
|
||||
async _onRequestWithinDialog(cs, req, res) {
|
||||
_onRequestWithinDialog(cs, req, res) {
|
||||
cs._onRequestWithinDialog(req, res);
|
||||
}
|
||||
|
||||
@@ -871,7 +871,11 @@ class TaskDial extends Task {
|
||||
|
||||
if (this.parentDtmfCollector) this._installDtmfDetection(cs, cs.dlg);
|
||||
if (this.childDtmfCollector) this._installDtmfDetection(cs, this.dlg);
|
||||
if (cs.sipRequestWithinDialogHook) this._initSipIndialogRequestListener(cs, this.dlg);
|
||||
if (cs.sipRequestWithinDialogHook) {
|
||||
/* remove any existing listener to escape from duplicating events */
|
||||
this._removeSipIndialogRequestListener(this.dlg);
|
||||
this._initSipIndialogRequestListener(cs, this.dlg);
|
||||
}
|
||||
|
||||
if (this.transcribeTask) this.transcribeTask.exec(cs, {ep: this.epOther, ep2:this.ep});
|
||||
if (this.listenTask) this.listenTask.exec(cs, {ep: this.listenTask.channel === 2 ? this.ep : this.epOther});
|
||||
|
||||
Reference in New Issue
Block a user