@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/esm/index.js
CHANGED
|
@@ -925,11 +925,16 @@ var ChannelInstance = class extends EventEmitter {
|
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
927
|
);
|
|
928
|
-
this.
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
928
|
+
this.once("ChannelDestroyed", () => {
|
|
929
|
+
console.log(
|
|
930
|
+
`Canal '${this.id}' destru\xEDdo. Removendo listeners associados.`
|
|
931
|
+
);
|
|
932
|
+
const wsClient2 = this.client.getWebSocketClients().get(this.app);
|
|
933
|
+
if (wsClient2) {
|
|
934
|
+
wsClient2.removeScopedChannelListeners(this.id, this.app);
|
|
935
|
+
} else {
|
|
936
|
+
console.warn(
|
|
937
|
+
`WebSocketClient n\xE3o encontrado para o app '${this.app}'.`
|
|
933
938
|
);
|
|
934
939
|
}
|
|
935
940
|
});
|
|
@@ -1961,25 +1966,22 @@ var WebSocketClient = class extends EventEmitter3 {
|
|
|
1961
1966
|
const key = `${app}:${instanceId}`;
|
|
1962
1967
|
if (this.scopedListeners.has(key)) {
|
|
1963
1968
|
console.warn(
|
|
1964
|
-
`Listener escopado j\xE1 existe para '${key}'. Removendo antigo.`
|
|
1969
|
+
`Listener escopado j\xE1 existe para '${key}'. Removendo antigo antes de adicionar um novo.`
|
|
1965
1970
|
);
|
|
1966
|
-
|
|
1967
|
-
this.off("message", existingListener);
|
|
1968
|
-
this.scopedListeners.delete(key);
|
|
1971
|
+
this.removeScopedMessageListeners(instanceId, app);
|
|
1969
1972
|
}
|
|
1970
1973
|
const scopedListener = (data) => {
|
|
1971
1974
|
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)) {
|
|
1972
1975
|
callback(data);
|
|
1973
1976
|
}
|
|
1974
1977
|
};
|
|
1975
|
-
this.on("message", scopedListener);
|
|
1976
1978
|
this.scopedListeners.set(key, scopedListener);
|
|
1979
|
+
this.on("message", scopedListener);
|
|
1977
1980
|
console.log(
|
|
1978
1981
|
`Listener escopado adicionado para '${key}'. Total de listeners: ${this.listenerCount(
|
|
1979
1982
|
"message"
|
|
1980
1983
|
)}`
|
|
1981
1984
|
);
|
|
1982
|
-
this.listListeners("message");
|
|
1983
1985
|
}
|
|
1984
1986
|
/**
|
|
1985
1987
|
* Remove todos os listeners associados a uma instância específica.
|
|
@@ -1989,19 +1991,20 @@ var WebSocketClient = class extends EventEmitter3 {
|
|
|
1989
1991
|
removeScopedMessageListeners(instanceId, app) {
|
|
1990
1992
|
const key = `${app}:${instanceId}`;
|
|
1991
1993
|
const scopedListener = this.scopedListeners.get(key);
|
|
1992
|
-
if (
|
|
1993
|
-
console.
|
|
1994
|
-
|
|
1994
|
+
if (scopedListener) {
|
|
1995
|
+
console.log(`Removendo listener escopado para '${key}'.`);
|
|
1996
|
+
this.off("message", scopedListener);
|
|
1997
|
+
this.scopedListeners.delete(key);
|
|
1998
|
+
} else {
|
|
1999
|
+
console.warn(`Nenhum listener encontrado para '${key}'.`);
|
|
1995
2000
|
}
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
this.scopedListeners.
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
);
|
|
2004
|
-
this.listListeners("message");
|
|
2001
|
+
}
|
|
2002
|
+
removeAllScopedListeners() {
|
|
2003
|
+
this.scopedListeners.forEach((_listener, key) => {
|
|
2004
|
+
console.log(`Removendo listener escopado para '${key}' durante cleanup.`);
|
|
2005
|
+
this.removeScopedMessageListeners(key.split(":")[1], key.split(":")[0]);
|
|
2006
|
+
});
|
|
2007
|
+
console.log("Todos os listeners escopados foram removidos.");
|
|
2005
2008
|
}
|
|
2006
2009
|
removeScopedChannelListeners(instanceId, app) {
|
|
2007
2010
|
const key = `${app}:${instanceId}`;
|