@ipcom/asterisk-ari 0.0.150 → 0.0.152
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 +17 -61
- package/dist/cjs/index.cjs.map +2 -2
- package/dist/esm/index.js +17 -61
- package/dist/esm/index.js.map +2 -2
- package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
- package/dist/types/ari-client/websocketClient.d.ts +0 -23
- package/dist/types/ari-client/websocketClient.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1202,45 +1202,24 @@ var ChannelInstance = class {
|
|
|
1202
1202
|
* Plays media on the channel
|
|
1203
1203
|
*/
|
|
1204
1204
|
async play(options, playbackId) {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
this.channelData = await this.getDetails();
|
|
1212
|
-
}
|
|
1213
|
-
const playback = this.client.Playback(playbackId || v4_default());
|
|
1214
|
-
playback.once("PlaybackStarted", (event) => {
|
|
1215
|
-
if ("playback" in event) {
|
|
1216
|
-
console.log("Playback realmente iniciado:", playback.id);
|
|
1217
|
-
resolve(playback);
|
|
1218
|
-
}
|
|
1219
|
-
});
|
|
1220
|
-
playback.once("PlaybackFinished", async (event) => {
|
|
1221
|
-
if ("playback" in event && event.playback) {
|
|
1222
|
-
const playbackState = event.playback.state;
|
|
1223
|
-
if (playbackState === "failed") {
|
|
1224
|
-
console.error("Playback falhou:", {
|
|
1225
|
-
playbackId: playback.id,
|
|
1226
|
-
channelId: this.id,
|
|
1227
|
-
state: playbackState
|
|
1228
|
-
});
|
|
1229
|
-
reject(new Error(`Playback failed: ${playbackState}`));
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
});
|
|
1233
|
-
await this.baseClient.post(
|
|
1234
|
-
`/channels/${this.id}/play/${playback.id}`,
|
|
1235
|
-
options
|
|
1236
|
-
);
|
|
1237
|
-
setTimeout(() => {
|
|
1238
|
-
reject(new Error("Playback timeout - n\xE3o recebeu evento de in\xEDcio"));
|
|
1239
|
-
}, 5e3);
|
|
1240
|
-
} catch (error) {
|
|
1241
|
-
reject(error);
|
|
1205
|
+
if (!options.media) {
|
|
1206
|
+
throw new Error("Media URL is required");
|
|
1207
|
+
}
|
|
1208
|
+
try {
|
|
1209
|
+
if (!this.channelData) {
|
|
1210
|
+
this.channelData = await this.getDetails();
|
|
1242
1211
|
}
|
|
1243
|
-
|
|
1212
|
+
const playback = this.client.Playback(playbackId || v4_default());
|
|
1213
|
+
await this.baseClient.post(
|
|
1214
|
+
`/channels/${this.id}/play/${playback.id}`,
|
|
1215
|
+
options
|
|
1216
|
+
);
|
|
1217
|
+
return playback;
|
|
1218
|
+
} catch (error) {
|
|
1219
|
+
const message = getErrorMessage(error);
|
|
1220
|
+
console.error(`Error playing media on channel ${this.id}:`, message);
|
|
1221
|
+
throw new Error(`Failed to play media: ${message}`);
|
|
1222
|
+
}
|
|
1244
1223
|
}
|
|
1245
1224
|
/**
|
|
1246
1225
|
* Gets the current channel details
|
|
@@ -2573,32 +2552,9 @@ var WebSocketClient = class extends import_events3.EventEmitter {
|
|
|
2573
2552
|
);
|
|
2574
2553
|
}
|
|
2575
2554
|
}
|
|
2576
|
-
/**
|
|
2577
|
-
* Checks if the WebSocket connection is currently open and active.
|
|
2578
|
-
*
|
|
2579
|
-
* This method examines the readyState of the WebSocket instance to determine
|
|
2580
|
-
* if the connection is established and ready for communication.
|
|
2581
|
-
*
|
|
2582
|
-
* @returns {boolean} True if the WebSocket connection is open and ready,
|
|
2583
|
-
* false otherwise.
|
|
2584
|
-
*/
|
|
2585
2555
|
isConnected() {
|
|
2586
2556
|
return this.ws?.readyState === import_ws.default.OPEN;
|
|
2587
2557
|
}
|
|
2588
|
-
/**
|
|
2589
|
-
* Retrieves the current state of the WebSocket connection.
|
|
2590
|
-
*
|
|
2591
|
-
* This method returns the readyState of the WebSocket instance, which
|
|
2592
|
-
* indicates the current state of the connection. If no WebSocket instance
|
|
2593
|
-
* exists, it returns the CLOSED state.
|
|
2594
|
-
*
|
|
2595
|
-
* @returns {number} The current state of the WebSocket connection.
|
|
2596
|
-
* Possible values are:
|
|
2597
|
-
* - WebSocket.CONNECTING (0): The connection is not yet open.
|
|
2598
|
-
* - WebSocket.OPEN (1): The connection is open and ready to communicate.
|
|
2599
|
-
* - WebSocket.CLOSING (2): The connection is in the process of closing.
|
|
2600
|
-
* - WebSocket.CLOSED (3): The connection is closed or couldn't be opened.
|
|
2601
|
-
*/
|
|
2602
2558
|
getState() {
|
|
2603
2559
|
return this.ws?.readyState ?? import_ws.default.CLOSED;
|
|
2604
2560
|
}
|