@ipcom/asterisk-ari 0.0.25 → 0.0.27

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
@@ -572,6 +572,7 @@ var require_backoff = __commonJS({
572
572
 
573
573
  // src/ari-client/ariClient.ts
574
574
  var import_exponential_backoff = __toESM(require_backoff(), 1);
575
+ import { EventEmitter as EventEmitter4 } from "events";
575
576
 
576
577
  // src/ari-client/baseClient.ts
577
578
  import axios from "axios";
@@ -835,16 +836,66 @@ var Bridges = class {
835
836
  };
836
837
 
837
838
  // src/ari-client/resources/channels.ts
839
+ import { EventEmitter } from "events";
838
840
  function toQueryParams2(options) {
839
841
  return new URLSearchParams(
840
842
  Object.entries(options).filter(([, value]) => value !== void 0).map(([key, value]) => [key, value])
841
843
  // Garante que value é string
842
844
  ).toString();
843
845
  }
844
- var Channels = class {
846
+ var Channels = class extends EventEmitter {
845
847
  constructor(client) {
848
+ super();
846
849
  this.client = client;
847
850
  }
851
+ /**
852
+ * Emits a specific channel-related event.
853
+ *
854
+ * This method is called by the WebSocket client to notify about channel-related events.
855
+ * It will emit events like "ChannelDtmfReceived" to registered listeners.
856
+ *
857
+ * @param eventType - The type of WebSocket event to emit.
858
+ * @param data - The data associated with the event.
859
+ */
860
+ emitChannelEvent(eventType, data) {
861
+ if ("channel" in data) {
862
+ const channelId = data.channel?.id;
863
+ if (channelId) {
864
+ this.emit(`${eventType}:${channelId}`, data);
865
+ }
866
+ }
867
+ this.emit(eventType, data);
868
+ }
869
+ /**
870
+ * Registers a listener for a specific channel-related event.
871
+ *
872
+ * @param eventType - The type of WebSocket event to listen for.
873
+ * @param channelId - The ID of the channel to listen for.
874
+ * @param callback - The callback function to execute when the event occurs.
875
+ */
876
+ registerChannelListener(eventType, channelId, callback) {
877
+ this.on(`${eventType}:${channelId}`, callback);
878
+ }
879
+ /**
880
+ * Unregisters a listener for a specific channel-related event.
881
+ *
882
+ * @param eventType - The type of WebSocket event to stop listening for.
883
+ * @param channelId - The ID of the channel to stop listening for.
884
+ * @param callback - The callback function to remove.
885
+ */
886
+ unregisterChannelListener(eventType, channelId, callback) {
887
+ this.off(`${eventType}:${channelId}`, callback);
888
+ }
889
+ /**
890
+ * Checks if a listener is already registered for a specific channel event.
891
+ *
892
+ * @param eventType - The type of event to check.
893
+ * @param channelId - The channel ID associated with the listener.
894
+ * @returns True if a listener is already registered, false otherwise.
895
+ */
896
+ isChannelListenerRegistered(eventType, channelId) {
897
+ return this.listenerCount(`${eventType}:${channelId}`) > 0;
898
+ }
848
899
  /**
849
900
  * Lists all active channels.
850
901
  */
@@ -1181,8 +1232,10 @@ var Endpoints = class {
1181
1232
  };
1182
1233
 
1183
1234
  // src/ari-client/resources/playbacks.ts
1184
- var Playbacks = class {
1235
+ import { EventEmitter as EventEmitter2 } from "events";
1236
+ var Playbacks = class extends EventEmitter2 {
1185
1237
  constructor(client) {
1238
+ super();
1186
1239
  this.client = client;
1187
1240
  }
1188
1241
  /**
@@ -1221,6 +1274,50 @@ var Playbacks = class {
1221
1274
  async stop(playbackId) {
1222
1275
  await this.client.post(`/playbacks/${playbackId}/stop`);
1223
1276
  }
1277
+ /**
1278
+ * Registers a listener for playback events.
1279
+ * The listener is triggered for events such as "PlaybackFinished".
1280
+ *
1281
+ * @param eventType - The type of event to listen for.
1282
+ * @param playbackId - The ID of the playback to associate with this listener.
1283
+ * @param callback - The callback function to execute when the event occurs.
1284
+ */
1285
+ registerListener(eventType, playbackId, callback) {
1286
+ this.on(`${eventType}:${playbackId}`, callback);
1287
+ }
1288
+ /**
1289
+ * Unregisters a listener for playback events.
1290
+ *
1291
+ * @param eventType - The type of event to stop listening for.
1292
+ * @param playbackId - The ID of the playback associated with the listener.
1293
+ * @param callback - The callback function to remove.
1294
+ */
1295
+ unregisterListener(eventType, playbackId, callback) {
1296
+ this.off(`${eventType}:${playbackId}`, callback);
1297
+ }
1298
+ /**
1299
+ * Checks if a listener is already registered for a specific event and playback.
1300
+ *
1301
+ * @param eventType - The type of event to check.
1302
+ * @param playbackId - The playback ID associated with the listener.
1303
+ * @returns True if a listener is already registered, false otherwise.
1304
+ */
1305
+ isListenerRegistered(eventType, playbackId) {
1306
+ return this.listenerCount(`${eventType}:${playbackId}`) > 0;
1307
+ }
1308
+ /**
1309
+ * Emits playback events received via WebSocket.
1310
+ * This method should be called by the WebSocket client when playback events occur.
1311
+ *
1312
+ * @param eventType - The type of the WebSocket event.
1313
+ * @param data - The data associated with the event.
1314
+ */
1315
+ emitPlaybackEvent(eventType, data) {
1316
+ if ("playbackId" in data) {
1317
+ this.emit(`${eventType}:${data.playbackId}`, data);
1318
+ }
1319
+ this.emit(eventType, data);
1320
+ }
1224
1321
  };
1225
1322
 
1226
1323
  // src/ari-client/resources/sounds.ts
@@ -1255,16 +1352,25 @@ var Sounds = class {
1255
1352
  };
1256
1353
 
1257
1354
  // src/ari-client/websocketClient.ts
1355
+ import { EventEmitter as EventEmitter3 } from "events";
1258
1356
  import WebSocket from "ws";
1259
- var WebSocketClient = class {
1260
- // Para evitar reconexões paralelas
1357
+ var WebSocketClient = class extends EventEmitter3 {
1358
+ /**
1359
+ * Creates a new WebSocketClient instance.
1360
+ * @param url - The WebSocket server URL to connect to.
1361
+ */
1261
1362
  constructor(url) {
1363
+ super();
1262
1364
  this.url = url;
1263
1365
  }
1264
1366
  ws = null;
1265
1367
  isClosedManually = false;
1266
- // Para evitar reconexões automáticas quando fechado manualmente
1267
1368
  isReconnecting = false;
1369
+ /**
1370
+ * Establishes a connection to the WebSocket server.
1371
+ * @returns A Promise that resolves when the connection is established, or rejects if an error occurs.
1372
+ * @throws Will throw an error if the connection fails.
1373
+ */
1268
1374
  async connect() {
1269
1375
  if (this.isReconnecting) return;
1270
1376
  return new Promise((resolve, reject) => {
@@ -1282,47 +1388,70 @@ var WebSocketClient = class {
1282
1388
  this.ws.on("close", (code, reason) => {
1283
1389
  console.warn(`WebSocket desconectado: ${code} - ${reason}`);
1284
1390
  this.isReconnecting = false;
1391
+ this.emit("close", { code, reason });
1392
+ });
1393
+ this.ws.on("message", (rawData) => {
1394
+ this.handleMessage(rawData);
1285
1395
  });
1286
1396
  });
1287
1397
  }
1288
- async reconnect() {
1289
- if (this.isClosedManually || this.isReconnecting) return;
1290
- console.log("Tentando reconectar ao WebSocket...");
1291
- this.isReconnecting = true;
1292
- try {
1293
- await this.connect();
1294
- console.log("Reconex\xE3o bem-sucedida.");
1295
- } catch (err) {
1296
- console.error("Erro ao tentar reconectar:", err);
1297
- } finally {
1298
- this.isReconnecting = false;
1299
- }
1300
- }
1398
+ /**
1399
+ * Checks if the WebSocket connection is currently open.
1400
+ * @returns True if the connection is open, false otherwise.
1401
+ */
1301
1402
  isConnected() {
1302
1403
  return this.ws?.readyState === WebSocket.OPEN;
1303
1404
  }
1405
+ /**
1406
+ * Adds a listener for WebSocket events.
1407
+ * @param event - The event type to listen for.
1408
+ * @param callback - The function to call when the event occurs.
1409
+ * @returns The WebSocketClient instance for chaining.
1410
+ */
1304
1411
  on(event, callback) {
1305
- if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
1306
- throw new Error("WebSocket n\xE3o est\xE1 conectado.");
1307
- }
1308
- if (event === "message") {
1309
- this.ws.on(event, (rawData) => {
1310
- try {
1311
- const decodedData = JSON.parse(rawData.toString());
1312
- if (decodedData?.type) {
1313
- const matchedEvent = decodedData;
1314
- callback(matchedEvent);
1315
- } else {
1316
- console.warn("Mensagem sem tipo:", decodedData);
1317
- }
1318
- } catch (err) {
1319
- console.error("Erro ao decodificar mensagem do WebSocket:", err);
1320
- }
1321
- });
1322
- } else {
1323
- this.ws.on(event, callback);
1412
+ super.on(event, callback);
1413
+ return this;
1414
+ }
1415
+ /**
1416
+ * Removes a specific listener from a WebSocket event.
1417
+ * @param event - The event type to remove the listener from.
1418
+ * @param callback - The function to remove from the event listeners.
1419
+ * @returns The WebSocketClient instance for chaining.
1420
+ */
1421
+ off(event, callback) {
1422
+ super.off(event, callback);
1423
+ return this;
1424
+ }
1425
+ /**
1426
+ * Removes all listeners for a specific event, or all events if no event is specified.
1427
+ * @param event - Optional. The event to remove all listeners from.
1428
+ * @returns The WebSocketClient instance for chaining.
1429
+ */
1430
+ removeAllListeners(event) {
1431
+ super.removeAllListeners(event);
1432
+ return this;
1433
+ }
1434
+ /**
1435
+ * Handles incoming WebSocket messages.
1436
+ * @param rawData - The raw data received from the WebSocket.
1437
+ */
1438
+ handleMessage(rawData) {
1439
+ try {
1440
+ const decodedData = JSON.parse(rawData.toString());
1441
+ if (decodedData?.type) {
1442
+ this.emit(decodedData.type, decodedData);
1443
+ } else {
1444
+ console.warn("Mensagem recebida sem tipo:", decodedData);
1445
+ }
1446
+ } catch (err) {
1447
+ console.error("Erro ao decodificar mensagem do WebSocket:", err);
1324
1448
  }
1325
1449
  }
1450
+ /**
1451
+ * Sends data through the WebSocket connection.
1452
+ * @param data - The data to send.
1453
+ * @throws Will throw an error if the WebSocket is not connected.
1454
+ */
1326
1455
  send(data) {
1327
1456
  if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
1328
1457
  throw new Error("WebSocket n\xE3o est\xE1 conectado.");
@@ -1333,6 +1462,9 @@ var WebSocketClient = class {
1333
1462
  }
1334
1463
  });
1335
1464
  }
1465
+ /**
1466
+ * Closes the WebSocket connection manually.
1467
+ */
1336
1468
  close() {
1337
1469
  if (this.ws) {
1338
1470
  this.isClosedManually = true;
@@ -1361,6 +1493,7 @@ var AriClient = class {
1361
1493
  wsClient = null;
1362
1494
  baseClient;
1363
1495
  isReconnecting = false;
1496
+ eventEmitter = new EventEmitter4();
1364
1497
  channels;
1365
1498
  endpoints;
1366
1499
  applications;
@@ -1370,10 +1503,14 @@ var AriClient = class {
1370
1503
  bridges;
1371
1504
  /**
1372
1505
  * Connects to the ARI WebSocket for a specific application.
1506
+ * This function establishes a WebSocket connection to the Asterisk ARI, sets up event listeners,
1507
+ * and ensures the application is registered. It uses an exponential backoff strategy for connection attempts.
1373
1508
  *
1374
- * @param app - The application name to connect to.
1375
- * @param subscribedEvents
1376
- * @returns {Promise<void>} Resolves when the WebSocket connects successfully.
1509
+ * @param app - The name of the application to connect to. This is required and used to identify the application in ARI.
1510
+ * @param subscribedEvents - Optional array of WebSocketEventType to subscribe to specific events.
1511
+ * If not provided or empty, it subscribes to all events.
1512
+ * @returns A Promise that resolves when the WebSocket connection is successfully established and the application is registered.
1513
+ * @throws Error if the 'app' parameter is not provided, or if connection attempts fail after multiple retries.
1377
1514
  */
1378
1515
  async connectWebSocket(app, subscribedEvents) {
1379
1516
  if (!app) {
@@ -1401,6 +1538,11 @@ var AriClient = class {
1401
1538
  return !this.wsClient?.isConnected();
1402
1539
  }
1403
1540
  };
1541
+ if (this.wsClient?.isConnected()) {
1542
+ console.log("WebSocket j\xE1 conectado. Removendo listeners antigos...");
1543
+ this.wsClient.removeAllListeners();
1544
+ this.wsClient.close();
1545
+ }
1404
1546
  this.wsClient = new WebSocketClient(wsUrl);
1405
1547
  try {
1406
1548
  await (0, import_exponential_backoff.backOff)(async () => {
@@ -1408,6 +1550,7 @@ var AriClient = class {
1408
1550
  throw new Error("WebSocketClient instance is null.");
1409
1551
  }
1410
1552
  await this.wsClient.connect();
1553
+ this.integrateWebSocketEvents();
1411
1554
  console.log(`WebSocket conectado para o app: ${app}`);
1412
1555
  await this.ensureAppRegistered(app);
1413
1556
  }, backoffOptions);
@@ -1421,6 +1564,104 @@ var AriClient = class {
1421
1564
  this.isReconnecting = false;
1422
1565
  }
1423
1566
  }
1567
+ /**
1568
+ * Integrates WebSocket events with playback listeners.
1569
+ */
1570
+ integrateWebSocketEvents() {
1571
+ if (!this.wsClient) {
1572
+ throw new Error("WebSocket client n\xE3o est\xE1 conectado.");
1573
+ }
1574
+ const eventHandlers = {
1575
+ PlaybackFinished: (data) => {
1576
+ if ("playbackId" in data) {
1577
+ this.playbacks.emitPlaybackEvent("PlaybackFinished", data);
1578
+ }
1579
+ this.emitGlobalEvent(data);
1580
+ },
1581
+ ChannelStateChange: (data) => {
1582
+ if ("channel" in data) {
1583
+ console.log("Estado do canal alterado:", data.channel);
1584
+ }
1585
+ this.emitGlobalEvent(data);
1586
+ },
1587
+ BridgeDestroyed: (data) => {
1588
+ if ("bridge" in data) {
1589
+ console.log("Bridge destru\xEDda:", data.bridge);
1590
+ }
1591
+ this.emitGlobalEvent(data);
1592
+ },
1593
+ // Adicione mais eventos conforme necessário
1594
+ // Exemplo:
1595
+ ChannelDtmfReceived: (data) => {
1596
+ if ("channel" in data) {
1597
+ console.log("DTMF recebido no canal:", data.channel);
1598
+ this.channels.emitChannelEvent("ChannelDtmfReceived", data);
1599
+ }
1600
+ this.emitGlobalEvent(data);
1601
+ }
1602
+ };
1603
+ for (const [eventType, handler] of Object.entries(eventHandlers)) {
1604
+ if (handler) {
1605
+ this.wsClient.on(eventType, handler);
1606
+ }
1607
+ }
1608
+ console.log("Todos os eventos do WebSocket foram registrados.");
1609
+ }
1610
+ /**
1611
+ * Registra um listener para eventos globais.
1612
+ * @param callback - A função a ser executada quando um evento global for recebido.
1613
+ */
1614
+ onGlobalEvent(callback) {
1615
+ this.eventEmitter.on("globalEvent", callback);
1616
+ }
1617
+ /**
1618
+ * Remove um listener para eventos globais.
1619
+ * @param callback - A função a ser removida dos eventos globais.
1620
+ */
1621
+ offGlobalEvent(callback) {
1622
+ this.eventEmitter.off("globalEvent", callback);
1623
+ }
1624
+ /**
1625
+ * Emite um evento global.
1626
+ * @param data - Os dados do evento a serem emitidos.
1627
+ */
1628
+ emitGlobalEvent(data) {
1629
+ this.eventEmitter.emit("globalEvent", data);
1630
+ }
1631
+ /**
1632
+ * Unregisters a listener for playback events.
1633
+ *
1634
+ * This method removes a specific listener registered for a playback event type,
1635
+ * ensuring that no further notifications are sent to the callback function.
1636
+ *
1637
+ * @param eventType - The type of event to stop listening for.
1638
+ * @param playbackId - The unique ID of the playback associated with the listener.
1639
+ * @param callback - The callback function to remove from the listener.
1640
+ */
1641
+ unregisterPlaybackListener(eventType, playbackId, callback) {
1642
+ this.playbacks.unregisterListener(eventType, playbackId, callback);
1643
+ }
1644
+ /**
1645
+ * Registers a listener for playback events.
1646
+ * The listener is triggered for events such as "PlaybackFinished".
1647
+ *
1648
+ * @param eventType - The type of event to listen for.
1649
+ * @param playbackId - The ID of the playback to associate with this listener.
1650
+ * @param callback - The callback function to execute when the event occurs.
1651
+ */
1652
+ registerPlaybackListener(eventType, playbackId, callback) {
1653
+ this.playbacks.registerListener(eventType, playbackId, callback);
1654
+ }
1655
+ /**
1656
+ * Checks if a listener is already registered for a specific event and playback.
1657
+ *
1658
+ * @param eventType - The type of event to check.
1659
+ * @param playbackId - The playback ID associated with the listener.
1660
+ * @returns True if a listener is already registered, false otherwise.
1661
+ */
1662
+ isPlaybackListenerRegistered(eventType, playbackId) {
1663
+ return this.playbacks.isListenerRegistered(eventType, playbackId);
1664
+ }
1424
1665
  /**
1425
1666
  * Ensures the ARI application is registered.
1426
1667
  *
@@ -1452,23 +1693,72 @@ var AriClient = class {
1452
1693
  return this.wsClient ? this.wsClient.isConnected() : false;
1453
1694
  }
1454
1695
  /**
1455
- * Registers a callback function for WebSocket events.
1456
- * This method allows you to listen for and respond to WebSocket messages
1457
- * and process specific event types.
1696
+ * Registers a listener for WebSocket events.
1697
+ *
1698
+ * This function allows you to attach a callback function to a specific WebSocket event type.
1699
+ * The callback will be executed whenever an event of the specified type is received.
1700
+ *
1701
+ * @template T - The type of WebSocket event, extending WebSocketEvent["type"].
1702
+ * @param {T} event - The type of WebSocket event to listen for.
1703
+ * @param {(data: Extract<WebSocketEvent, { type: T }>) => void} callback - The function to be called when the event is received.
1704
+ * The callback receives the event data as its parameter.
1705
+ * @throws {Error} Throws an error if the WebSocket client is not connected when this method is called.
1706
+ * @returns {void} This function doesn't return a value.
1707
+ */
1708
+ onWebSocketEvent(event, callback) {
1709
+ if (!this.wsClient) {
1710
+ throw new Error("WebSocket n\xE3o est\xE1 conectado.");
1711
+ }
1712
+ this.wsClient.on(event, callback);
1713
+ }
1714
+ /**
1715
+ * Removes a specific listener for WebSocket events.
1716
+ *
1717
+ * This function unregisters a previously registered callback function for a specific WebSocket event type.
1718
+ * It's useful for removing event handlers when they are no longer needed or for cleaning up resources.
1719
+ *
1720
+ * @template T - The type of WebSocket event, extending WebSocketEvent["type"].
1721
+ * @param {T} event - The type of WebSocket event to remove the listener from.
1722
+ * @param {(data: Extract<WebSocketEvent, { type: T }>) => void} callback - The callback function to be removed.
1723
+ * This should be the same function reference that was used when adding the event listener.
1724
+ * @throws {Error} Throws an error if the WebSocket client is not connected when this method is called.
1725
+ * @returns {void} This function doesn't return a value.
1726
+ */
1727
+ offWebSocketEvent(event, callback) {
1728
+ if (!this.wsClient) {
1729
+ throw new Error("WebSocket n\xE3o est\xE1 conectado.");
1730
+ }
1731
+ this.wsClient.off(event, callback);
1732
+ }
1733
+ /**
1734
+ * Removes all listeners for a specific WebSocket event type.
1735
+ *
1736
+ * This function removes all event listeners that have been registered for a particular
1737
+ * WebSocket event type. It's useful for cleaning up event listeners when they are no
1738
+ * longer needed or before re-registering new listeners.
1739
+ *
1740
+ * @param event - The type of WebSocket event for which all listeners should be removed.
1741
+ * This should be a string identifying the event type (e.g., 'message', 'close', etc.).
1742
+ *
1743
+ * @throws {Error} Throws an error if the WebSocket client is not connected when this method is called.
1458
1744
  *
1459
- * @param callback - The callback function to execute when a WebSocket message is received.
1460
- * The function will receive the parsed event data as its parameter.
1461
- * @throws {Error} Throws an error if the WebSocket is not connected when trying to register the event.
1462
- * @returns {void}
1745
+ * @returns {void} This function doesn't return a value.
1463
1746
  */
1464
- onWebSocketEvent(callback) {
1747
+ removeAllWebSocketListeners(event) {
1465
1748
  if (!this.wsClient) {
1466
- throw new Error("WebSocket is not connected.");
1749
+ throw new Error("WebSocket n\xE3o est\xE1 conectado.");
1467
1750
  }
1468
- this.wsClient.on("message", callback);
1751
+ this.wsClient.removeAllListeners(event);
1469
1752
  }
1470
1753
  /**
1471
- * Closes the WebSocket connection.
1754
+ * Closes the WebSocket connection and removes all associated listeners.
1755
+ *
1756
+ * This function terminates the active WebSocket connection if one exists,
1757
+ * and cleans up by removing all event listeners attached to it. After calling
1758
+ * this function, the WebSocket client will be set to null, effectively
1759
+ * ending the connection and preparing for potential future connections.
1760
+ *
1761
+ * @returns {void} This function doesn't return a value.
1472
1762
  */
1473
1763
  closeWebSocket() {
1474
1764
  if (this.wsClient) {
@@ -1879,20 +2169,20 @@ var AriClient = class {
1879
2169
  return this.playbacks.getDetails(playbackId);
1880
2170
  }
1881
2171
  /**
1882
- * Controls a specific playback in the Asterisk server.
1883
- * This function allows manipulation of an ongoing playback, such as pausing, resuming, or skipping.
1884
- *
1885
- * @param playbackId - The unique identifier of the playback to control.
1886
- * This should be a string that uniquely identifies the playback in the Asterisk system.
1887
- * @param controlRequest - An object containing the control operation details.
1888
- * This object should conform to the PlaybackControlRequest interface,
1889
- * which includes an 'operation' property specifying the control action to perform.
1890
- * @returns A Promise that resolves when the control operation is successfully executed.
1891
- * The promise resolves to void, indicating no specific return value.
1892
- * If an error occurs during the operation, the promise will be rejected with an error object.
1893
- * @throws Will throw an error if the playback control operation fails, e.g., if the playback doesn't exist
1894
- * or the requested operation is invalid.
1895
- */
2172
+ * Controls a specific playback in the Asterisk server.
2173
+ * This function allows manipulation of an ongoing playback, such as pausing, resuming, or skipping.
2174
+ *
2175
+ * @param playbackId - The unique identifier of the playback to control.
2176
+ * This should be a string that uniquely identifies the playback in the Asterisk system.
2177
+ * @param controlRequest - An object containing the control operation details.
2178
+ * This object should conform to the PlaybackControlRequest interface,
2179
+ * which includes an 'operation' property specifying the control action to perform.
2180
+ * @returns A Promise that resolves when the control operation is successfully executed.
2181
+ * The promise resolves to void, indicating no specific return value.
2182
+ * If an error occurs during the operation, the promise will be rejected with an error object.
2183
+ * @throws Will throw an error if the playback control operation fails, e.g., if the playback doesn't exist
2184
+ * or the requested operation is invalid.
2185
+ */
1896
2186
  async controlPlayback(playbackId, controlRequest) {
1897
2187
  const { operation } = controlRequest;
1898
2188
  return this.playbacks.control(playbackId, operation);