@ipcom/asterisk-ari 0.0.131 → 0.0.133
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 +26 -23
- package/dist/cjs/index.cjs.map +3 -3
- package/dist/esm/index.js +26 -23
- package/dist/esm/index.js.map +3 -3
- package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
- package/dist/types/ari-client/websocketClient.d.ts +1 -0
- package/dist/types/ari-client/websocketClient.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -947,11 +947,16 @@ var ChannelInstance = class extends import_events.EventEmitter {
|
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
949
|
);
|
|
950
|
-
this.
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
950
|
+
this.once("ChannelDestroyed", () => {
|
|
951
|
+
console.log(
|
|
952
|
+
`Canal '${this.id}' destru\xEDdo. Removendo listeners associados.`
|
|
953
|
+
);
|
|
954
|
+
const wsClient2 = this.client.getWebSocketClients().get(this.app);
|
|
955
|
+
if (wsClient2) {
|
|
956
|
+
wsClient2.removeScopedChannelListeners(this.id, this.app);
|
|
957
|
+
} else {
|
|
958
|
+
console.warn(
|
|
959
|
+
`WebSocketClient n\xE3o encontrado para o app '${this.app}'.`
|
|
955
960
|
);
|
|
956
961
|
}
|
|
957
962
|
});
|
|
@@ -1983,25 +1988,22 @@ var WebSocketClient = class extends import_events3.EventEmitter {
|
|
|
1983
1988
|
const key = `${app}:${instanceId}`;
|
|
1984
1989
|
if (this.scopedListeners.has(key)) {
|
|
1985
1990
|
console.warn(
|
|
1986
|
-
`Listener escopado j\xE1 existe para '${key}'. Removendo antigo.`
|
|
1991
|
+
`Listener escopado j\xE1 existe para '${key}'. Removendo antigo antes de adicionar um novo.`
|
|
1987
1992
|
);
|
|
1988
|
-
|
|
1989
|
-
this.off("message", existingListener);
|
|
1990
|
-
this.scopedListeners.delete(key);
|
|
1993
|
+
this.removeScopedMessageListeners(instanceId, app);
|
|
1991
1994
|
}
|
|
1992
1995
|
const scopedListener = (data) => {
|
|
1993
1996
|
if (data.application === app && (data.type.startsWith("Channel") && "channel" in data && data.channel?.id === instanceId || data.type.startsWith("Playback") && "playbackId" in data && data.playbackId === instanceId)) {
|
|
1994
1997
|
callback(data);
|
|
1995
1998
|
}
|
|
1996
1999
|
};
|
|
1997
|
-
this.on("message", scopedListener);
|
|
1998
2000
|
this.scopedListeners.set(key, scopedListener);
|
|
2001
|
+
this.on("message", scopedListener);
|
|
1999
2002
|
console.log(
|
|
2000
2003
|
`Listener escopado adicionado para '${key}'. Total de listeners: ${this.listenerCount(
|
|
2001
2004
|
"message"
|
|
2002
2005
|
)}`
|
|
2003
2006
|
);
|
|
2004
|
-
this.listListeners("message");
|
|
2005
2007
|
}
|
|
2006
2008
|
/**
|
|
2007
2009
|
* Remove todos os listeners associados a uma instância específica.
|
|
@@ -2011,19 +2013,20 @@ var WebSocketClient = class extends import_events3.EventEmitter {
|
|
|
2011
2013
|
removeScopedMessageListeners(instanceId, app) {
|
|
2012
2014
|
const key = `${app}:${instanceId}`;
|
|
2013
2015
|
const scopedListener = this.scopedListeners.get(key);
|
|
2014
|
-
if (
|
|
2015
|
-
console.
|
|
2016
|
-
|
|
2016
|
+
if (scopedListener) {
|
|
2017
|
+
console.log(`Removendo listener escopado para '${key}'.`);
|
|
2018
|
+
this.off("message", scopedListener);
|
|
2019
|
+
this.scopedListeners.delete(key);
|
|
2020
|
+
} else {
|
|
2021
|
+
console.warn(`Nenhum listener encontrado para '${key}'.`);
|
|
2017
2022
|
}
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
this.scopedListeners.
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
);
|
|
2026
|
-
this.listListeners("message");
|
|
2023
|
+
}
|
|
2024
|
+
removeAllScopedListeners() {
|
|
2025
|
+
this.scopedListeners.forEach((_listener, key) => {
|
|
2026
|
+
console.log(`Removendo listener escopado para '${key}' durante cleanup.`);
|
|
2027
|
+
this.removeScopedMessageListeners(key.split(":")[1], key.split(":")[0]);
|
|
2028
|
+
});
|
|
2029
|
+
console.log("Todos os listeners escopados foram removidos.");
|
|
2027
2030
|
}
|
|
2028
2031
|
removeScopedChannelListeners(instanceId, app) {
|
|
2029
2032
|
const key = `${app}:${instanceId}`;
|