@ipcom/asterisk-ari 0.0.107 → 0.0.109

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,11 +997,13 @@ 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) => {
1003
1004
  callback(data);
1004
1005
  wsClient.off(scopedEvent, listener);
1006
+ wsClient.removeWildcardListeners(this.id, event, "Channel");
1005
1007
  };
1006
1008
  wsClient.on(scopedEvent, listener);
1007
1009
  return this;
@@ -1517,11 +1519,12 @@ var PlaybackInstance = class extends import_events3.EventEmitter {
1517
1519
  `Nenhum WebSocket conectado dispon\xEDvel para '${this.app}'.`
1518
1520
  );
1519
1521
  }
1522
+ wsClient.removeWildcardListeners(this.id, event, "Playback");
1520
1523
  const scopedEvent = `${this.app}:Playback:${this.id}:${event}`;
1521
- console.log({ scopedEvent });
1522
1524
  const listener = (data) => {
1523
1525
  callback(data);
1524
1526
  wsClient.off(scopedEvent, listener);
1527
+ wsClient.removeWildcardListeners(this.id, event, "Playback");
1525
1528
  };
1526
1529
  wsClient.on(scopedEvent, listener);
1527
1530
  return this;
@@ -1858,6 +1861,20 @@ var WebSocketClient = class extends import_events4.EventEmitter {
1858
1861
  super.off(event, callback);
1859
1862
  return this;
1860
1863
  }
1864
+ removeWildcardListeners(id, event, type) {
1865
+ console.log(
1866
+ `Removendo listeners para '${type}:${id}:${event}' com wildcard no app`
1867
+ );
1868
+ for (const eventName of this.eventNames()) {
1869
+ if (typeof eventName === "string") {
1870
+ const eventString = String(eventName);
1871
+ if (eventString.includes(`:${type}:${id}:${event}`)) {
1872
+ console.log(`Removendo listener para o evento: ${eventString}`);
1873
+ this.removeAllListeners(eventName);
1874
+ }
1875
+ }
1876
+ }
1877
+ }
1861
1878
  /**
1862
1879
  * Removes all listeners for a specific event, or all events if no event is specified.
1863
1880
  * @param event - Optional. The event to remove all listeners from.