@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/cjs/index.cjs
CHANGED
|
@@ -1740,7 +1740,7 @@ var AriClient = class {
|
|
|
1740
1740
|
async connectWebSocket(app, subscribedEvents) {
|
|
1741
1741
|
if (!app) {
|
|
1742
1742
|
throw new Error(
|
|
1743
|
-
"
|
|
1743
|
+
"O par\xE2metro 'app' \xE9 obrigat\xF3rio para conectar ao WebSocket."
|
|
1744
1744
|
);
|
|
1745
1745
|
}
|
|
1746
1746
|
if (this.webSocketReady) {
|
|
@@ -1751,16 +1751,14 @@ var AriClient = class {
|
|
|
1751
1751
|
try {
|
|
1752
1752
|
if (this.isReconnecting) {
|
|
1753
1753
|
console.warn(
|
|
1754
|
-
"
|
|
1754
|
+
"J\xE1 est\xE1 tentando reconectar. Ignorando esta tentativa."
|
|
1755
1755
|
);
|
|
1756
1756
|
return;
|
|
1757
1757
|
}
|
|
1758
1758
|
this.isReconnecting = true;
|
|
1759
1759
|
const eventsParam = subscribedEvents && subscribedEvents.length > 0 ? `&event=${subscribedEvents.join(",")}` : "&subscribeAll=true";
|
|
1760
1760
|
const protocol = this.config.secure ? "wss" : "ws";
|
|
1761
|
-
const wsUrl = `${protocol}://${encodeURIComponent(
|
|
1762
|
-
this.config.username
|
|
1763
|
-
)}:${encodeURIComponent(this.config.password)}@${this.config.host}:${this.config.port}/ari/events?app=${app}${eventsParam}`;
|
|
1761
|
+
const wsUrl = `${protocol}://${encodeURIComponent(this.config.username)}:${encodeURIComponent(this.config.password)}@${this.config.host}:${this.config.port}/ari/events?app=${app}${eventsParam}`;
|
|
1764
1762
|
const backoffOptions = {
|
|
1765
1763
|
delayFirstAttempt: false,
|
|
1766
1764
|
startingDelay: 1e3,
|
|
@@ -1788,6 +1786,7 @@ var AriClient = class {
|
|
|
1788
1786
|
console.log(`WebSocket conectado para o app: ${app}`);
|
|
1789
1787
|
await this.ensureAppRegistered(app);
|
|
1790
1788
|
this.processPendingListeners();
|
|
1789
|
+
this.isWebSocketConnectedFlag = true;
|
|
1791
1790
|
}, backoffOptions);
|
|
1792
1791
|
resolve();
|
|
1793
1792
|
} catch (err) {
|
|
@@ -1812,6 +1811,7 @@ var AriClient = class {
|
|
|
1812
1811
|
`WebSocket client para o app '${app}' n\xE3o est\xE1 conectado.`
|
|
1813
1812
|
);
|
|
1814
1813
|
}
|
|
1814
|
+
console.log(`[${app}] Registrando eventos do WebSocket...`);
|
|
1815
1815
|
const eventHandlers = {
|
|
1816
1816
|
PlaybackFinished: (data) => {
|
|
1817
1817
|
if ("playbackId" in data) {
|
|
@@ -1839,20 +1839,6 @@ var AriClient = class {
|
|
|
1839
1839
|
this.channels.emitChannelEvent("ChannelDtmfReceived", data);
|
|
1840
1840
|
}
|
|
1841
1841
|
this.emitGlobalEvent(data);
|
|
1842
|
-
},
|
|
1843
|
-
// Adicione mais eventos conforme necessário
|
|
1844
|
-
EndpointStateChange: (data) => {
|
|
1845
|
-
if ("endpoint" in data) {
|
|
1846
|
-
console.log(`[${app}] Estado do endpoint alterado:`, data.endpoint);
|
|
1847
|
-
}
|
|
1848
|
-
this.emitGlobalEvent(data);
|
|
1849
|
-
},
|
|
1850
|
-
ChannelHangupRequest: (data) => {
|
|
1851
|
-
if ("channel" in data) {
|
|
1852
|
-
console.log(`[${app}] Requisi\xE7\xE3o de hangup no canal:`, data.channel);
|
|
1853
|
-
this.channels.emitChannelEvent("ChannelHangupRequest", data);
|
|
1854
|
-
}
|
|
1855
|
-
this.emitGlobalEvent(data);
|
|
1856
1842
|
}
|
|
1857
1843
|
};
|
|
1858
1844
|
for (const [eventType, handler] of Object.entries(eventHandlers)) {
|