@ipcom/asterisk-ari 0.0.146-beta → 0.0.146

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/README.md CHANGED
@@ -26,11 +26,11 @@ npm install @ipcom/asterisk-ari
26
26
  import { AriClient } from '@ipcom/asterisk-ari';
27
27
 
28
28
  const client = new AriClient({
29
- host: 'localhost', // Asterisk host
30
- port: 8088, // ARI port
31
- username: 'username', // ARI username
32
- password: 'password', // ARI password
33
- secure: false // Use true for HTTPS/WSS
29
+ host: 'localhost', // Asterisk host
30
+ port: 8088, // ARI port
31
+ username: 'username', // ARI username
32
+ password: 'password', // ARI password
33
+ secure: false // Use true for HTTPS/WSS
34
34
  });
35
35
  ```
36
36
 
@@ -42,16 +42,16 @@ await client.connectWebSocket(['myApp']); // 'myApp' is your application name
42
42
 
43
43
  // Listen for specific events
44
44
  client.on('StasisStart', event => {
45
- console.log('New channel started:', event.channel.id);
45
+ console.log('New channel started:', event.channel.id);
46
46
  });
47
47
 
48
48
  client.on('StasisEnd', event => {
49
- console.log('Channel ended:', event.channel.id);
49
+ console.log('Channel ended:', event.channel.id);
50
50
  });
51
51
 
52
52
  // Listen for DTMF events
53
53
  client.on('ChannelDtmfReceived', event => {
54
- console.log('DTMF received:', event.digit);
54
+ console.log('DTMF received:', event.digit);
55
55
  });
56
56
 
57
57
  // Close WebSocket connection
@@ -60,32 +60,21 @@ client.closeWebSocket();
60
60
 
61
61
  ## Event Instances
62
62
 
63
- ### Channel, Bridge and Playback Instances in Events
63
+ ### Channel and Playback Instances in Events
64
64
 
65
65
  When working with WebSocket events, you get access to both the raw event data and convenient instance objects that allow direct interaction with the channel or playback:
66
66
 
67
67
  ```typescript
68
68
  client.on('StasisStart', async event => {
69
- // event.channel contains the raw channel data
70
- console.log('New channel started:', event.channel.id);
69
+ // event.channel contains the raw channel data
70
+ console.log('New channel started:', event.channel.id);
71
71
 
72
- // event.instanceChannel provides a ready-to-use ChannelInstance
73
- const channelInstance = event.instanceChannel;
74
-
75
- // You can directly interact with the channel through the instance
76
- await channelInstance.answer();
77
- await channelInstance.play({ media: 'sound:welcome' });
78
- });
79
-
80
- client.on('BridgeCreated', async event => {
81
- // event.bridge contains the raw bridge data
82
- console.log('Bridge created:', event.bridge.id);
83
-
84
- // event.instanceBridge provides a ready-to-use BridgeInstance
85
- const bridgeInstance = event.instanceBridge;
86
-
87
- // Direct control through the instance
88
- await bridgeInstance.add({ channel: ['channel-id-1', 'channel-id-2'] });
72
+ // event.instanceChannel provides a ready-to-use ChannelInstance
73
+ const channelInstance = event.instanceChannel;
74
+
75
+ // You can directly interact with the channel through the instance
76
+ await channelInstance.answer();
77
+ await channelInstance.play({ media: 'sound:welcome' });
89
78
  });
90
79
 
91
80
  // Similarly for playback events
@@ -174,41 +163,6 @@ await playback.control('restart'); // Restart
174
163
  await playback.stop(); // Stop
175
164
  ```
176
165
 
177
- ### Bridge Handling
178
-
179
- ```typescript
180
- // Create a bridge instance
181
- const bridge = client.Bridge();
182
-
183
- // Create a new bridge with specific settings
184
- await bridge.getDetails();
185
-
186
- // Add channels to the bridge
187
- await bridge.add({
188
- channel: ['channel-id-1', 'channel-id-2']
189
- });
190
-
191
- // Remove channels from the bridge
192
- await bridge.remove({
193
- channel: ['channel-id-1']
194
- });
195
-
196
- // Play audio on the bridge
197
- const playback = await bridge.playMedia({
198
- media: 'sound:announcement',
199
- lang: 'en'
200
- });
201
-
202
- // Stop playback on the bridge
203
- await bridge.stopPlayback(playback.id);
204
-
205
- // Set video source
206
- await bridge.setVideoSource('video-channel-id');
207
-
208
- // Clear video source
209
- await bridge.clearVideoSource();
210
- ```
211
-
212
166
  ### Specific Channel Monitoring
213
167
 
214
168
  ```typescript
