@ipcom/asterisk-ari 0.0.33 → 0.0.34
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
|
@@ -1699,6 +1699,7 @@ var AriClient = class {
|
|
|
1699
1699
|
isReconnecting = false;
|
|
1700
1700
|
eventEmitter = new import_events4.EventEmitter();
|
|
1701
1701
|
wsConnections = /* @__PURE__ */ new Map();
|
|
1702
|
+
isWebSocketConnectedFlag = false;
|
|
1702
1703
|
channels;
|
|
1703
1704
|
endpoints;
|
|
1704
1705
|
applications;
|
|
@@ -1750,17 +1751,21 @@ var AriClient = class {
|
|
|
1750
1751
|
};
|
|
1751
1752
|
try {
|
|
1752
1753
|
await (0, import_exponential_backoff.backOff)(async () => {
|
|
1753
|
-
|
|
1754
|
-
|
|
1754
|
+
if (!this.wsClient) {
|
|
1755
|
+
throw new Error("WebSocketClient instance is null.");
|
|
1756
|
+
}
|
|
1757
|
+
await this.wsClient.connect();
|
|
1758
|
+
this.isWebSocketConnectedFlag = true;
|
|
1759
|
+
this.integrateWebSocketEvents(app, this.wsClient);
|
|
1755
1760
|
console.log(`WebSocket conectado para o app: ${app}`);
|
|
1756
1761
|
await this.ensureAppRegistered(app);
|
|
1757
1762
|
}, backoffOptions);
|
|
1758
1763
|
} catch (err) {
|
|
1764
|
+
this.isWebSocketConnectedFlag = false;
|
|
1759
1765
|
console.error(
|
|
1760
|
-
|
|
1766
|
+
"N\xE3o foi poss\xEDvel conectar ao WebSocket ap\xF3s m\xFAltiplas tentativas:",
|
|
1761
1767
|
err
|
|
1762
1768
|
);
|
|
1763
|
-
this.wsConnections.delete(app);
|
|
1764
1769
|
throw err;
|
|
1765
1770
|
}
|
|
1766
1771
|
}
|
|
@@ -1921,9 +1926,12 @@ var AriClient = class {
|
|
|
1921
1926
|
* @throws {Error} Throws an error if the WebSocket client is not connected when this method is called.
|
|
1922
1927
|
* @returns {void} This function doesn't return a value.
|
|
1923
1928
|
*/
|
|
1924
|
-
onWebSocketEvent(event, callback) {
|
|
1929
|
+
async onWebSocketEvent(event, callback) {
|
|
1930
|
+
if (!this.isWebSocketConnectedFlag) {
|
|
1931
|
+
throw new Error("WebSocket ainda n\xE3o est\xE1 conectado.");
|
|
1932
|
+
}
|
|
1925
1933
|
if (!this.wsClient) {
|
|
1926
|
-
throw new Error("WebSocket n\xE3o est\xE1
|
|
1934
|
+
throw new Error("WebSocket n\xE3o est\xE1 configurado.");
|
|
1927
1935
|
}
|
|
1928
1936
|
this.wsClient.on(event, callback);
|
|
1929
1937
|
}
|