@babblevoice/babble-drachtio-callmanager 2.2.7 → 2.3.1
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 +4 -1
- package/lib/store.js +44 -27
- package/package.json +1 -1
- package/test/unit/store.js +7 -7
package/lib/call.js
CHANGED
|
@@ -130,6 +130,7 @@ class call {
|
|
|
130
130
|
@property { boolean } authed
|
|
131
131
|
@property { boolean } cleaned
|
|
132
132
|
@property { boolean } refered
|
|
133
|
+
@property { boolean } picked
|
|
133
134
|
*/
|
|
134
135
|
|
|
135
136
|
/** @member { callstate } */
|
|
@@ -143,7 +144,8 @@ class call {
|
|
|
143
144
|
"held": false,
|
|
144
145
|
"authed": false,
|
|
145
146
|
"cleaned": false,
|
|
146
|
-
"refered": false
|
|
147
|
+
"refered": false,
|
|
148
|
+
"picked": false
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
/**
|
|
@@ -873,6 +875,7 @@ class call {
|
|
|
873
875
|
It wuld be normal to bridge this call to another after this call has been made.
|
|
874
876
|
*/
|
|
875
877
|
pick() {
|
|
878
|
+
this.state.picked = true
|
|
876
879
|
this._em.emit( "call.pick", this )
|
|
877
880
|
}
|
|
878
881
|
|
package/lib/store.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
let storebycallid = new Map()
|
|
4
4
|
let storebyuuid = new Map()
|
|
5
5
|
let storebyentity = new Map()
|
|
6
|
-
let
|
|
6
|
+
let storebyrealm = new Map()
|
|
7
7
|
|
|
8
8
|
/** @module store */
|
|
9
9
|
|
|
@@ -104,6 +104,7 @@ function fixentity( c ) {
|
|
|
104
104
|
* @param {object} c.entity - entity object
|
|
105
105
|
* @param {object} c.entity.uri
|
|
106
106
|
* @param {object} c._entity
|
|
107
|
+
* @param {object} c.destination
|
|
107
108
|
* @param {object} [ c._state ]
|
|
108
109
|
* @param {boolean} [ c._state._hangup ]
|
|
109
110
|
* @return {Promise} - which resolves on completion (for future in case we support redis or similar)
|
|
@@ -118,21 +119,29 @@ module.exports.set = async ( c ) => {
|
|
|
118
119
|
storebyuuid.set( c.uuid, c )
|
|
119
120
|
addtocallidset( c )
|
|
120
121
|
|
|
122
|
+
let realm = ""
|
|
123
|
+
const destination = c.destination
|
|
124
|
+
if( destination ) realm = c.destination.host
|
|
125
|
+
|
|
121
126
|
const entity = fixentity( c )
|
|
122
|
-
if( "boolean"
|
|
127
|
+
if( "boolean" !== typeof entity ) {
|
|
128
|
+
|
|
129
|
+
let storedentity = storebyentity.get( entity.uri )
|
|
130
|
+
if( !storedentity ) {
|
|
131
|
+
storedentity = new Map()
|
|
132
|
+
storebyentity.set( entity.uri, storedentity )
|
|
133
|
+
}
|
|
123
134
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
storedentity = new Map()
|
|
127
|
-
storebyentity.set( entity.uri, storedentity )
|
|
135
|
+
storedentity.set( c.uuid, c )
|
|
136
|
+
realm = entity.realm
|
|
128
137
|
}
|
|
129
138
|
|
|
130
|
-
|
|
139
|
+
if( !realm ) return true
|
|
131
140
|
|
|
132
|
-
let storedentityrealm =
|
|
141
|
+
let storedentityrealm = storebyrealm.get( realm )
|
|
133
142
|
if( !storedentityrealm ) {
|
|
134
143
|
storedentityrealm = new Map()
|
|
135
|
-
|
|
144
|
+
storebyrealm.set( realm, storedentityrealm )
|
|
136
145
|
}
|
|
137
146
|
storedentityrealm.set( c.uuid, c )
|
|
138
147
|
|
|
@@ -154,11 +163,14 @@ module.exports.getbyentity = async ( uri ) => {
|
|
|
154
163
|
* @param {string} realm - the entity realm
|
|
155
164
|
* @return {Promise} which resolves to either a set containing calls for this entity or undefined
|
|
156
165
|
*/
|
|
157
|
-
module.exports.
|
|
158
|
-
if( !
|
|
159
|
-
return
|
|
166
|
+
module.exports.getbyrealm = async ( realm ) => {
|
|
167
|
+
if( !storebyrealm.has( realm ) ) return false
|
|
168
|
+
return storebyrealm.get( realm )
|
|
160
169
|
}
|
|
161
170
|
|
|
171
|
+
/* backwards compat - is now realm more generally */
|
|
172
|
+
module.exports.getbyentityrealm = module.exports.getbyrealm
|
|
173
|
+
|
|
162
174
|
/**
|
|
163
175
|
* Returns a unique call by call id and sip tags.
|
|
164
176
|
* @param {object} sip - sip params required
|
|
@@ -201,22 +213,27 @@ module.exports.delete = async function( c ) {
|
|
|
201
213
|
|
|
202
214
|
deletefromcallidset( c )
|
|
203
215
|
|
|
204
|
-
|
|
205
|
-
|
|
216
|
+
let realm = ""
|
|
217
|
+
const destination = c.destination
|
|
218
|
+
if( destination ) realm = c.destination.host
|
|
206
219
|
|
|
207
|
-
const
|
|
208
|
-
if(
|
|
209
|
-
entityentries.
|
|
210
|
-
if(
|
|
211
|
-
|
|
220
|
+
const entity = fixentity( c )
|
|
221
|
+
if( "boolean" !== typeof entity ) {
|
|
222
|
+
const entityentries = storebyentity.get( entity.uri )
|
|
223
|
+
if( undefined !== entityentries ) {
|
|
224
|
+
entityentries.delete( c.uuid )
|
|
225
|
+
if( 0 === entityentries.size ) {
|
|
226
|
+
storebyentity.delete( entity.uri )
|
|
227
|
+
}
|
|
212
228
|
}
|
|
229
|
+
realm = entity.realm
|
|
213
230
|
}
|
|
214
231
|
|
|
215
|
-
const
|
|
216
|
-
if(
|
|
217
|
-
|
|
218
|
-
if( 0 ===
|
|
219
|
-
|
|
232
|
+
const storedrealm = storebyrealm.get( realm )
|
|
233
|
+
if( storedrealm ) {
|
|
234
|
+
storedrealm.delete( c.uuid )
|
|
235
|
+
if( 0 === storedrealm.size ) {
|
|
236
|
+
storebyrealm.delete( entity.realm )
|
|
220
237
|
}
|
|
221
238
|
}
|
|
222
239
|
}
|
|
@@ -228,7 +245,7 @@ module.exports.clear = async() => {
|
|
|
228
245
|
storebycallid = new Map()
|
|
229
246
|
storebyuuid = new Map()
|
|
230
247
|
storebyentity = new Map()
|
|
231
|
-
|
|
248
|
+
storebyrealm = new Map()
|
|
232
249
|
}
|
|
233
250
|
|
|
234
251
|
/**
|
|
@@ -239,7 +256,7 @@ module.exports.stats = async () => {
|
|
|
239
256
|
"storebycallid": storebycallid.size,
|
|
240
257
|
"storebyuuid": storebyuuid.size,
|
|
241
258
|
"storebyentity": storebyentity.size,
|
|
242
|
-
"
|
|
259
|
+
"storebyrealm": storebyrealm.size
|
|
243
260
|
}
|
|
244
261
|
}
|
|
245
262
|
|
|
@@ -247,5 +264,5 @@ module.exports.stats = async () => {
|
|
|
247
264
|
* Debug only
|
|
248
265
|
*/
|
|
249
266
|
module.exports._dump = () => {
|
|
250
|
-
console.log( storebycallid, storebyuuid, storebyentity,
|
|
267
|
+
console.log( storebycallid, storebyuuid, storebyentity, storebyrealm )
|
|
251
268
|
}
|
package/package.json
CHANGED
package/test/unit/store.js
CHANGED
|
@@ -30,7 +30,7 @@ describe( "callmanager - store", function() {
|
|
|
30
30
|
"storebycallid": 1,
|
|
31
31
|
"storebyuuid": 1,
|
|
32
32
|
"storebyentity": 1,
|
|
33
|
-
"
|
|
33
|
+
"storebyrealm": 1
|
|
34
34
|
} )
|
|
35
35
|
} )
|
|
36
36
|
|
|
@@ -53,7 +53,7 @@ describe( "callmanager - store", function() {
|
|
|
53
53
|
"storebycallid": 1,
|
|
54
54
|
"storebyuuid": 1,
|
|
55
55
|
"storebyentity": 1,
|
|
56
|
-
"
|
|
56
|
+
"storebyrealm": 1
|
|
57
57
|
} )
|
|
58
58
|
|
|
59
59
|
dummycall.sip.tags.local = "4444"
|
|
@@ -63,7 +63,7 @@ describe( "callmanager - store", function() {
|
|
|
63
63
|
"storebycallid": 1,
|
|
64
64
|
"storebyuuid": 1,
|
|
65
65
|
"storebyentity": 1,
|
|
66
|
-
"
|
|
66
|
+
"storebyrealm": 1
|
|
67
67
|
} )
|
|
68
68
|
|
|
69
69
|
let searchfor = {
|
|
@@ -119,7 +119,7 @@ describe( "callmanager - store", function() {
|
|
|
119
119
|
"storebycallid": 2,
|
|
120
120
|
"storebyuuid": 2,
|
|
121
121
|
"storebyentity": 0,
|
|
122
|
-
"
|
|
122
|
+
"storebyrealm": 0
|
|
123
123
|
} )
|
|
124
124
|
|
|
125
125
|
dummycall1._entity = {
|
|
@@ -132,7 +132,7 @@ describe( "callmanager - store", function() {
|
|
|
132
132
|
"storebycallid": 2,
|
|
133
133
|
"storebyuuid": 2,
|
|
134
134
|
"storebyentity": 1,
|
|
135
|
-
"
|
|
135
|
+
"storebyrealm": 1
|
|
136
136
|
} )
|
|
137
137
|
|
|
138
138
|
await callstore.set( dummycall3 )
|
|
@@ -141,7 +141,7 @@ describe( "callmanager - store", function() {
|
|
|
141
141
|
"storebycallid": 3,
|
|
142
142
|
"storebyuuid": 3,
|
|
143
143
|
"storebyentity": 1,
|
|
144
|
-
"
|
|
144
|
+
"storebyrealm": 1
|
|
145
145
|
} )
|
|
146
146
|
|
|
147
147
|
let c = await callstore.getbycallid( dummycall1.sip )
|
|
@@ -158,7 +158,7 @@ describe( "callmanager - store", function() {
|
|
|
158
158
|
"storebycallid": 0,
|
|
159
159
|
"storebyuuid": 0,
|
|
160
160
|
"storebyentity": 0,
|
|
161
|
-
"
|
|
161
|
+
"storebyrealm": 0
|
|
162
162
|
} )
|
|
163
163
|
} )
|
|
164
164
|
} )
|