@babblevoice/babble-drachtio-callmanager 1.2.1 → 1.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.
package/lib/call.js CHANGED
@@ -420,8 +420,8 @@ class call {
420
420
  parsed = this._req.getParsedHeader( "from" )
421
421
  }
422
422
 
423
- let parseduri = parseuri( parsed.uri )
424
423
  if( !parsed ) parsed = {}
424
+ let parseduri = parseuri( parsed.uri )
425
425
  if( !parsed.params ) parsed.params = {}
426
426
 
427
427
  return {
@@ -1443,6 +1443,24 @@ class call {
1443
1443
  }
1444
1444
  }
1445
1445
 
1446
+ /**
1447
+ * Set the sound soup for music on hold.
1448
+ * @param { object } soup - sound soup as described in projectrtp
1449
+ */
1450
+ set moh( soup ) {
1451
+ this._moh = soup
1452
+ }
1453
+
1454
+ /**
1455
+ * Return the current moh
1456
+ */
1457
+ get moh() {
1458
+ if( this._moh ) {
1459
+ return this._moh
1460
+ }
1461
+ return callmanager.options.moh
1462
+ }
1463
+
1446
1464
  /**
1447
1465
  * If we have been placed on hold (and it has been neotiated) then configure audio to match.
1448
1466
  * @private
@@ -1458,7 +1476,7 @@ class call {
1458
1476
  let other = this.other
1459
1477
  if( other ) {
1460
1478
  other.channels.audio.unmix()
1461
- other.channels.audio.play( callmanager.options.moh )
1479
+ other.channels.audio.play( this.moh )
1462
1480
  }
1463
1481
 
1464
1482
  this._em.emit( "call.hold", this )
@@ -1939,13 +1957,13 @@ class call {
1939
1957
  /* Call outstanding resolves for promises - this will trigger out hangup promise also */
1940
1958
  resolves.forEach( r => r( this ) )
1941
1959
 
1942
- this.removealllisteners()
1943
-
1944
1960
  this._em.emit( "call.destroyed", this )
1945
1961
  callmanager.options.em.emit( "call.destroyed", this )
1946
1962
 
1947
1963
  this._em.emit( "call.reporting", this )
1948
1964
  callmanager.options.em.emit( "call.reporting", this )
1965
+
1966
+ this.removealllisteners()
1949
1967
  }
1950
1968
 
1951
1969
  /**
@@ -2447,7 +2465,7 @@ class call {
2447
2465
  @private
2448
2466
  */
2449
2467
  c._req = req
2450
- c._req.on( "cancel", () => this._oncanceled() )
2468
+ c._req.on( "cancel", () => c._oncanceled.bind( c ) )
2451
2469
  /**
2452
2470
  @member
2453
2471
  @private
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babblevoice/babble-drachtio-callmanager",
3
- "version": "1.2.1",
3
+ "version": "1.3.2",
4
4
  "description": "Call processing to create a PBX",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -554,9 +554,9 @@ describe( "call object", function() {
554
554
  eventhappened = true
555
555
  } )
556
556
 
557
- await c.hangup()
558
-
559
557
  expect( eventhappened ).to.be.false
558
+ await c.hangup()
559
+ expect( eventhappened ).to.be.true
560
560
  } )
561
561
 
562
562
  it( `uas.newuac - answered and destroyed event`, async function() {
@@ -752,7 +752,7 @@ describe( "call object", function() {
752
752
  } )
753
753
 
754
754
  it( `uas.newuac - early callback is called`, async function() {
755
- let srfscenario = new srf.srfscenario( {} )
755
+ new srf.srfscenario( {} )
756
756
 
757
757
  let options = {
758
758
  "contact": "ourcontactstring",
@@ -768,7 +768,7 @@ describe( "call object", function() {
768
768
  } )
769
769
 
770
770
  it( `uas.newuac - confirmed callback is called`, async function() {
771
- let srfscenario = new srf.srfscenario( {} )
771
+ new srf.srfscenario( {} )
772
772
 
773
773
  let options = {
774
774
  "contact": "ourcontactstring",
@@ -784,7 +784,7 @@ describe( "call object", function() {
784
784
  } )
785
785
 
786
786
  it( `uas.newuac - simple update`, async function() {
787
- let srfscenario = new srf.srfscenario( {} )
787
+ new srf.srfscenario( {} )
788
788
 
789
789
  let options = {
790
790
  "contact": "ourcontactstring",
@@ -814,7 +814,7 @@ describe( "call object", function() {
814
814
  } )
815
815
 
816
816
  it( `uas.newuac - simple update - but don't allow as not in allow`, async function() {
817
- let srfscenario = new srf.srfscenario( {} )
817
+ new srf.srfscenario( {} )
818
818
 
819
819
  let options = {
820
820
  "contact": "ourcontactstring",
@@ -841,7 +841,7 @@ describe( "call object", function() {
841
841
  } )
842
842
 
843
843
  it( `Test listen and emit event on call object`, async function() {
844
- let srfscenario = new srf.srfscenario( {} )
844
+ new srf.srfscenario( {} )
845
845
 
846
846
  let options = {
847
847
  "contact": "ourcontactstring",
@@ -864,7 +864,7 @@ describe( "call object", function() {
864
864
  } )
865
865
 
866
866
  it( `Test listen and emit event on and removealllisteners call object`, async function() {
867
- let srfscenario = new srf.srfscenario( {} )
867
+ new srf.srfscenario( {} )
868
868
 
869
869
  let options = {
870
870
  "contact": "ourcontactstring",
@@ -890,7 +890,7 @@ describe( "call object", function() {
890
890
  } )
891
891
 
892
892
  it( `Test listen and emit event on and removealllisteners (none specified) call object`, async function() {
893
- let srfscenario = new srf.srfscenario( {} )
893
+ new srf.srfscenario( {} )
894
894
 
895
895
  let options = {
896
896
  "contact": "ourcontactstring",
@@ -916,7 +916,7 @@ describe( "call object", function() {
916
916
  } )
917
917
 
918
918
  it( `Test listen and emit event on and off call object`, async function() {
919
- let srfscenario = new srf.srfscenario( {} )
919
+ new srf.srfscenario( {} )
920
920
 
921
921
  let options = {
922
922
  "contact": "ourcontactstring",
@@ -944,7 +944,7 @@ describe( "call object", function() {
944
944
  } )
945
945
 
946
946
  it( `Test listen and emit event once call object`, async function() {
947
- let srfscenario = new srf.srfscenario( {} )
947
+ new srf.srfscenario( {} )
948
948
 
949
949
  let options = {
950
950
  "contact": "ourcontactstring",
@@ -968,7 +968,7 @@ describe( "call object", function() {
968
968
  } )
969
969
 
970
970
  it( `Test listen and emit call.pick on call object`, async function() {
971
- let srfscenario = new srf.srfscenario( {} )
971
+ new srf.srfscenario( {} )
972
972
 
973
973
  let options = {
974
974
  "contact": "ourcontactstring",
@@ -990,7 +990,7 @@ describe( "call object", function() {
990
990
  } )
991
991
 
992
992
  it( `Create a call and mock rtpengine and ensure we receive events`, async function() {
993
- let srfscenario = new srf.srfscenario( {} )
993
+ new srf.srfscenario( {} )
994
994
  let rtpserver = callmanager.projectrtp.proxy.listen()
995
995
 
996
996
  let connection = net.createConnection( 9002, "127.0.0.1" )
@@ -1072,4 +1072,32 @@ describe( "call object", function() {
1072
1072
  connection.destroy()
1073
1073
  rtpserver.destroy()
1074
1074
  } )
1075
+
1076
+ it( `set get moh`, async function() {
1077
+ new srf.srfscenario( {} )
1078
+
1079
+ let options = {
1080
+ "contact": "ourcontactstring",
1081
+ "late": true
1082
+ }
1083
+
1084
+ let c = await call.newuac( options )
1085
+
1086
+ let s = {
1087
+ "loop": true,
1088
+ "files": [
1089
+ { "wav": "some.wav" }
1090
+ ]
1091
+ }
1092
+
1093
+ /* no default configured */
1094
+ expect( c.moh ).to.be.undefined
1095
+ c.moh = s
1096
+
1097
+ expect( c._moh.loop ).to.equal( true )
1098
+ expect( c.moh.loop ).to.equal( true )
1099
+
1100
+ c._onhangup( "wire" )
1101
+
1102
+ } )
1075
1103
  } )