mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
feat: loop dial music (#769)
This commit is contained in:
@@ -82,6 +82,8 @@ function filterAndLimit(logger, tasks) {
|
|||||||
return unique;
|
return unique;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sleepFor = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms));
|
||||||
|
|
||||||
class TaskDial extends Task {
|
class TaskDial extends Task {
|
||||||
constructor(logger, opts) {
|
constructor(logger, opts) {
|
||||||
super(logger, opts);
|
super(logger, opts);
|
||||||
@@ -203,7 +205,16 @@ class TaskDial extends Task {
|
|||||||
else {
|
else {
|
||||||
this.epOther = cs.ep;
|
this.epOther = cs.ep;
|
||||||
if (this.dialMusic && this.epOther && this.epOther.connected) {
|
if (this.dialMusic && this.epOther && this.epOther.connected) {
|
||||||
this.epOther.play(this.dialMusic).catch((err) => {});
|
(async() => {
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
await this.epOther.play(this.dialMusic);
|
||||||
|
} catch (err) {
|
||||||
|
this.logger.error(err, `TaskDial:exec error playing ${this.dialMusic}`);
|
||||||
|
await sleepFor(1000);
|
||||||
|
}
|
||||||
|
} while (!this.killed || !this.bridged);
|
||||||
|
})();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.killed) await this._attemptCalls(cs);
|
if (!this.killed) await this._attemptCalls(cs);
|
||||||
|
|||||||
Reference in New Issue
Block a user