@babblevoice/babble-drachtio-callmanager 3.5.8 → 3.6.0
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/index.js +4 -1
- package/lib/call.js +65 -26
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -14,7 +14,10 @@ const default_options = {
|
|
|
14
14
|
"registrar": false, /* our registrar object or falsey */
|
|
15
15
|
"referauthrequired": true,
|
|
16
16
|
"ignoreipv6candidates": true, /* ipv6 does not work in projectrtp */
|
|
17
|
-
"privacy": false
|
|
17
|
+
"privacy": false,
|
|
18
|
+
"hangupchildrenonhangup": true,
|
|
19
|
+
"hangupparentonhangup": false,
|
|
20
|
+
"continueonotherhangup": false
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
/**
|
package/lib/call.js
CHANGED
|
@@ -1228,7 +1228,7 @@ class call {
|
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
1230
|
/* are we still established? */
|
|
1231
|
-
if( !this.established || this.state.destroyed ) return this
|
|
1231
|
+
if( !this.established || this.state.destroyed || this.parent.destroyed ) return this
|
|
1232
1232
|
if( !this.channels.audio ) {
|
|
1233
1233
|
/* something bad has happened */
|
|
1234
1234
|
this.hangup( hangupcodes.NOT_ACCEPTABLE )
|
|
@@ -2586,6 +2586,8 @@ class call {
|
|
|
2586
2586
|
|
|
2587
2587
|
/* Link logically and mix */
|
|
2588
2588
|
a_1.adopt( c_1, true )
|
|
2589
|
+
/* update the caller id on the call */
|
|
2590
|
+
await a_1.update()
|
|
2589
2591
|
|
|
2590
2592
|
this._notifyrefercomplete()
|
|
2591
2593
|
|
|
@@ -2797,14 +2799,29 @@ class call {
|
|
|
2797
2799
|
} ).catch( () => {} )
|
|
2798
2800
|
}
|
|
2799
2801
|
|
|
2802
|
+
/**
|
|
2803
|
+
* @param { boolean } value - allow our relation (child or parent) to hang us up or not - set to true if this leg wants to continue
|
|
2804
|
+
*/
|
|
2805
|
+
set continueonotherhangup( value ) {
|
|
2806
|
+
this.options.continueonotherhangup = value
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2809
|
+
/**
|
|
2810
|
+
* @returns { boolean }
|
|
2811
|
+
*/
|
|
2812
|
+
get continueonotherhangup() {
|
|
2813
|
+
return this.options.continueonotherhangup
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2800
2816
|
/**
|
|
2801
2817
|
* Used by our frame to a) continue a hangup which has been initiated by either us or the network.
|
|
2802
2818
|
* Complete the hangup, including hanging up all children and waiting for them to complete their
|
|
2803
2819
|
* hangup.
|
|
2804
|
-
* @param {
|
|
2820
|
+
* @param { "us" | "wire" } [ src ] - "us"|"wire"
|
|
2805
2821
|
* @param { object } [ reason ] - one of the reasons from the hangupcodes enum - only used if we havn't alread set our reason
|
|
2806
2822
|
* @private
|
|
2807
2823
|
*/
|
|
2824
|
+
// eslint-disable-next-line complexity
|
|
2808
2825
|
async _onhangup( src = "us", reason ) {
|
|
2809
2826
|
|
|
2810
2827
|
if( this._state._onhangup ) {
|
|
@@ -2813,18 +2830,33 @@ class call {
|
|
|
2813
2830
|
}
|
|
2814
2831
|
this._state._onhangup = true
|
|
2815
2832
|
|
|
2816
|
-
|
|
2817
|
-
const hangups = []
|
|
2818
|
-
for( const child of this.children ) {
|
|
2819
|
-
hangups.push( child.hangup( this.hangup_cause ) )
|
|
2820
|
-
}
|
|
2833
|
+
this._sethangupcause( src, reason )
|
|
2821
2834
|
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2835
|
+
if( "wire" == src ) {
|
|
2836
|
+
/*
|
|
2837
|
+
1. Hangup our children regardless of our state
|
|
2838
|
+
2. If we are established and the only child child - hangup our parent (unless otherwise told not to: parent.continueonotherhangup)
|
|
2839
|
+
*/
|
|
2840
|
+
const hangups = []
|
|
2841
|
+
if( this.options.hangupchildrenonhangup ) {
|
|
2842
|
+
for( const child of this.children ) {
|
|
2843
|
+
if( !child.options.continueonotherhangup ) {
|
|
2844
|
+
hangups.push( child.hangup( this.hangup_cause ) )
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2826
2848
|
|
|
2827
|
-
|
|
2849
|
+
if( this.established && this.options.hangupparentonhangup && this.parent ) {
|
|
2850
|
+
if( !this.parent.options.continueonotherhangup && 2 > this.parent.children.size ) {
|
|
2851
|
+
hangups.push( this.parent.hangup( this.hangup_cause ) )
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
|
|
2855
|
+
/* wait for all relatives to complete their hangup */
|
|
2856
|
+
if( 0 < hangups.length ) {
|
|
2857
|
+
await Promise.all( hangups )
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2828
2860
|
|
|
2829
2861
|
/* flag destroyed so when we receive our close event we know what to do */
|
|
2830
2862
|
this.destroyed = true
|
|
@@ -2844,19 +2876,21 @@ class call {
|
|
|
2844
2876
|
/**
|
|
2845
2877
|
* Hangup the call with reason. Public interface for callers to use.
|
|
2846
2878
|
* @param { object } reason - one of the reasons from the hangupcodes enum
|
|
2847
|
-
* @param { boolean } tone if true play
|
|
2879
|
+
* @param { boolean } [ tone ] if true play the appropriate tone instead of actaully hanging up
|
|
2880
|
+
* @param { "wire" | "us" } [ source ] - who initiated the hangup - typically us - but if the signal came from another network interface - then wire
|
|
2881
|
+
*
|
|
2848
2882
|
*/
|
|
2849
|
-
async hangup( reason, tone = false ) {
|
|
2883
|
+
async hangup( reason, tone = false, source = "us" ) {
|
|
2850
2884
|
|
|
2851
2885
|
if( this._state._hangup || this._state._onhangup ) {
|
|
2852
2886
|
await this.waitforhangup()
|
|
2853
2887
|
return
|
|
2854
2888
|
}
|
|
2855
2889
|
|
|
2856
|
-
this._sethangupcause(
|
|
2890
|
+
this._sethangupcause( source, reason )
|
|
2857
2891
|
|
|
2858
2892
|
if( this.state.established ) {
|
|
2859
|
-
if(
|
|
2893
|
+
if( this.#hangupestablish( reason, tone ) ) return
|
|
2860
2894
|
} else if( "uac" === this.type && this.state.trying ) {
|
|
2861
2895
|
this.#hangupnotestablish()
|
|
2862
2896
|
} else if( this._res ) {
|
|
@@ -2864,29 +2898,29 @@ class call {
|
|
|
2864
2898
|
}
|
|
2865
2899
|
|
|
2866
2900
|
this._state._hangup = true
|
|
2867
|
-
|
|
2901
|
+
|
|
2902
|
+
try {
|
|
2903
|
+
if( this._dialog ) await this._dialog.destroy()
|
|
2904
|
+
} catch( e ) { console.trace( e ) }
|
|
2905
|
+
|
|
2906
|
+
await this._onhangup( source, reason )
|
|
2868
2907
|
}
|
|
2869
2908
|
|
|
2870
2909
|
/**
|
|
2871
2910
|
* @param { object } reason - plays the apropropriate tone
|
|
2872
2911
|
* @param { boolean } tone
|
|
2873
2912
|
*/
|
|
2874
|
-
|
|
2913
|
+
#hangupestablish( reason, tone ) {
|
|
2875
2914
|
if( undefined != reason && tone ) {
|
|
2876
2915
|
switch( reason.sip ) {
|
|
2877
2916
|
case 486:
|
|
2878
2917
|
this.play( this.engagedsoup )
|
|
2879
|
-
|
|
2918
|
+
return true
|
|
2880
2919
|
case 480:
|
|
2881
2920
|
this.play( this.unobtainablesoup )
|
|
2921
|
+
return true
|
|
2882
2922
|
}
|
|
2883
|
-
return true
|
|
2884
2923
|
}
|
|
2885
|
-
this._state._hangup = true
|
|
2886
|
-
|
|
2887
|
-
try {
|
|
2888
|
-
await this._dialog.destroy()
|
|
2889
|
-
} catch( e ) { console.trace( e ) }
|
|
2890
2924
|
return false
|
|
2891
2925
|
}
|
|
2892
2926
|
|
|
@@ -2920,6 +2954,7 @@ class call {
|
|
|
2920
2954
|
/**
|
|
2921
2955
|
* Send an UPDATE. Use to updated called id, caller id, sdp etc. Send in dialog - TODO look how to send
|
|
2922
2956
|
* early as this is recomended in the RFC.
|
|
2957
|
+
* @param { object } [ remote ]
|
|
2923
2958
|
*/
|
|
2924
2959
|
async update( remote ) {
|
|
2925
2960
|
|
|
@@ -3224,7 +3259,7 @@ class call {
|
|
|
3224
3259
|
if( err.status in inboundsiperros ) reason = inboundsiperros[ err.status ]
|
|
3225
3260
|
|
|
3226
3261
|
this.state.destroyed = true
|
|
3227
|
-
|
|
3262
|
+
this._onhangup( "wire", reason )
|
|
3228
3263
|
} else {
|
|
3229
3264
|
console.trace( err )
|
|
3230
3265
|
}
|
|
@@ -3362,6 +3397,9 @@ class call {
|
|
|
3362
3397
|
* @property { object } [ calledid ]
|
|
3363
3398
|
* @property { string } [ calledid.number ]
|
|
3364
3399
|
* @property { string } [ calledid.name ]
|
|
3400
|
+
* @property { boolean } [ continueonotherhangup ] - if true continue on other hangup
|
|
3401
|
+
* @property { boolean } [ hangupchildrenonhangup ]
|
|
3402
|
+
* @property { boolean } [ hangupparentonhangup ]
|
|
3365
3403
|
* @property { call } [ bond ] - other channel to bond to for pottential channel pairing
|
|
3366
3404
|
*/
|
|
3367
3405
|
|
|
@@ -3504,6 +3542,7 @@ class call {
|
|
|
3504
3542
|
if( earlypromise ) await earlypromise
|
|
3505
3543
|
|
|
3506
3544
|
if( !newdialog ) {
|
|
3545
|
+
callstore.delete( newcall )
|
|
3507
3546
|
if( callbacks.fail ) callbacks.fail( newcall )
|
|
3508
3547
|
return newcall
|
|
3509
3548
|
}
|