quickblox 2.15.1 → 2.15.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.
@@ -15,11 +15,15 @@
15
15
  * - onReconnectListener(session, userId, state)
16
16
  */
17
17
 
18
+ /**
19
+ * @namespace QB.webrtc.WebRTCSession
20
+ */
21
+
18
22
  /**
19
23
  * @typedef {Object} MediaParams
20
24
  * @property {boolean | MediaTrackConstraints} [params.audio]
21
25
  * @property {boolean | MediaTrackConstraints} [params.video]
22
- * @property {string} [params.elemId] Id of HTMLVideoElement
26
+ * @property {string} [params.elemId] - Id of HTMLVideoElement.
23
27
  * @property {Object} [params.options]
24
28
  * @property {boolean} [params.options.muted]
25
29
  * @property {boolean} [params.options.mirror]
@@ -52,16 +56,16 @@ var ReconnectionState = {
52
56
 
53
57
 
54
58
  /**
55
- * QuickBlox WebRTC session
59
+ * QuickBlox WebRTC session.
56
60
  * @param {Object} params
57
- * @param {1|2} params.callType Type of a call
61
+ * @param {1|2} params.callType - Type of a call
58
62
  * 1 - VIDEO
59
63
  * 2 - AUDIO
60
- * @param {Array<number>} params.opIDs An array with opponents
61
- * @param {number} params.currentUserID Current user ID
62
- * @param {number} params.initiatorID Call initiator ID
63
- * @param {string} [params.sessionID] Session identifier (optional)
64
- * @param {number} [params.bandwidth] Bandwidth limit
64
+ * @param {Array<number>} params.opIDs - An array with opponents.
65
+ * @param {number} params.currentUserID - Current user ID.
66
+ * @param {number} params.initiatorID - Call initiator ID.
67
+ * @param {string} [params.sessionID] - Session identifier (optional).
68
+ * @param {number} [params.bandwidth] - Bandwidth limit.
65
69
  */
