mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
rest dial dtmf
This commit is contained in:
@@ -48,15 +48,15 @@ class TaskRestDial extends Task {
|
|||||||
this.sipRequestWithinDialogHook = this.data.sipRequestWithinDialogHook;
|
this.sipRequestWithinDialogHook = this.data.sipRequestWithinDialogHook;
|
||||||
this.referHook = this.data.referHook;
|
this.referHook = this.data.referHook;
|
||||||
|
|
||||||
// if (this.dtmfHook) {
|
if (this.dtmfHook) {
|
||||||
// const {parentDtmfCollector, childDtmfCollector} = parseDtmfOptions(logger, this.data.dtmfCapture || {});
|
const {parentDtmfCollector, childDtmfCollector} = parseDtmfOptions(logger, this.data.dtmfCapture || {});
|
||||||
// if (parentDtmfCollector) {
|
if (parentDtmfCollector) {
|
||||||
// this.parentDtmfCollector = parentDtmfCollector;
|
this.parentDtmfCollector = parentDtmfCollector;
|
||||||
// }
|
}
|
||||||
// if (childDtmfCollector) {
|
if (childDtmfCollector) {
|
||||||
// this.childDtmfCollector = childDtmfCollector;
|
this.childDtmfCollector = childDtmfCollector;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
this.on('connect', this._onConnect.bind(this));
|
this.on('connect', this._onConnect.bind(this));
|
||||||
this.on('callStatus', this._onCallStatus.bind(this));
|
this.on('callStatus', this._onCallStatus.bind(this));
|
||||||
@@ -99,7 +99,7 @@ class TaskRestDial extends Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove DTMF detection
|
// Remove DTMF detection
|
||||||
// this._removeDtmfDetection(cs.dlg);
|
this._removeDtmfDetection(cs.dlg);
|
||||||
|
|
||||||
this.notifyTaskDone();
|
this.notifyTaskDone();
|
||||||
}
|
}
|
||||||
@@ -190,43 +190,43 @@ class TaskRestDial extends Task {
|
|||||||
this.logger.info({evt}, 'Rest:dial:_onAmdEvent');
|
this.logger.info({evt}, 'Rest:dial:_onAmdEvent');
|
||||||
const {actionHook} = this.data.amd;
|
const {actionHook} = this.data.amd;
|
||||||
this.performHook(cs, actionHook, evt)
|
this.performHook(cs, actionHook, evt)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.logger.error({err}, 'Rest:dial:_onAmdEvent - error calling actionHook');
|
this.logger.error({err}, 'Rest:dial:_onAmdEvent - error calling actionHook');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_installDtmfDetection(cs, dlg) {
|
_installDtmfDetection(cs, dlg) {
|
||||||
dlg.on('info', this._onInfo.bind(this, cs, dlg));
|
dlg.on('info', this._onInfo.bind(this, cs, dlg));
|
||||||
}
|
}
|
||||||
|
|
||||||
// _onInfo(cs, dlg, req, res) {
|
_onInfo(cs, dlg, req, res) {
|
||||||
// res.send(200);
|
res.send(200);
|
||||||
// if (req.get('Content-Type') !== 'application/dtmf-relay') {
|
if (req.get('Content-Type') !== 'application/dtmf-relay') {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// const dtmfDetector = dlg === cs.dlg ? this.parentDtmfCollector : this.childDtmfCollector;
|
|
||||||
// if (!dtmfDetector) return;
|
|
||||||
//
|
|
||||||
// const arr = /Signal=([0-9#*])/.exec(req.body);
|
|
||||||
// if (!arr) return;
|
|
||||||
//
|
|
||||||
// const key = arr[1];
|
|
||||||
// const match = dtmfDetector.keyPress(key);
|
|
||||||
//
|
|
||||||
// if (match) {
|
|
||||||
// const b3 = this.getTracingPropagation();
|
|
||||||
// const httpHeaders = b3 && {b3};
|
|
||||||
// this.logger.info({callSid: cs.callSid}, `RestDial:_onInfo triggered dtmf match: ${match}`);
|
|
||||||
//
|
|
||||||
// cs.requestor.request('verb:hook', this.dtmfHook, {dtmf: match, ...cs.callInfo.toJSON()}, httpHeaders)
|
|
||||||
// .catch((err) => this.logger.info(err, 'RestDial:_onDtmf - error'));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// _removeDtmfDetection(dlg) {
|
const dtmfDetector = dlg === cs.dlg ? this.parentDtmfCollector : this.childDtmfCollector;
|
||||||
// dlg && dlg.removeAllListeners('info');
|
if (!dtmfDetector) return;
|
||||||
// }
|
|
||||||
|
const arr = /Signal=([0-9#*])/.exec(req.body);
|
||||||
|
if (!arr) return;
|
||||||
|
|
||||||
|
const key = arr[1];
|
||||||
|
const match = dtmfDetector.keyPress(key);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
const b3 = this.getTracingPropagation();
|
||||||
|
const httpHeaders = b3 && {b3};
|
||||||
|
this.logger.info({callSid: cs.callSid}, `RestDial:_onInfo triggered dtmf match: ${match}`);
|
||||||
|
|
||||||
|
cs.requestor.request('verb:hook', this.dtmfHook, {dtmf: match, ...cs.callInfo.toJSON()}, httpHeaders)
|
||||||
|
.catch((err) => this.logger.info(err, 'RestDial:_onDtmf - error'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_removeDtmfDetection(dlg) {
|
||||||
|
dlg && dlg.removeAllListeners('info');
|
||||||
|
}
|
||||||
|
|
||||||
_initSipRequestWithinDialogHandler(cs, dlg) {
|
_initSipRequestWithinDialogHandler(cs, dlg) {
|
||||||
cs.sipRequestWithinDialogHook = this.sipRequestWithinDialogHook;
|
cs.sipRequestWithinDialogHook = this.sipRequestWithinDialogHook;
|
||||||
|
|||||||
Reference in New Issue
Block a user