@ipcom/asterisk-ari 0.0.100 → 0.0.102
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
|
@@ -1549,7 +1549,22 @@ var PlaybackInstance = class extends EventEmitter3 {
|
|
|
1549
1549
|
if (!this.id) {
|
|
1550
1550
|
throw new Error("Nenhum playback associado para encerrar.");
|
|
1551
1551
|
}
|
|
1552
|
-
|
|
1552
|
+
try {
|
|
1553
|
+
await this.baseClient.delete(`/playbacks/${this.id}`);
|
|
1554
|
+
console.log(`Playback '${this.id}' parado com sucesso.`);
|
|
1555
|
+
} catch (error) {
|
|
1556
|
+
if (error.response?.status === 404) {
|
|
1557
|
+
console.warn(
|
|
1558
|
+
`Playback '${this.id}' n\xE3o encontrado para encerrar (404).`
|
|
1559
|
+
);
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
console.error(
|
|
1563
|
+
`Erro ao encerrar o playback '${this.id}':`,
|
|
1564
|
+
error.message || error
|
|
1565
|
+
);
|
|
1566
|
+
throw error;
|
|
1567
|
+
}
|
|
1553
1568
|
}
|
|
1554
1569
|
};
|
|
1555
1570
|
var Playbacks = class extends EventEmitter3 {
|
|
@@ -1605,7 +1620,22 @@ var Playbacks = class extends EventEmitter3 {
|
|
|
1605
1620
|
* @returns A promise that resolves when the playback is successfully stopped.
|
|
1606
1621
|
*/
|
|
1607
1622
|
async stop(playbackId) {
|
|
1608
|
-
|
|
1623
|
+
try {
|
|
1624
|
+
await this.baseClient.delete(`/playbacks/${playbackId}`);
|
|
1625
|
+
console.log(`Playback '${playbackId}' parado com sucesso.`);
|
|
1626
|
+
} catch (error) {
|
|
1627
|
+
if (error.response?.status === 404) {
|
|
1628
|
+
console.warn(
|
|
1629
|
+
`Playback '${playbackId}' n\xE3o encontrado para encerrar (404).`
|
|
1630
|
+
);
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
console.error(
|
|
1634
|
+
`Erro ao encerrar o playback '${playbackId}':`,
|
|
1635
|
+
error.message || error
|
|
1636
|
+
);
|
|
1637
|
+
throw error;
|
|
1638
|
+
}
|
|
1609
1639
|
}
|
|
1610
1640
|
/**
|
|
1611
1641
|
* Registers a listener for playback events.
|
|
@@ -1814,10 +1844,15 @@ var WebSocketClient = class extends EventEmitter4 {
|
|
|
1814
1844
|
* @param callback - Função de callback para o evento.
|
|
1815
1845
|
*/
|
|
1816
1846
|
addScopedMessageListener(instanceId, callback) {
|
|
1847
|
+
if (this.scopedListeners.has(instanceId)) {
|
|
1848
|
+
console.warn(
|
|
1849
|
+
`Listener escopado para a inst\xE2ncia '${instanceId}' j\xE1 existe. Ignorando duplica\xE7\xE3o.`
|
|
1850
|
+
);
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1817
1853
|
const scopedListener = (data) => {
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
data.type.startsWith("Playback") && "playbackId" in data && data.playbackId === instanceId) {
|
|
1854
|
+
if (data.type.startsWith("Channel") && "channel" in data && data.channel?.id === instanceId || data.type.startsWith("Playback") && "playbackId" in data && data.playbackId === instanceId) {
|
|
1855
|
+
console.log(data);
|
|
1821
1856
|
console.log(
|
|
1822
1857
|
`Listener escopado para a inst\xE2ncia '${instanceId}' ativado.`
|
|
1823
1858
|
);
|
|
@@ -1826,6 +1861,11 @@ var WebSocketClient = class extends EventEmitter4 {
|
|
|
1826
1861
|
};
|
|
1827
1862
|
this.scopedListeners.set(instanceId, scopedListener);
|
|
1828
1863
|
this.on("message", scopedListener);
|
|
1864
|
+
console.log(
|
|
1865
|
+
`Listener escopado adicionado para a inst\xE2ncia '${instanceId}'. Total de listeners: ${this.listenerCount(
|
|
1866
|
+
"message"
|
|
1867
|
+
)}`
|
|
1868
|
+
);
|
|
1829
1869
|
}
|
|
1830
1870
|
/**
|
|
1831
1871
|
* Remove todos os listeners associados a uma instância específica.
|
|
@@ -1842,7 +1882,11 @@ var WebSocketClient = class extends EventEmitter4 {
|
|
|
1842
1882
|
if (scopedListener) {
|
|
1843
1883
|
this.off("message", scopedListener);
|
|
1844
1884
|
this.scopedListeners.delete(instanceId);
|
|
1845
|
-
console.log(
|
|
1885
|
+
console.log(
|
|
1886
|
+
`Listeners removidos para a inst\xE2ncia '${instanceId}'. Total de listeners restantes: ${this.listenerCount(
|
|
1887
|
+
"message"
|
|
1888
|
+
)}`
|
|
1889
|
+
);
|
|
1846
1890
|
}
|
|
1847
1891
|
}
|
|
1848
1892
|
/**
|