@ipcom/asterisk-ari 0.0.38 → 0.0.39
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
|
@@ -1718,7 +1718,7 @@ var AriClient = class {
|
|
|
1718
1718
|
async connectWebSocket(app, subscribedEvents) {
|
|
1719
1719
|
if (!app) {
|
|
1720
1720
|
throw new Error(
|
|
1721
|
-
"
|
|
1721
|
+
"O par\xE2metro 'app' \xE9 obrigat\xF3rio para conectar ao WebSocket."
|
|
1722
1722
|
);
|
|
1723
1723
|
}
|
|
1724
1724
|
if (this.webSocketReady) {
|
|
@@ -1729,16 +1729,14 @@ var AriClient = class {
|
|
|
1729
1729
|
try {
|
|
1730
1730
|
if (this.isReconnecting) {
|
|
1731
1731
|
console.warn(
|
|
1732
|
-
"
|
|
1732
|
+
"J\xE1 est\xE1 tentando reconectar. Ignorando esta tentativa."
|
|
1733
1733
|
);
|
|
1734
1734
|
return;
|
|
1735
1735
|
}
|
|
1736
1736
|
this.isReconnecting = true;
|
|
1737
1737
|
const eventsParam = subscribedEvents && subscribedEvents.length > 0 ? `&event=${subscribedEvents.join(",")}` : "&subscribeAll=true";
|
|
1738
1738
|
const protocol = this.config.secure ? "wss" : "ws";
|
|
1739
|
-
const wsUrl = `${protocol}://${encodeURIComponent(
|
|
1740
|
-
this.config.username
|
|
1741
|
-
)}:${encodeURIComponent(this.config.password)}@${this.config.host}:${this.config.port}/ari/events?app=${app}${eventsParam}`;
|
|
1739
|
+
const wsUrl = `${protocol}://${encodeURIComponent(this.config.username)}:${encodeURIComponent(this.config.password)}@${this.config.host}:${this.config.port}/ari/events?app=${app}${eventsParam}`;
|
|
1742
1740
|
const backoffOptions = {
|
|
1743
1741
|
delayFirstAttempt: false,
|
|
1744
1742
|
startingDelay: 1e3,
|
|
@@ -1766,6 +1764,7 @@ var AriClient = class {
|
|
|
1766
1764
|
console.log(`WebSocket conectado para o app: ${app}`);
|
|
1767
1765
|
await this.ensureAppRegistered(app);
|
|
1768
1766
|
this.processPendingListeners();
|
|
1767
|
+
this.isWebSocketConnectedFlag = true;
|
|
1769
1768
|
}, backoffOptions);
|
|
1770
1769
|
resolve();
|
|
1771
1770
|
} catch (err) {
|
|
@@ -1790,6 +1789,7 @@ var AriClient = class {
|
|
|
1790
1789
|
`WebSocket client para o app '${app}' n\xE3o est\xE1 conectado.`
|
|
1791
1790
|
);
|
|
1792
1791
|
}
|
|
1792
|
+
console.log(`[${app}] Registrando eventos do WebSocket...`);
|
|
1793
1793
|
const eventHandlers = {
|
|
1794
1794
|
PlaybackFinished: (data) => {
|
|
1795
1795
|
if ("playbackId" in data) {
|
|
@@ -1817,20 +1817,6 @@ var AriClient = class {
|
|
|
1817
1817
|
this.channels.emitChannelEvent("ChannelDtmfReceived", data);
|
|
1818
1818
|
}
|
|
1819
1819
|
this.emitGlobalEvent(data);
|
|
1820
|
-
},
|
|
1821
|
-
// Adicione mais eventos conforme necessário
|
|
1822
|
-
EndpointStateChange: (data) => {
|
|
1823
|
-
if ("endpoint" in data) {
|
|
1824
|
-
console.log(`[${app}] Estado do endpoint alterado:`, data.endpoint);
|
|
1825
|
-
}
|
|
1826
|
-
this.emitGlobalEvent(data);
|
|
1827
|
-
},
|
|
1828
|
-
ChannelHangupRequest: (data) => {
|
|
1829
|
-
if ("channel" in data) {
|
|
1830
|
-
console.log(`[${app}] Requisi\xE7\xE3o de hangup no canal:`, data.channel);
|
|
1831
|
-
this.channels.emitChannelEvent("ChannelHangupRequest", data);
|
|
1832
|
-
}
|
|
1833
|
-
this.emitGlobalEvent(data);
|
|
1834
1820
|
}
|
|
1835
1821
|
};
|
|
1836
1822
|
for (const [eventType, handler] of Object.entries(eventHandlers)) {
|