mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
adding log for issue freshdesk 1600
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user