@@ -254,39 +208,6 @@ await channel.pausePlayback(playback.id);
254
208
  await channel.resumePlayback(playback.id);
255
209
  ```
256
210
 
257
- ### Bridge Event Monitoring
258
-
259
- ```typescript
260
- // Create an instance for a specific bridge
261
- const bridge = client.Bridge('bridge-id');
262
-
263
- // Monitor bridge events
264
- bridge.on('BridgeCreated', event => {
265
- console.log('Bridge created:', event.bridge.id);
266
- });
267
-
268
- bridge.on('BridgeDestroyed', event => {
269
- console.log('Bridge destroyed:', event.bridge.id);
270
- });
271
-
272
- bridge.on('BridgeMerged', event => {
273
- console.log('Bridge merged:', event.bridge.id);
274
- });
275
-
276
- // Get bridge details
277
- const details = await bridge.get();
278
- console.log('Bridge details:', details);
279
-
280
- // Monitor channel events in bridge
281
- bridge.on('ChannelEnteredBridge', event => {
282
- console.log('Channel entered bridge:', event.channel.id);
283
- });
284
-
285
- bridge.on('ChannelLeftBridge', event => {
286
- console.log('Channel left bridge:', event.channel.id);
287
- });
288
- ```
289
-
290
211
  ## Error Handling
291
212
 
292
213
  ```typescript
@@ -312,29 +233,23 @@ try {
312
233
  The library provides complete type definitions for all operations:
313
234
 
314
235
  ```typescript
315
- import type {
316
- Channel,
317
- Bridge,
318
- ChannelEvent,
319
- BridgeEvent,
320
- WebSocketEvent
236
+ import type {
237
+ Channel,
238
+ ChannelEvent,
239
+ WebSocketEvent
321
240
  } from '@ipcom/asterisk-ari';
322
241
 
323
242
  // Types will be available for use
324
243
  const handleChannelEvent = (event: ChannelEvent) => {
325
244
  const channelId: string = event.channel.id;
326
245
  };
327
-
328
- // Types will be available for use
329
- const handleBridgeEvent = (event: BridgeEvent) => {
330
- const bridgeId: string = event.bridge.id;
331
- };
332
246
  ```
333
247
 
334
248
  ## Additional Features
335
249
 
336
250
  The library provides access to many other ARI features:
337
251
 
252
+ - Bridge management
338
253
  - Endpoint handling
339
254
  - Sound manipulation
340
255
  - Application control
@@ -348,13 +263,13 @@ The library provides access to many other ARI features:
348
263
  ```typescript
349
264
  // Create and manage a bridge
350
265
  const bridge = await client.bridges.createBridge({
351
- type: 'mixing',
352
- name: 'myBridge'
266
+ type: 'mixing',
267
+ name: 'myBridge'
353
268
  });
354
269
 
355
270
  // Add channels to bridge
356
271
  await client.bridges.addChannels(bridge.id, {
357
- channel: ['channel-id-1', 'channel-id-2']
272
+ channel: ['channel-id-1', 'channel-id-2']
358
273
  });
359
274
  ```
360
275
 
@@ -364,10 +279,10 @@ await client.bridges.addChannels(bridge.id, {
364
279
  // Start recording on a channel
365
280
  const channel = client.Channel('channel-id');
366
281
  await channel.record({
367
- name: 'recording-name',
368
- format: 'wav',
369
- maxDurationSeconds: 60,
370
- beep: true
282
+ name: 'recording-name',
283
+ format: 'wav',
284
+ maxDurationSeconds: 60,
285
+ beep: true
371
286
  });
372
287
  ```
373
288
 
@@ -376,9 +291,9 @@ await channel.record({
376
291
  ```typescript
377
292
  // Create external media channel
378
293
  const channel = await client.channels.createExternalMedia({
379
- app: 'myApp',
380
- external_host: 'media-server:8088',
381
- format: 'slin16'
294
+ app: 'myApp',
295
+ external_host: 'media-server:8088',
296
+ format: 'slin16'
382
297
  });
383
298
  ```
384
299