@babblevoice/babble-drachtio-callmanager 2.3.1 → 2.3.2

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.
Files changed (2) hide show
  1. package/lib/call.js +38 -16
  2. package/package.json +1 -1
package/lib/call.js CHANGED
@@ -787,9 +787,11 @@ class call {
787
787
  /**
788
788
  Allows 3rd parties to emit events to listeners specific to this call.
789
789
  @param { string } ev - event name
790
+ @param { any } argv1
790
791
  */
791
- emit( ev ) {
792
- this._em.emit( ev, this )
792
+ emit( ev, argv1 ) {
793
+ if( argv1 ) return this._em.emit( ev, argv1 )
794
+ else return this._em.emit( ev, this )
793
795
  }
794
796
 
795
797
  /**
@@ -1570,7 +1572,7 @@ class call {
1570
1572
  } catch ( e ) { console.trace( e ) }
1571
1573
 
1572
1574
  switch( e.action ) {
1573
- case "close":
1575
+ case "close":
1574
1576
  this.#handlechannelevclose( e )
1575
1577
  return
1576
1578
  case "telephone-event":
@@ -1911,6 +1913,10 @@ class call {
1911
1913
  other.channels.audio.dtmf( digit )
1912
1914
  }
1913
1915
 
1916
+ try {
1917
+ this._em.emit( "channel", { "call": this, "event": { action: "telephone-event", event: digit, source: "sip-info" } } )
1918
+ } catch ( e ) { console.trace( e ) }
1919
+
1914
1920
  return res.send( 200 )
1915
1921
  }
1916
1922
 
@@ -2460,16 +2466,17 @@ class call {
2460
2466
 
2461
2467
  /* If max-forwards is not specified then we decrement the parent and pass on */
2462
2468
  if( !( "headers" in options ) ) options.headers = {}
2469
+
2470
+ let maxforwards = 70
2463
2471
  if( !options.headers[ Object.keys( options.headers ).find( key => "max-forwards" === key.toLowerCase() ) ] ) {
2464
- if( !this._req.has( "Max-Forwards" ) ) {
2465
- return false
2472
+ if( this._req.has( "Max-Forwards" ) ) {
2473
+ maxforwards = parseInt( this._req.get( "Max-Forwards" ) ) - 1
2474
+ if( isNaN( maxforwards ) || 0 >= maxforwards ) return false
2466
2475
  }
2467
-
2468
- const maxforwards = parseInt( this._req.get( "Max-Forwards" ) )
2469
- if( 0 >= maxforwards ) return false
2470
- options.headers[ "Max-Forwards" ] = maxforwards - 1
2471
2476
  }
2472
2477
 
2478
+ options.headers[ "Max-Forwards" ] = maxforwards
2479
+
2473
2480
  if( !options.orphan ) {
2474
2481
  options.parent = this
2475
2482
  }
@@ -2491,12 +2498,8 @@ class call {
2491
2498
  }
2492
2499
  return true
2493
2500
  }
2494
-
2495
- /**
2496
- *
2497
- * @returns { Promise< boolean | object > }
2498
- */
2499
- static async #callcontactfornewuac( options, callbacks ) {
2501
+
2502
+ static async #sanityforcallcontact( options ) {
2500
2503
 
2501
2504
  if( !( await call.#checkmaxcallsforentity( options ) ) ) return false
2502
2505
 
@@ -2505,13 +2508,27 @@ class call {
2505
2508
  if( !options.entity ) return false
2506
2509
 
2507
2510
  const contactinfo = await callmanager.options.registrar.contacts( options.entity )
2508
-
2509
2511
  if( 0 == contactinfo.contacts.length )
2510
2512
  return false
2511
2513
 
2512
2514
  if( options.first )
2513
2515
  contactinfo.contacts = [ contactinfo.contacts[ 0 ] ]
2514
2516
 
2517
+ return contactinfo
2518
+ }
2519
+
2520
+ /**
2521
+ *
2522
+ * @returns { Promise< boolean | object > }
2523
+ */
2524
+ static async #callcontactfornewuac( options, callbacks ) {
2525
+
2526
+ const contactinfo = await call.#sanityforcallcontact( options )
2527
+ if( !contactinfo ) {
2528
+ if( callbacks.fail ) callbacks.fail()
2529
+ return false
2530
+ }
2531
+
2515
2532
  let numcontacts = 0
2516
2533
  const ourcallbacks = {}
2517
2534
  let failcount = 0
@@ -2556,6 +2573,11 @@ class call {
2556
2573
  }
2557
2574
  }
2558
2575
 
2576
+ if( 0 == numcontacts ) {
2577
+ if( callbacks.fail ) callbacks.fail()
2578
+ return false
2579
+ }
2580
+
2559
2581
  const child = await waitonchildrenpromise
2560
2582
  return child
2561
2583
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {