mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
listen: when passDtmf is true, send dtmf events down websocket connection as json test frames (#129)
This commit is contained in:
@@ -22,8 +22,6 @@ class TaskListen extends Task {
|
|||||||
this.results = {};
|
this.results = {};
|
||||||
|
|
||||||
if (this.transcribe) this.transcribeTask = makeTask(logger, {'transcribe': opts.transcribe}, this);
|
if (this.transcribe) this.transcribeTask = makeTask(logger, {'transcribe': opts.transcribe}, this);
|
||||||
|
|
||||||
this._dtmfHandler = this._onDtmf.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() { return TaskName.Listen; }
|
get name() { return TaskName.Listen; }
|
||||||
@@ -31,6 +29,7 @@ class TaskListen extends Task {
|
|||||||
async exec(cs, ep) {
|
async exec(cs, ep) {
|
||||||
await super.exec(cs);
|
await super.exec(cs);
|
||||||
this.ep = ep;
|
this.ep = ep;
|
||||||
|
this._dtmfHandler = this._onDtmf.bind(this, ep);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.hook = this.normalizeUrl(this.url, 'GET', this.wsAuth);
|
this.hook = this.normalizeUrl(this.url, 'GET', this.wsAuth);
|
||||||
@@ -148,7 +147,13 @@ class TaskListen extends Task {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDtmf(evt) {
|
_onDtmf(ep, evt) {
|
||||||
|
this.logger.debug({evt}, `TaskListen:_onDtmf received dtmf ${evt.dtmf}`);
|
||||||
|
if (this.passDtmf && this.ep?.connected) {
|
||||||
|
const obj = {event: 'dtmf', dtmf: evt.dtmf, duration: evt.duration};
|
||||||
|
this.ep.forkAudioSendText(obj)
|
||||||
|
.catch((err) => this.logger.info({err}, 'TaskListen:_onDtmf error sending dtmf'));
|
||||||
|
}
|
||||||
if (evt.dtmf === this.finishOnKey) {
|
if (evt.dtmf === this.finishOnKey) {
|
||||||
this.logger.info(`TaskListen:_onDtmf terminating task due to dtmf ${evt.dtmf}`);
|
this.logger.info(`TaskListen:_onDtmf terminating task due to dtmf ${evt.dtmf}`);
|
||||||
this.results.digits = evt.dtmf;
|
this.results.digits = evt.dtmf;
|
||||||
|
|||||||
Reference in New Issue
Block a user