@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/cjs/index.cjs
CHANGED
|
@@ -1091,11 +1091,9 @@ var ChannelInstance = class extends import_events.EventEmitter {
|
|
|
1091
1091
|
console.log(`PlaybackFinished '${playback.id}' no canal '${this.id}'.`);
|
|
1092
1092
|
wsClient.removeScopedPlaybackListeners(playback.id, this.app);
|
|
1093
1093
|
});
|
|
1094
|
-
playback.once("
|
|
1095
|
-
console.log(`
|
|
1096
|
-
|
|
1097
|
-
playback.once("PlaybackContinuing", () => {
|
|
1098
|
-
console.log(`PlaybackContinuing '${playback.id}' no canal '${this.id}'.`);
|
|
1094
|
+
playback.once("PlaybackFinished", async () => {
|
|
1095
|
+
console.log(`Playback conclu\xEDdo: ${playback.id}`);
|
|
1096
|
+
this.client.getWebSocketClients().get(this.app)?.removeScopedPlaybackListeners(playback.id, this.app);
|
|
1099
1097
|
});
|
|
1100
1098
|
this.once("ChannelDestroyed", () => {
|
|
1101
1099
|
console.log(
|
|
@@ -1912,7 +1910,13 @@ var WebSocketClient = class extends import_events3.EventEmitter {
|
|
|
1912
1910
|
const listeners = this.listeners(event);
|
|
1913
1911
|
console.log(`=== Listagem de Listeners para '${event}' ===`);
|
|
1914
1912
|
listeners.forEach((listener, index) => {
|
|
1913
|
+
const scopedKey = Array.from(this.scopedListeners.entries()).find(
|
|
1914
|
+
([, value]) => value === listener
|
|
1915
|
+
)?.[0];
|
|
1915
1916
|
console.log(`Listener #${index + 1}:`, listener.toString());
|
|
1917
|
+
if (scopedKey) {
|
|
1918
|
+
console.log(` Associado ao escopo: ${scopedKey}`);
|
|
1919
|
+
}
|
|
1916
1920
|
});
|
|
1917
1921
|
console.log(`Total de listeners para '${event}': ${listeners.length}`);
|
|
1918
1922
|
}
|
|
@@ -2022,21 +2026,27 @@ var WebSocketClient = class extends import_events3.EventEmitter {
|
|
|
2022
2026
|
this.listListeners("message");
|
|
2023
2027
|
}
|
|
2024
2028
|
removeScopedChannelListeners(instanceId, app) {
|
|
2025
|
-
const key =
|
|
2029
|
+
const key = `${app}:${instanceId}`;
|
|
2026
2030
|
const scopedListener = this.scopedListeners.get(key);
|
|
2027
2031
|
if (scopedListener) {
|
|
2032
|
+
console.log(`Removendo listener escopado para o canal '${key}'.`);
|
|
2028
2033
|
this.off("message", scopedListener);
|
|
2029
2034
|
this.scopedListeners.delete(key);
|
|
2030
2035
|
console.log(`Listener de canal removido para '${key}'.`);
|
|
2036
|
+
} else {
|
|
2037
|
+
console.warn(`Nenhum listener encontrado para o canal '${key}'.`);
|
|
2031
2038
|
}
|
|
2032
2039
|
}
|
|
2033
2040
|
removeScopedPlaybackListeners(playbackId, app) {
|
|
2034
|
-
const key =
|
|
2041
|
+
const key = `${app}:${playbackId}`;
|
|
2035
2042
|
const scopedListener = this.scopedListeners.get(key);
|
|
2036
2043
|
if (scopedListener) {
|
|
2044
|
+
console.log(`Removendo listener escopado para o playback '${key}'.`);
|
|
2037
2045
|
this.off("message", scopedListener);
|
|
2038
2046
|
this.scopedListeners.delete(key);
|
|
2039
2047
|
console.log(`Listener de playback removido para '${key}'.`);
|
|
2048
|
+
} else {
|
|
2049
|
+
console.warn(`Nenhum listener encontrado para o playback '${key}'.`);
|
|
2040
2050
|
}
|
|
2041
2051
|
}
|
|
2042
2052
|
/**
|
|
@@ -2051,9 +2061,23 @@ var WebSocketClient = class extends import_events3.EventEmitter {
|
|
|
2051
2061
|
if ("channel" in decodedData && decodedData.channel?.id) {
|
|
2052
2062
|
const channelScopedEvent = `${decodedData.application}:Channel:${decodedData.channel.id}:${decodedData.type}`;
|
|
2053
2063
|
this.emit(channelScopedEvent, decodedData);
|
|
2064
|
+
if (decodedData.type === "ChannelDestroyed") {
|
|
2065
|
+
console.log(`Canal destru\xEDdo detectado: ${decodedData.channel.id}`);
|
|
2066
|
+
this.removeScopedChannelListeners(
|
|
2067
|
+
decodedData.channel.id,
|
|
2068
|
+
decodedData.application
|
|
2069
|
+
);
|
|
2070
|
+
}
|
|
2054
2071
|
} else if ("playback" in decodedData && decodedData.playback?.id) {
|
|
2055
2072
|
const playbackScopedEvent = `${decodedData.application}:Playback:${decodedData.playback.id}:${decodedData.type}`;
|
|
2056
2073
|
this.emit(playbackScopedEvent, decodedData);
|
|
2074
|
+
if (decodedData.type === "PlaybackFinished") {
|
|
2075
|
+
console.log(`Playback conclu\xEDdo: ${decodedData.playback.id}`);
|
|
2076
|
+
this.removeScopedPlaybackListeners(
|
|
2077
|
+
decodedData.playback.id,
|
|
2078
|
+
decodedData.application
|
|
2079
|
+
);
|
|
2080
|
+
}
|
|
2057
2081
|
}
|
|
2058
2082
|
this.emit(scopedEvent, decodedData);
|
|
2059
2083
|
} else {
|