mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
feat sip indialog actionHook (#477)
* feat sip indialog actionHook * feat sip indialog actionHook * feat sip indialog actionHook * feat sip indialog actionHook * update verb spec * fix * fix * rename function as required _onRequestWithinDialog
This commit is contained in:
@@ -414,6 +414,14 @@ class CallSession extends Emitter {
|
||||
this._onHoldMusic = url;
|
||||
}
|
||||
|
||||
get sipRequestWithinDialogHook() {
|
||||
return this._sipRequestWithinDialogHook;
|
||||
}
|
||||
|
||||
set sipRequestWithinDialogHook(url) {
|
||||
this._sipRequestWithinDialogHook = url;
|
||||
}
|
||||
|
||||
hasGlobalSttPunctuation() {
|
||||
return this._globalSttPunctuation !== undefined;
|
||||
}
|
||||
@@ -1646,10 +1654,32 @@ class CallSession extends Emitter {
|
||||
}
|
||||
this.dlg.on('modify', this._onReinvite.bind(this));
|
||||
this.dlg.on('refer', this._onRefer.bind(this));
|
||||
if (this.sipRequestWithinDialogHook) {
|
||||
this.dlg.on('info', this._onRequestWithinDialog.bind(this));
|
||||
this.dlg.on('message', this._onRequestWithinDialog.bind(this));
|
||||
}
|
||||
this.logger.debug(`CallSession:propagateAnswer - answered callSid ${this.callSid}`);
|
||||
}
|
||||
}
|
||||
|
||||
async _onRequestWithinDialog(req, res) {
|
||||
if (!this.sipRequestWithinDialogHook) {
|
||||
return;
|
||||
}
|
||||
const sip_method = req.method;
|
||||
if (sip_method === 'INFO') {
|
||||
res.send(200);
|
||||
} else if (sip_method === 'MESSAGE') {
|
||||
res.send(202);
|
||||
} else {
|
||||
this.logger.info(`CallSession:_onRequestWithinDialog unsported method: ${req.method}`);
|
||||
res.send(501);
|
||||
return;
|
||||
}
|
||||
const params = {sip_method, sip_body: req.body};
|
||||
this.currentTask.performHook(this, this.sipRequestWithinDialogHook, params);
|
||||
}
|
||||
|
||||
async _onReinvite(req, res) {
|
||||
try {
|
||||
if (this.ep) {
|
||||
|
||||
Reference in New Issue
Block a user