adding log for issue freshdesk 1600

This commit is contained in:
Hoan HL
2025-11-09 17:00:01 +07:00
parent aecb6c9ee1
commit 909727899d
3 changed files with 8 additions and 2 deletions

View File

@@ -78,7 +78,7 @@ class CallSession extends Emitter {
this.callGone = false;
this.notifiedComplete = false;
this.rootSpan = rootSpan;
this.stickyEventEmitter = new StickyEventEmitter();
this.stickyEventEmitter = new StickyEventEmitter(logger);
this.stickyEventEmitter.onSuccess = () => {
this.taskInProgress = null;
this.stickyEventEmitter.destroy();

View File

@@ -67,6 +67,9 @@ class TaskPlay extends Task {
this.logger.debug(`Play got kill-playback, executing uuid_break, taskId: ${t?.taskId}`);
this.ep.api('uuid_break', this.ep.uuid).catch((err) => this.logger.info(err, 'Error killing audio'));
this.notifyStatus({event: 'kill-playback'});
} else {
this.logger.debug(
`Play received uuid_break for different taskId: ${t?.taskId}, current taskId: ${this.taskId}`);
}
});
});

View File

@@ -13,10 +13,11 @@ const EventEmitter = require('events');
* - Maintains compatibility with Node's EventEmitter interface
*/
class StickyEventEmitter extends EventEmitter {
constructor() {
constructor(logger) {
super();
this._eventCache = new Map();
this._onceListeners = new Map(); // For storing once listeners if needed
this.logger = logger;
}
destroy() {
this._eventCache.clear();
@@ -28,12 +29,14 @@ class StickyEventEmitter extends EventEmitter {
this._eventCache.set(event, args);
// If there are any 'once' listeners waiting, call them
this.logger.debug(`StickyEventEmitter emitting event: ${event} with args: ${JSON.stringify(args)}`);
if (this._onceListeners.has(event)) {
const listeners = this._onceListeners.get(event);
for (const listener of listeners) {
listener(...args);
}
if (this.onSuccess) {
this.logger.debug(`StickyEventEmitter calling onSuccess for event: ${event}`);
this.onSuccess();
}
this._onceListeners.delete(event);