@ipcom/asterisk-ari 0.0.108 → 0.0.110

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.
@@ -984,6 +984,12 @@ var ChannelInstance = class extends import_events2.EventEmitter {
984
984
  );
985
985
  }
986
986
  const scopedEvent = `${this.app}:Channel:${this.id}:${event}`;
987
+ console.log({ metheod: "on", event, scopedEvent });
988
+ const existingListeners = wsClient.listeners(scopedEvent);
989
+ if (existingListeners.includes(callback)) {
990
+ console.warn(`Listener j\xE1 registrado para o evento '${scopedEvent}'.`);
991
+ return this;
992
+ }
987
993
  wsClient.on(scopedEvent, callback);
988
994
  return this;
989
995
  }
@@ -999,10 +1005,16 @@ var ChannelInstance = class extends import_events2.EventEmitter {
999
1005
  }
1000
1006
  wsClient.removeWildcardListeners(this.id, event, "Channel");
1001
1007
  const scopedEvent = `${this.app}:Channel:${this.id}:${event}`;
1002
- console.log({ scopedEvent });
1008
+ console.log({ metheod: "once", event, scopedEvent });
1009
+ const existingListeners = wsClient.listeners(scopedEvent);
1010
+ if (existingListeners.some((listener2) => listener2 === callback)) {
1011
+ console.warn(`Listener j\xE1 registrado para o evento '${scopedEvent}'.`);
1012
+ return this;
1013
+ }
1003
1014
  const listener = (data) => {
1004
1015
  callback(data);
1005
1016
  wsClient.off(scopedEvent, listener);
1017
+ wsClient.removeWildcardListeners(this.id, event, "Channel");
1006
1018
  };
1007
1019
  wsClient.on(scopedEvent, listener);
1008
1020
  return this;
@@ -1505,6 +1517,12 @@ var PlaybackInstance = class extends import_events3.EventEmitter {
1505
1517
  );
1506
1518
  }
1507
1519
  const scopedEvent = `${this.app}:Playback:${this.id}:${event}`;
1520
+ console.log({ metheod: "on", event, scopedEvent });
1521
+ const existingListeners = wsClient.listeners(scopedEvent);
1522
+ if (existingListeners.some((listener) => listener === callback)) {
1523
+ console.warn(`Listener j\xE1 registrado para o evento '${scopedEvent}'.`);
1524
+ return this;
1525
+ }
1508
1526
  wsClient.on(scopedEvent, callback);
1509
1527
  return this;
1510
1528
  }
@@ -1520,9 +1538,16 @@ var PlaybackInstance = class extends import_events3.EventEmitter {
1520
1538
  }
1521
1539
  wsClient.removeWildcardListeners(this.id, event, "Playback");
1522
1540
  const scopedEvent = `${this.app}:Playback:${this.id}:${event}`;
1541
+ console.log({ metheod: "once", event, scopedEvent });
1542
+ const existingListeners = wsClient.listeners(scopedEvent);
1543
+ if (existingListeners.some((listener2) => listener2 === callback)) {
1544
+ console.warn(`Listener j\xE1 registrado para o evento '${scopedEvent}'.`);
1545
+ return this;
1546
+ }
1523
1547
  const listener = (data) => {
1524
1548
  callback(data);
1525
1549
  wsClient.off(scopedEvent, listener);
1550
+ wsClient.removeWildcardListeners(this.id, event, "Playback");
1526
1551
  };
1527
1552
  wsClient.on(scopedEvent, listener);
1528
1553
  return this;
@@ -1954,11 +1979,9 @@ var WebSocketClient = class extends import_events4.EventEmitter {
1954
1979
  const scopedEvent = `${decodedData.application}:${decodedData.type}`;
1955
1980
  if ("channel" in decodedData && decodedData.channel?.id) {
1956
1981
  const channelScopedEvent = `${decodedData.application}:Channel:${decodedData.channel.id}:${decodedData.type}`;
1957
- console.log({ handleMessage: decodedData });
1958
1982
  this.emit(channelScopedEvent, decodedData);
1959
1983
  } else if ("playback" in decodedData && decodedData.playback?.id) {
1960
1984
  const playbackScopedEvent = `${decodedData.application}:Playback:${decodedData.playback.id}:${decodedData.type}`;
1961
- console.log({ handleMessage: decodedData });
1962
1985
  this.emit(playbackScopedEvent, decodedData);
1963
1986
  }
1964
1987
  this.emit(scopedEvent, decodedData);