@ipcom/asterisk-ari 0.0.107 → 0.0.108

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -997,6 +997,7 @@ var ChannelInstance = class extends import_events2.EventEmitter {
997
997
  `Nenhum WebSocket conectado dispon\xEDvel para '${this.app}'.`
998
998
  );
999
999
  }
1000
+ wsClient.removeWildcardListeners(this.id, event, "Channel");
1000
1001
  const scopedEvent = `${this.app}:Channel:${this.id}:${event}`;
1001
1002
  console.log({ scopedEvent });
1002
1003
  const listener = (data) => {
@@ -1517,8 +1518,8 @@ var PlaybackInstance = class extends import_events3.EventEmitter {
1517
1518
  `Nenhum WebSocket conectado dispon\xEDvel para '${this.app}'.`
1518
1519
  );
1519
1520
  }
1521
+ wsClient.removeWildcardListeners(this.id, event, "Playback");
1520
1522
  const scopedEvent = `${this.app}:Playback:${this.id}:${event}`;
1521
- console.log({ scopedEvent });
1522
1523
  const listener = (data) => {
1523
1524
  callback(data);
1524
1525
  wsClient.off(scopedEvent, listener);
@@ -1858,6 +1859,20 @@ var WebSocketClient = class extends import_events4.EventEmitter {
1858
1859
  super.off(event, callback);
1859
1860
  return this;
1860
1861
  }
1862
+ removeWildcardListeners(id, event, type) {
1863
+ console.log(
1864
+ `Removendo listeners para '${type}:${id}:${event}' com wildcard no app`
1865
+ );
1866
+ for (const eventName of this.eventNames()) {
1867
+ if (typeof eventName === "string") {
1868
+ const eventString = String(eventName);
1869
+ if (eventString.includes(`:${type}:${id}:${event}`)) {
1870
+ console.log(`Removendo listener para o evento: ${eventString}`);
1871
+ this.removeAllListeners(eventName);
1872
+ }
1873
+ }
1874
+ }
1875
+ }
1861
1876
  /**
1862
1877
  * Removes all listeners for a specific event, or all events if no event is specified.
1863
1878
  * @param event - Optional. The event to remove all listeners from.