66
70
  function WebRTCSession(params) {
67
71
  this.ID = params.sessionID ? params.sessionID : generateUUID();
@@ -70,13 +74,13 @@ function WebRTCSession(params) {
70
74
  this.initiatorID = parseInt(params.initiatorID);
71
75
  this.opponentsIDs = params.opIDs;
72
76
  this.callType = parseInt(params.callType);
73
- /** @type {{[userId: number]: qbRTCPeerConnection}} */
77
+ /*** @type {{[userId: number]: qbRTCPeerConnection}} */
74
78
  this.peerConnections = {};
75
- /** @type {MediaParams} */
79
+ /*** @type {MediaParams} */
76
80
  this.mediaParams = null;
77
- /** @type {{[userID: number]: number | undefined}} */
81
+ /*** @type {{[userID: number]: number | undefined}} */
78
82
  this.iceConnectTimers = {};
79
- /** @type {{[userID: number]: number | undefined}} */
83
+ /*** @type {{[userID: number]: number | undefined}} */
80
84
  this.reconnectTimers = {};
81
85
 
82
86
  this.signalingProvider = params.signalingProvider;
@@ -85,7 +89,7 @@ function WebRTCSession(params) {
85
89
 
86
90
  this.bandwidth = params.bandwidth;
87
91
 
88
- /**
92
+ /***
89
93
  * We use this timeout to fix next issue:
90
94
  * "From Android/iOS make a call to Web and kill the Android/iOS app instantly. Web accept/reject popup will be still visible.
91
95
  * We need a way to hide it if sach situation happened."
@@ -94,14 +98,16 @@ function WebRTCSession(params) {
94
98
 
95
99
  this.startCallTime = 0;
96
100
  this.acceptCallTime = 0;
97
- /** @type {MediaStream | undefined} */
101
+ /*** @type {MediaStream | undefined} */
98
102
  this.localStream = undefined;
99
103
  }
100
104
 
101
105
  /**
102
- * Get the user media stream
103
- * @param {MediaParams} params media stream constraints and additional options
104
- * @param {Function} callback callback to get a result of the function
106
+ * Get the user media stream({@link https://docs.quickblox.com/docs/js-video-calling#access-local-media-stream read more}).
107
+ * @function getUserMedia
108
+ * @memberof QB.webrtc.WebRTCSession
109
+ * @param {MediaParams} params - Media stream constraints and additional options.
110
+ * @param {Function} callback - Callback to get a result of the function.
105
111
  */
106
112
  WebRTCSession.prototype.getUserMedia = function (params, callback) {
107
113
  if (!navigator.mediaDevices.getUserMedia) {
@@ -135,8 +141,10 @@ WebRTCSession.prototype.getUserMedia = function (params, callback) {
135
141
  };
136
142
 
137
143
  /**
138
- * Get the state of connection
139
- * @param {number} The User Id
144
+ * Get the state of connection.
145
+ * @function connectionStateForUser
146
+ * @memberof QB.webrtc.WebRTCSession
147
+ * @param {number} userID
140
148
  */
141
149
  WebRTCSession.prototype.connectionStateForUser = function (userID) {
142
150
  var peerConnection = this.peerConnections[userID];
@@ -144,12 +152,14 @@ WebRTCSession.prototype.connectionStateForUser = function (userID) {
144
152
  };
145
153
 
146
154
  /**
147
- * Attach media stream to audio/video element
148
- * @param {string} elementId The Id of an ellement to attach a stream
149
- * @param {MediaStream} stream The stream to attach
150
- * @param {Object} [options] The additional options
151
- * @param {boolean} [options.muted] Whether video element should be muted
152
- * @param {boolean} [options.mirror] Whether video should be "mirrored"
155
+ * Attach media stream to audio/video element({@link https://docs.quickblox.com/docs/js-video-calling#attach-local-media-stream read more}).
156
+ * @function attachMediaStream
157
+ * @memberof QB.webrtc.WebRTCSession
158
+ * @param {string} elementId - The Id of an ellement to attach a stream.
159
+ * @param {MediaStream} stream - The stream to attach.
160
+ * @param {Object} [options] - The additional options.
161
+ * @param {boolean} [options.muted] - Whether video element should be muted.
162
+ * @param {boolean} [options.mirror] - Whether video should be "mirrored".
153
163
  */
154
164
  WebRTCSession.prototype.attachMediaStream = function (elementId, stream, options) {
155
165
  var elem = document.getElementById(elementId);
@@ -184,8 +194,10 @@ WebRTCSession.prototype.attachMediaStream = function (elementId, stream, options
184
194
  };
185
195
 
186
196
  /**
187
- * Detach media stream from audio/video element
188
- * @param {string} elementId The Id of an element to detach a stream
197
+ * Detach media stream from audio/video element.
198
+ * @function detachMediaStream
199
+ * @memberof QB.webrtc.WebRTCSession
200
+ * @param {string} elementId - The Id of an element to detach a stream.
189
201
  */
190
202
  WebRTCSession.prototype.detachMediaStream = function (elementId) {
191
203
  var elem = document.getElementById(elementId);
@@ -209,11 +221,13 @@ WebRTCSession.prototype.detachMediaStream = function (elementId) {
209
221
  };
210
222
 
211
223
  /**
212
- * Switch media tracks in audio/video HTML's element and replace its in peers.
213
- * @param {Object} deviceIds - the object with deviceIds of plugged devices
214
- * @param {string} [deviceIds.audio] - the deviceId, it can be gotten from QB.webrtc.getMediaDevices('audioinput')
215
- * @param {string} [deviceIds.video] - the deviceId, it can be gotten from QB.webrtc.getMediaDevices('videoinput')
216
- * @param {Function} callback - the callback to get a result of the function
224
+ * Switch media tracks in audio/video HTML's element and replace its in peers({@link https://docs.quickblox.com/docs/js-video-calling-advanced#switch-camera read more}).
225
+ * @function switchMediaTracks
226
+ * @memberof QB.webrtc.WebRTCSession
227
+ * @param {Object} deviceIds - An object with deviceIds of plugged devices.
228
+ * @param {string} [deviceIds.audio] - The deviceId, it can be gotten from QB.webrtc.getMediaDevices('audioinput').
229
+ * @param {string} [deviceIds.video] - The deviceId, it can be gotten from QB.webrtc.getMediaDevices('videoinput').
230
+ * @param {Function} callback - The callback to get a result of the function.
217
231
  */
218
232
  WebRTCSession.prototype.switchMediaTracks = function (deviceIds, callback) {
219
233
  if (!navigator.mediaDevices.getUserMedia) {
@@ -269,7 +283,7 @@ WebRTCSession.prototype._replaceTracks = function (stream) {
269
283
  this.attachMediaStream(elemId, stream, ops);
270
284
  }
271
285
 
272
- /** @param {RTCPeerConnection} peer */
286
+ /*** @param {RTCPeerConnection} peer */
273
287
  function _replaceTracksForPeer(peer) {
274
288
  return Promise.all(peer.getSenders().map(function (sender) {
275
289
  return sender.replaceTrack(newStreamTracks.find(function (track) {
@@ -286,8 +300,10 @@ WebRTCSession.prototype._replaceTracks = function (stream) {
286
300
  };
287
301
 
288
302
  /**
289
- * Initiate a call
290
- * @param {Object} [extension] [custom parametrs]
303
+ * Initiate a call({@link https://docs.quickblox.com/docs/js-video-calling#make-a-call read more}).
304
+ * @function call
305
+ * @memberof QB.webrtc.WebRTCSession
306
+ * @param {Object} [extension] - A map with a custom parametrs .
291
307
  * @param {Function} [callback]
292
308
  */
293
309
  WebRTCSession.prototype.call = function (extension, callback) {
@@ -331,8 +347,10 @@ WebRTCSession.prototype._callInternal = function (userID, extension) {
331
347
  };
332
348
 
333
349
  /**
334
- * Accept a call
335
- * @param {Object} extension A map with custom parameters
350
+ * Accept a call({@link https://docs.quickblox.com/docs/js-video-calling#accept-a-call read more}).
351
+ * @function accept
352
+ * @memberof QB.webrtc.WebRTCSession
353
+ * @param {Object} extension - A map with custom parameters.
336
354
  */
337
355
  WebRTCSession.prototype.accept = function (extension) {
338
356
  var self = this,
@@ -429,8 +447,10 @@ WebRTCSession.prototype._acceptInternal = function (userID, extension) {
429
447
  };
430
448
 
431
449
  /**
432
- * Reject a call
433
- * @param {Object} A map with custom parameters
450
+ * Reject a call({@link https://docs.quickblox.com/docs/js-video-calling#reject-a-call read more}).
451
+ * @function reject
452
+ * @memberof QB.webrtc.WebRTCSession
453
+ * @param {Object} extension - A map with custom parameters.
434
454
  */
435
455
  WebRTCSession.prototype.reject = function (extension) {
436
456
  var self = this,
@@ -460,8 +480,10 @@ WebRTCSession.prototype.reject = function (extension) {
460
480
  };
461
481
 
462
482
  /**
463
- * Stop a call
464
- * @param {Object} A map with custom parameters
483
+ * Stop a call({@link https://docs.quickblox.com/docs/js-video-calling#end-a-call read more}).
484
+ * @function stop
485
+ * @memberof QB.webrtc.WebRTCSession
486
+ * @param {Object} extension - A map with custom parameters.
465
487
  */
466
488
  WebRTCSession.prototype.stop = function (extension) {
467
489
  var self = this,
@@ -493,8 +515,10 @@ WebRTCSession.prototype.stop = function (extension) {
493
515
  };
494
516
 
495
517
  /**
496
- * [function close connection with user]
497
- * @param {Number} userId [id of user]
518
+ * Close connection with a user.
519
+ * @function closeConnection
520
+ * @memberof QB.webrtc.WebRTCSession
521
+ * @param {Number} userId - Id of a user.
498
522
  */
499
523
  WebRTCSession.prototype.closeConnection = function (userId) {
500
524
  var self = this,
@@ -516,8 +540,10 @@ WebRTCSession.prototype.closeConnection = function (userId) {
516
540
 
517
541
 
518
542
  /**
519
- * Update a call
520
- * @param {Object} extension A map with custom parameters
543
+ * Update a call.
544
+ * @function update
545
+ * @memberof QB.webrtc.WebRTCSession
546
+ * @param {Object} extension - A map with custom parameters.
521
547
  * @param {number} [userID]
522
548
  */
523
549
  WebRTCSession.prototype.update = function (extension, userID) {
@@ -555,16 +581,20 @@ WebRTCSession.prototype.update = function (extension, userID) {
555
581
  };
556
582
 
557
583
  /**
558
- * Mutes the stream
559
- * @param {string} what to mute: 'audio' or 'video'
584
+ * Mutes the stream({@link https://docs.quickblox.com/docs/js-video-calling-advanced#mute-audio read more}).
585
+ * @function mute
586
+ * @memberof QB.webrtc.WebRTCSession
587
+ * @param {string} type - 'audio' or 'video'
560
588
  */
561
589
  WebRTCSession.prototype.mute = function (type) {
562
590
  this._muteStream(0, type);
563
591
  };
564
592
 
565
593
  /**
566
- * Unmutes the stream
567
- * @param {string} what to unmute: 'audio' or 'video'
594
+ * Unmutes the stream({@link https://docs.quickblox.com/docs/js-video-calling-advanced#mute-audio read more}).
595
+ * @function unmute
596
+ * @memberof QB.webrtc.WebRTCSession
597
+ * @param {string} type - 'audio' or 'video'
568
598
  */
569
599
  WebRTCSession.prototype.unmute = function (type) {
570
600
  this._muteStream(1, type);
@@ -746,7 +776,7 @@ WebRTCSession.prototype._processReconnectOffer = function (userID, SRD) {
746
776
 
747
777
  /**
748
778
  * @param {number} userID
749
- * @param {RTCSessionDescriptionInit & { offerId: string }} SRD
779
+ * @param {RTCSessionDescriptionInit} SRD
750
780
  */
751
781
  WebRTCSession.prototype._processReconnectAnswer = function (userID, SRD) {
752
782
  var peer = this.peerConnections[userID];
@@ -45,7 +45,7 @@ function StreamManagement(options) {
45
45
 
46
46
  this._intervalId = null;
47
47
 
48
- this._timeInterval = 2000;
48
+ this._timeInterval = Utils.getTimeIntervalForCallBackMessage();
49
49
 
50
50
  this.sentMessageCallback = null;
51
51
 
@@ -214,14 +214,17 @@ StreamManagement.prototype.getClientSentStanzasCounter = function(){
214
214
  };
215
215
 
216
216
  StreamManagement.prototype._checkCounterOnIncomeStanza = function (count){
217
- if (this._stanzasQueue.length) {
218
- if (this._stanzasQueue[0].expect !== count){
219
- this.sentMessageCallback(this._stanzasQueue[0].message);
220
- } else {
221
- this.sentMessageCallback(null, this._stanzasQueue[0].message);
217
+ var updatedStanzasQueue = [];
218
+
219
+ if(this._stanzasQueue.length){
220
+ for(var i = 0; i < this._stanzasQueue.length; i++){
221
+ if(this._stanzasQueue[i].expect == count){
222
+ this.sentMessageCallback(null, this._stanzasQueue[i].message);
223
+ } else {
224
+ updatedStanzasQueue.push(this._stanzasQueue[i]);
225
+ }
222
226
  }
223
-
224
- this._stanzasQueue.shift();
227
+ this._stanzasQueue = updatedStanzasQueue;
225
228
  }
226
229
  };
227
230
 
package/src/qbConfig.js CHANGED
@@ -12,8 +12,8 @@
12
12
  */
13
13
 
14
14
  var config = {
15
- version: '2.15.1',
16
- buildNumber: '1139',
15
+ version: '2.15.2',
16
+ buildNumber: '1144',
17
17
  creds: {
18
18
  'appId': 0,
19
19
  'authKey': '',
@@ -79,6 +79,7 @@ var config = {
79
79
  addISOTime: false,
80
80
  qbTokenExpirationDate: null,
81
81
  liveSessionInterval: 120,
82
+ callBackInterval: 30,
82
83
  };
83
84
 
84
85
  config.set = function(options) {
package/src/qbMain.js CHANGED
@@ -29,6 +29,7 @@ QuickBlox.prototype = {
29
29
 
30
30
  /**
31
31
  * @memberof QB
32
+ * Initialize QuickBlox SDK({@link https://docs.quickblox.com/docs/js-setup#initialize-quickblox-sdk read more})
32
33
  * @param {Number | String} appIdOrToken - Application ID (from your admin panel) or Session Token.
33
34
  * @param {String | Number} authKeyOrAppId - Authorization key or Application ID. You need to set up Application ID if you use session token as appIdOrToken parameter.
34
35
  * @param {String} authSecret - Authorization secret key (from your admin panel).
@@ -133,7 +134,7 @@ QuickBlox.prototype = {
133
134
  },
134
135
 
135
136
  /**
136
- * Init QuickBlox SDK with User Account data for start session with token.
137
+ * Init QuickBlox SDK with User Account data to start session with token({@link https://docs.quickblox.com/docs/js-setup#initialize-quickblox-sdk-without-authorization-key-and-secret read more}).
137
138
  * @memberof QB
138
139
  * @param {Number} appId - Application ID (from your admin panel).
139
140
  * @param {String | Number} accountKey - Account key (from your admin panel).
@@ -153,28 +154,28 @@ QuickBlox.prototype = {
153
154
  },
154
155
 
155
156
  /**
156
- * Return current session
157
+ * Return current session({@link https://docs.quickblox.com/docs/js-authentication#get-session read more}).
157
158
  * @memberof QB
158
159
  * @param {getSessionCallback} callback - The getSessionCallback function.
159
160
  * */
160
161
  getSession: function(callback) {
161
162
  /**
162
- * This callback return session object.
163
+ * This callback return session object..
163
164
  * @callback getSessionCallback
164
- * @param {Object} error - The error object
165
- * @param {Object} session - Contains of session object
165
+ * @param {Object} error - The error object.
166
+ * @param {Object} session - Contains of session object.
166
167
  * */
167
168
  this.auth.getSession(callback);
168
169
  },
169
170
 
170
171
  /**
171
- * Set up user session token to current session and return it
172
+ * Set up user session token to current session and return it({@link https://docs.quickblox.com/docs/js-authentication#set-existing-session read more}).
172
173
  * @memberof QB
173
- * @param {String} token - a User Session Token
174
+ * @param {String} token - A User Session Token.
174
175
  * @param {getSessionCallback} callback - The getSessionCallback function.
175
176
  * @callback getSessionCallback
176
- * @param {Object} error - The error object
177
- * @param {Object} session - Contains of session object
177
+ * @param {Object} error - The error object.
178
+ * @param {Object} session - Contains of session object.
178
179
  * */
179
180
  startSessionWithToken: function(token, callback) {
180
181
  if (token === undefined) throw new Error('Cannot start session with undefined token');
@@ -202,23 +203,23 @@ QuickBlox.prototype = {
202
203
  },
203
204
 
204
205
  /**
205
- * Creat new session. {@link https://quickblox.com/developers/Javascript#Authorization More info}
206
+ * Create new session({@link https://docs.quickblox.com/docs/js-authentication#create-session read more}).
206
207
  * @memberof QB
207
208
  * @param {String} appIdOrToken Should be applecationID or QBtoken.
208
- * @param {createSessionCallback} callback -
209
+ * @param {createSessionCallback} callback
209
210
  * */
210
211
  createSession: function(params, callback) {
211
212
  /**
212
213
  * This callback return session object.
213
214
  * @callback createSession
214
- * @param {Object} error - The error object
215
- * @param {Object} session - Contains of session object
215
+ * @param {Object} error - The error object.
216
+ * @param {Object} session - Contains of session object.
216
217
  * */
217
218
  this.auth.createSession(params, callback);
218
219
  },
219
220
 
220
221
  /**
221
- * Destroy current session. {@link https://quickblox.com/developers/Authentication_and_Authorization#API_Session_Destroy More info}
222
+ * Destroy current session({@link https://docs.quickblox.com/docs/js-authentication#destroy-session-token read more}).
222
223
  * @memberof QB
223
224
  * @param {destroySessionCallback} callback - The destroySessionCallback function.
224
225
  * */
@@ -233,7 +234,7 @@ QuickBlox.prototype = {
233
234
  },
234
235
 
235
236
  /**
236
- * Login to QuickBlox application. {@link https://quickblox.com/developers/Javascript#Authorization More info}
237
+ * Login to QuickBlox application({@link https://docs.quickblox.com/docs/js-authentication#log-in-user read more}).
237
238
  * @memberof QB
238
239
  * @param {Object} params - Params object for login into the session.
239
240
  * @param {loginCallback} callback - The loginCallback function.
@@ -249,7 +250,7 @@ QuickBlox.prototype = {
249
250
  },
250
251
 
251
252
  /**
252
- * Remove user from current session, but doesn't destroy it.
253
+ * Remove user from current session, but doesn't destroy it({@link https://docs.quickblox.com/docs/js-authentication#log-out-user read more}).
253
254
  * @memberof QB
254
255
  * @param {logoutCallback} callback - The logoutCallback function.
255
256
  * */
package/src/qbUtils.js CHANGED
@@ -320,8 +320,12 @@ var Utils = {
320
320
  merged.push(newItem);
321
321
  }
322
322
  return merged;
323
- }
323
+ },
324
324
 
325
+ getTimeIntervalForCallBackMessage: function() {
326
+ const timeInterval = typeof config.callBackInterval === 'undefined' ? 2 : config.callBackInterval;
327
+ return timeInterval * 1000;
328
+ }
325
329
  };
326
330
 
327
331
  module.exports = Utils;