@babblevoice/babble-drachtio-callmanager 1.6.1 → 1.6.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 +6 -4
- package/package.json +1 -1
- package/test/interface/call.js +6 -0
- package/test/interface/xfer.js +35 -7
package/lib/call.js
CHANGED
|
@@ -1853,10 +1853,11 @@ class call {
|
|
|
1853
1853
|
let replaces = replacesuri.match( /replaces=(.*?)(;|$)/i )
|
|
1854
1854
|
|
|
1855
1855
|
if( null !== replaces ) {
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
this._runblindxfer( req, res, referto )
|
|
1856
|
+
await this._runattendedxfer( req, res, replaces, replacesuri )
|
|
1857
|
+
return
|
|
1859
1858
|
}
|
|
1859
|
+
|
|
1860
|
+
await this._runblindxfer( req, res, referto )
|
|
1860
1861
|
} )
|
|
1861
1862
|
}
|
|
1862
1863
|
|
|
@@ -1865,7 +1866,7 @@ class call {
|
|
|
1865
1866
|
a blind xfer on the other leg.
|
|
1866
1867
|
@private
|
|
1867
1868
|
*/
|
|
1868
|
-
_runblindxfer( req, res, referto ) {
|
|
1869
|
+
async _runblindxfer( req, res, referto ) {
|
|
1869
1870
|
let othercall = this.other
|
|
1870
1871
|
if( !othercall ) return res.send( 400, "We have no-one to refer" )
|
|
1871
1872
|
|
|
@@ -1876,6 +1877,7 @@ class call {
|
|
|
1876
1877
|
this._notifyreferstart()
|
|
1877
1878
|
|
|
1878
1879
|
othercall.referingtouri = referto.uri
|
|
1880
|
+
othercall.referedby = this
|
|
1879
1881
|
callmanager.options.em.emit( "call.new", othercall )
|
|
1880
1882
|
this._notifyrefercomplete()
|
|
1881
1883
|
|
package/package.json
CHANGED
package/test/interface/call.js
CHANGED
|
@@ -35,6 +35,11 @@ describe( "call object", function() {
|
|
|
35
35
|
|
|
36
36
|
let srfscenario = new srf.srfscenario()
|
|
37
37
|
|
|
38
|
+
let newcallcalled = false
|
|
39
|
+
srfscenario.options.em.on( "call.new", ( /*newcall*/ ) => {
|
|
40
|
+
newcallcalled = true
|
|
41
|
+
} )
|
|
42
|
+
|
|
38
43
|
let call = await new Promise( ( resolve ) => {
|
|
39
44
|
srfscenario.oncall( async ( call ) => { resolve( call ) } )
|
|
40
45
|
srfscenario.inbound()
|
|
@@ -54,6 +59,7 @@ describe( "call object", function() {
|
|
|
54
59
|
"storebyentity": 0
|
|
55
60
|
} )
|
|
56
61
|
|
|
62
|
+
expect( newcallcalled ).to.be.true
|
|
57
63
|
expect( call ).to.have.property( "uuid" ).that.is.a( "string" )
|
|
58
64
|
expect( call ).to.have.property( "type" ).that.is.a( "string" ).to.equal( "uas" )
|
|
59
65
|
expect( call ).to.have.property( "state" ).that.is.a( "object" )
|
package/test/interface/xfer.js
CHANGED
|
@@ -46,9 +46,30 @@ describe( "xfer", function() {
|
|
|
46
46
|
|
|
47
47
|
} )
|
|
48
48
|
|
|
49
|
-
it( `call blind xfer 2 leg
|
|
49
|
+
it( `call blind xfer 2 leg auth`, async function() {
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
Client a Us Client b
|
|
53
|
+
|--------------INVITE ------------>| |(1)
|
|
54
|
+
|<-------------407 proxy auth------| |(2)
|
|
55
|
+
|--------------INVITE w auth ----->| |(3)
|
|
56
|
+
|<-------------200 ok--------------| |(4)
|
|
57
|
+
| |--------------INVITE ------------>|(5)
|
|
58
|
+
| |<-------------200 ok--------------|(6)
|
|
59
|
+
| |<-------------REFER --------------|(7)
|
|
60
|
+
| |--------------202 --------------->|(8)
|
|
61
|
+
| |--------------NOTIFY (100)------->|(9)
|
|
62
|
+
| |<-------------200 ----------------|(10)
|
|
63
|
+
| |--------------NOTIFY (200)------->|(11)
|
|
64
|
+
| |<-------------200 ----------------|(12)
|
|
65
|
+
em.emit( "call.new", call )
|
|
66
|
+
*/
|
|
50
67
|
|
|
51
68
|
let srfscenario = new srf.srfscenario()
|
|
69
|
+
let referedcall
|
|
70
|
+
srfscenario.options.em.on( "call.new", ( r ) => {
|
|
71
|
+
referedcall = r
|
|
72
|
+
} )
|
|
52
73
|
|
|
53
74
|
let call = await new Promise( ( resolve ) => {
|
|
54
75
|
srfscenario.oncall( async ( call ) => { resolve( call ) } )
|
|
@@ -69,19 +90,26 @@ describe( "xfer", function() {
|
|
|
69
90
|
await call.answer()
|
|
70
91
|
let child = await call.newuac( { "contact": "1000@dummy" } )
|
|
71
92
|
|
|
72
|
-
|
|
93
|
+
await child._dialog.callbacks.refer( req, res )
|
|
73
94
|
|
|
74
95
|
await call.hangup()
|
|
75
96
|
|
|
76
97
|
expect( call.hangup_cause.sip ).equal( 487 )
|
|
77
|
-
expect( call.hangup_cause.src ).equal( "
|
|
78
|
-
expect( call.hangup_cause.reason ).equal( "
|
|
98
|
+
expect( call.hangup_cause.src ).equal( "us" )
|
|
99
|
+
expect( call.hangup_cause.reason ).equal( "NORMAL_CLEARING" )
|
|
100
|
+
expect( child.hangup_cause.reason ).equal( "BLIND_TRANSFER" )
|
|
79
101
|
|
|
80
102
|
expect( sipcodesent ).to.equal( 202 )
|
|
81
103
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
104
|
+
/* should be the same call */
|
|
105
|
+
expect( call.state.refered ).to.be.true
|
|
106
|
+
expect( referedcall.state.refered ).to.be.true
|
|
107
|
+
expect( referedcall.referingtouri ).to.equal( "sip:alice@atlanta.example.com" )
|
|
108
|
+
|
|
109
|
+
expect( referedcall.referedby.uuid ).to.equal( child.uuid )
|
|
110
|
+
|
|
111
|
+
/* the child (the xferer) finishes with sending BYE */
|
|
112
|
+
child._onhangup( "wire" )
|
|
85
113
|
|
|
86
114
|
} )
|
|
87
115
|
|