@ipcom/asterisk-ari 0.0.129 → 0.0.131
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.
package/dist/esm/index.js
CHANGED
|
@@ -1069,11 +1069,9 @@ var ChannelInstance = class extends EventEmitter {
|
|
|
1069
1069
|
console.log(`PlaybackFinished '${playback.id}' no canal '${this.id}'.`);
|
|
1070
1070
|
wsClient.removeScopedPlaybackListeners(playback.id, this.app);
|
|
1071
1071
|
});
|
|
1072
|
-
playback.once("
|
|
1073
|
-
console.log(`
|
|
1074
|
-
|
|
1075
|
-
playback.once("PlaybackContinuing", () => {
|
|
1076
|
-
console.log(`PlaybackContinuing '${playback.id}' no canal '${this.id}'.`);
|
|
1072
|
+
playback.once("PlaybackFinished", async () => {
|
|
1073
|
+
console.log(`Playback conclu\xEDdo: ${playback.id}`);
|
|
1074
|
+
this.client.getWebSocketClients().get(this.app)?.removeScopedPlaybackListeners(playback.id, this.app);
|
|
1077
1075
|
});
|
|
1078
1076
|
this.once("ChannelDestroyed", () => {
|
|
1079
1077
|
console.log(
|
|
@@ -1890,7 +1888,13 @@ var WebSocketClient = class extends EventEmitter3 {
|
|
|
1890
1888
|
const listeners = this.listeners(event);
|
|
1891
1889
|
console.log(`=== Listagem de Listeners para '${event}' ===`);
|
|
1892
1890
|
listeners.forEach((listener, index) => {
|
|
1891
|
+
const scopedKey = Array.from(this.scopedListeners.entries()).find(
|
|
1892
|
+
([, value]) => value === listener
|
|
1893
|
+
)?.[0];
|
|
1893
1894
|
console.log(`Listener #${index + 1}:`, listener.toString());
|
|
1895
|
+
if (scopedKey) {
|
|
1896
|
+
console.log(` Associado ao escopo: ${scopedKey}`);
|
|
1897
|
+
}
|
|
1894
1898
|
});
|
|
1895
1899
|
console.log(`Total de listeners para '${event}': ${listeners.length}`);
|
|
1896
1900
|
}
|
|
@@ -2000,21 +2004,27 @@ var WebSocketClient = class extends EventEmitter3 {
|
|
|
2000
2004
|
this.listListeners("message");
|
|
2001
2005
|
}
|
|
2002
2006
|
removeScopedChannelListeners(instanceId, app) {
|
|
2003
|
-
const key =
|
|
2007
|
+
const key = `${app}:${instanceId}`;
|
|
2004
2008
|
const scopedListener = this.scopedListeners.get(key);
|
|
2005
2009
|
if (scopedListener) {
|
|
2010
|
+
console.log(`Removendo listener escopado para o canal '${key}'.`);
|
|
2006
2011
|
this.off("message", scopedListener);
|
|
2007
2012
|
this.scopedListeners.delete(key);
|
|
2008
2013
|
console.log(`Listener de canal removido para '${key}'.`);
|
|
2014
|
+
} else {
|
|
2015
|
+
console.warn(`Nenhum listener encontrado para o canal '${key}'.`);
|
|
2009
2016
|
}
|
|
2010
2017
|
}
|
|
2011
2018
|
removeScopedPlaybackListeners(playbackId, app) {
|
|
2012
|
-
const key =
|
|
2019
|
+
const key = `${app}:${playbackId}`;
|
|
2013
2020
|
const scopedListener = this.scopedListeners.get(key);
|
|
2014
2021
|
if (scopedListener) {
|
|
2022
|
+
console.log(`Removendo listener escopado para o playback '${key}'.`);
|
|
2015
2023
|
this.off("message", scopedListener);
|
|
2016
2024
|
this.scopedListeners.delete(key);
|
|
2017
2025
|
console.log(`Listener de playback removido para '${key}'.`);
|
|
2026
|
+
} else {
|
|
2027
|
+
console.warn(`Nenhum listener encontrado para o playback '${key}'.`);
|
|
2018
2028
|
}
|
|
2019
2029
|
}
|
|
2020
2030
|
/**
|
|
@@ -2029,9 +2039,23 @@ var WebSocketClient = class extends EventEmitter3 {
|
|
|
2029
2039
|
if ("channel" in decodedData && decodedData.channel?.id) {
|
|
2030
2040
|
const channelScopedEvent = `${decodedData.application}:Channel:${decodedData.channel.id}:${decodedData.type}`;
|
|
2031
2041
|
this.emit(channelScopedEvent, decodedData);
|
|
2042
|
+
if (decodedData.type === "ChannelDestroyed") {
|
|
2043
|
+
console.log(`Canal destru\xEDdo detectado: ${decodedData.channel.id}`);
|
|
2044
|
+
this.removeScopedChannelListeners(
|
|
2045
|
+
decodedData.channel.id,
|
|
2046
|
+
decodedData.application
|
|
2047
|
+
);
|
|
2048
|
+
}
|
|
2032
2049
|
} else if ("playback" in decodedData && decodedData.playback?.id) {
|
|
2033
2050
|
const playbackScopedEvent = `${decodedData.application}:Playback:${decodedData.playback.id}:${decodedData.type}`;
|
|
2034
2051
|
this.emit(playbackScopedEvent, decodedData);
|
|
2052
|
+
if (decodedData.type === "PlaybackFinished") {
|
|
2053
|
+
console.log(`Playback conclu\xEDdo: ${decodedData.playback.id}`);
|
|
2054
|
+
this.removeScopedPlaybackListeners(
|
|
2055
|
+
decodedData.playback.id,
|
|
2056
|
+
decodedData.application
|
|
2057
|
+
);
|
|
2058
|
+
}
|
|
2035
2059
|
}
|
|
2036
2060
|
this.emit(scopedEvent, decodedData);
|
|
2037
2061
|
} else {
|