quickblox 2.14.1 → 2.15.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/README.md +1 -1
- package/package.json +1 -1
- package/quickblox.js +20909 -21018
- package/quickblox.min.js +1 -1
- package/src/modules/chat/qbChat.js +168 -48
- package/src/modules/webrtc/qbRTCPeerConnection.js +446 -306
- package/src/modules/webrtc/qbWebRTCClient.js +43 -21
- package/src/modules/webrtc/qbWebRTCHelpers.js +60 -36
- package/src/modules/webrtc/qbWebRTCSession.js +640 -408
- package/src/modules/webrtc/qbWebRTCSignalingProcessor.js +57 -52
- package/src/modules/webrtc/qbWebRTCSignalingProvider.js +24 -20
- package/src/qbConfig.js +13 -15
- package/src/qbMain.js +27 -17
- package/src/qbProxy.js +2 -3
- package/src/qbUtils.js +1 -0
|
@@ -87,7 +87,7 @@ function ChatProxy(service) {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
this.service = service;
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
// Check the chat connection (return true/false)
|
|
92
92
|
this.isConnected = false;
|
|
93
93
|
// Check the chat connecting state (return true/false)
|
|
@@ -95,7 +95,9 @@ function ChatProxy(service) {
|
|
|
95
95
|
this._isLogout = false;
|
|
96
96
|
|
|
97
97
|
this._checkConnectionTimer = undefined;
|
|
98
|
-
|
|
98
|
+
this._checkConnectionPingTimer = undefined;
|
|
99
|
+
this._localPingFaildCounter = 0;
|
|
100
|
+
this._onlineStatus = true;
|
|
99
101
|
this._checkExpiredSessionTimer = undefined;
|
|
100
102
|
this._sessionHasExpired = false;
|
|
101
103
|
this._pings = {};
|
|
@@ -741,7 +743,10 @@ ChatProxy.prototype = {
|
|
|
741
743
|
|
|
742
744
|
/** Connect for browser env. */
|
|
743
745
|
if (Utils.getEnv().browser) {
|
|
746
|
+
Utils.QBLog('[QBChat]', '!!---Browser env - connected--!!');
|
|
747
|
+
|
|
744
748
|
self.connection.connect(userJid, params.password, function(status) {
|
|
749
|
+
Utils.QBLog('[QBChat]', 'self.connection.connect called with status '+ status);
|
|
745
750
|
switch (status) {
|
|
746
751
|
case Strophe.Status.ERROR:
|
|
747
752
|
self.isConnected = false;
|
|
@@ -772,7 +777,7 @@ ChatProxy.prototype = {
|
|
|
772
777
|
case Strophe.Status.AUTHFAIL:
|
|
773
778
|
self.isConnected = false;
|
|
774
779
|
self._isConnecting = false;
|
|
775
|
-
|
|
780
|
+
|
|
776
781
|
err = Utils.getError(401, 'Status.AUTHFAIL - The authentication attempt failed', 'QBChat');
|
|
777
782
|
|
|
778
783
|
if (isInitialConnect) {
|
|
@@ -780,7 +785,6 @@ ChatProxy.prototype = {
|
|
|
780
785
|
}
|
|
781
786
|
|
|
782
787
|
if(!self.isConnected && typeof self.onReconnectFailedListener === 'function'){
|
|
783
|
-
// TODO: investigate problem reconnect field
|
|
784
788
|
Utils.safeCallbackCall(self.onReconnectFailedListener, err);
|
|
785
789
|
}
|
|
786
790
|
|
|
@@ -802,26 +806,44 @@ ChatProxy.prototype = {
|
|
|
802
806
|
self.connection.XAddTrackedHandler(self._onSystemMessageListener, null, 'message', 'headline');
|
|
803
807
|
self.connection.XAddTrackedHandler(self._onMessageErrorListener, null, 'message', 'error');
|
|
804
808
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
809
|
+
var noTimerId = typeof self._checkConnectionPingTimer === 'undefined';
|
|
810
|
+
noTimerId = config.pingLocalhostTimeInterval === 0 ? false : noTimerId;
|
|
811
|
+
|
|
812
|
+
if (noTimerId) {
|
|
813
|
+
Utils.QBLog('[QBChat]', 'Init ping to localhost at ', Utils.getCurrentTime());
|
|
814
|
+
self._checkConnectionPingTimer = setInterval(function() {
|
|
815
|
+
try {
|
|
816
|
+
self.pinglocalhost(function (error) {
|
|
817
|
+
if (error) {
|
|
818
|
+
Utils.QBLog('[QBChat]',
|
|
819
|
+
'Local Ping: ',
|
|
820
|
+
'failed, at ', Utils.getCurrentTime(),
|
|
821
|
+
'_localPingFaildCounter: ', self._localPingFaildCounter,
|
|
822
|
+
' error: ', error);
|
|
823
|
+
self._localPingFaildCounter += 1;
|
|
824
|
+
if (self._localPingFaildCounter > 6) {
|
|
825
|
+
self.isConnected = false;
|
|
826
|
+
self._isConnecting = false;
|
|
827
|
+
self._localPingFaildCounter = 0;
|
|
828
|
+
self._establishConnection(params);
|
|
829
|
+
}
|
|
830
|
+
} else {
|
|
831
|
+
Utils.QBLog('[QBChat]',
|
|
832
|
+
'Local Ping: ',
|
|
833
|
+
'ok, at ', Utils.getCurrentTime(),
|
|
834
|
+
'_localPingFaildCounter: ', self._localPingFaildCounter);
|
|
835
|
+
self._localPingFaildCounter = 0;
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
catch (err) {
|
|
840
|
+
Utils.QBLog('[QBChat]',
|
|
841
|
+
'Local Ping: ',
|
|
842
|
+
'Exception, at ', Utils.getCurrentTime(),
|
|
843
|
+
', detail info: ', err);
|
|
844
|
+
}
|
|
845
|
+
}, config.pingLocalhostTimeInterval * 1000);
|
|
846
|
+
}
|
|
825
847
|
|
|
826
848
|
if (typeof self.onSessionExpiredListener === 'function') {
|
|
827
849
|
var noExpiredSessionTimerId = typeof self._checkExpiredSessionTimer === 'undefined';
|
|
@@ -831,15 +853,12 @@ ChatProxy.prototype = {
|
|
|
831
853
|
var timeNow = new Date();
|
|
832
854
|
if (typeof config.qbTokenExpirationDate !== 'undefined') {
|
|
833
855
|
var timeLag = Math.round((timeNow.getTime() - config.qbTokenExpirationDate.getTime()) / (1000 * 60));
|
|
834
|
-
//artan 25-08-2022
|
|
835
|
-
// TODO: need to delete in task [CROS-815]
|
|
836
|
-
console.log('timeLag: ', timeLag);
|
|
837
856
|
if (timeLag >= 0) {
|
|
838
857
|
self._sessionHasExpired = true;
|
|
839
858
|
Utils.safeCallbackCall(self.onSessionExpiredListener, null);
|
|
840
859
|
}
|
|
841
860
|
}
|
|
842
|
-
// TODO: in task [CROS-
|
|
861
|
+
// TODO: in task [CROS-823], may by need to change 5 * 1000 to config.liveSessionInterval * 1000
|
|
843
862
|
}, 5 * 1000);
|
|
844
863
|
|
|
845
864
|
}
|
|
@@ -878,6 +897,7 @@ ChatProxy.prototype = {
|
|
|
878
897
|
|
|
879
898
|
/** connect for node */
|
|
880
899
|
if(!Utils.getEnv().browser) {
|
|
900
|
+
Utils.QBLog('[QBChat]', '!!--call branch code connect for node--!!');
|
|
881
901
|
// Remove all connection handlers exist from a previous connection
|
|
882
902
|
self.Client.removeAllListeners();
|
|
883
903
|
|
|
@@ -978,7 +998,7 @@ ChatProxy.prototype = {
|
|
|
978
998
|
}
|
|
979
999
|
|
|
980
1000
|
self.helpers.setUserCurrentJid(self.helpers.userCurrentJid(xmppClient));
|
|
981
|
-
|
|
1001
|
+
|
|
982
1002
|
self.isConnected = true;
|
|
983
1003
|
self._isConnecting = false;
|
|
984
1004
|
self._sessionHasExpired = false;
|
|
@@ -1010,7 +1030,6 @@ ChatProxy.prototype = {
|
|
|
1010
1030
|
},
|
|
1011
1031
|
|
|
1012
1032
|
_establishConnection: function(params) {
|
|
1013
|
-
// TODO: must to call if only qbTokenExpirationDate is not expried
|
|
1014
1033
|
var self = this;
|
|
1015
1034
|
Utils.QBLog('[QBChat]', '_establishConnection called');
|
|
1016
1035
|
if (self._isLogout || self._checkConnectionTimer) {
|
|
@@ -1032,13 +1051,27 @@ ChatProxy.prototype = {
|
|
|
1032
1051
|
|
|
1033
1052
|
_connect();
|
|
1034
1053
|
|
|
1035
|
-
|
|
1036
|
-
// TODO: investigate problem with interval connection
|
|
1037
1054
|
self._checkConnectionTimer = setInterval(function() {
|
|
1055
|
+
Utils.QBLog('[QBChat]', 'self._checkConnectionTimer called with config.chatReconnectionTimeInterval = '+config.chatReconnectionTimeInterval);
|
|
1038
1056
|
_connect();
|
|
1039
1057
|
}, config.chatReconnectionTimeInterval * 1000);
|
|
1040
1058
|
},
|
|
1041
1059
|
|
|
1060
|
+
reconnect: function () {
|
|
1061
|
+
Utils.QBLog('[QBChat]', 'Call reconnect ');
|
|
1062
|
+
clearInterval(this._checkConnectionTimer);
|
|
1063
|
+
this._checkConnectionTimer = undefined;
|
|
1064
|
+
this.muc.joinedRooms = {};
|
|
1065
|
+
this.helpers.setUserCurrentJid('');
|
|
1066
|
+
|
|
1067
|
+
if (Utils.getEnv().browser) {
|
|
1068
|
+
this.connection.flush();
|
|
1069
|
+
this.connection.disconnect();
|
|
1070
|
+
} else {
|
|
1071
|
+
this.Client.end();
|
|
1072
|
+
}
|
|
1073
|
+
},
|
|
1074
|
+
|
|
1042
1075
|
/**
|
|
1043
1076
|
* Send message to 1 to 1 or group dialog. {@link https://quickblox.com/developers/Web_XMPP_Chat_Sample#Chat_in_dialog More info.}
|
|
1044
1077
|
* @memberof QB.chat
|
|
@@ -1174,12 +1207,10 @@ ChatProxy.prototype = {
|
|
|
1174
1207
|
xmlns: chatUtils.MARKERS.STATES
|
|
1175
1208
|
});
|
|
1176
1209
|
|
|
1177
|
-
if
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
self.Client.send(stanza);
|
|
1182
|
-
}
|
|
1210
|
+
if(Utils.getEnv().browser){
|
|
1211
|
+
self.connection.send(stanza);
|
|
1212
|
+
} else {
|
|
1213
|
+
self.Client.send(stanza);
|
|
1183
1214
|
}
|
|
1184
1215
|
},
|
|
1185
1216
|
|
|
@@ -1204,12 +1235,10 @@ ChatProxy.prototype = {
|
|
|
1204
1235
|
xmlns: chatUtils.MARKERS.STATES
|
|
1205
1236
|
});
|
|
1206
1237
|
|
|
1207
|
-
if
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
self.Client.send(stanza);
|
|
1212
|
-
}
|
|
1238
|
+
if(Utils.getEnv().browser){
|
|
1239
|
+
self.connection.send(stanza);
|
|
1240
|
+
} else {
|
|
1241
|
+
self.Client.send(stanza);
|
|
1213
1242
|
}
|
|
1214
1243
|
},
|
|
1215
1244
|
|
|
@@ -1320,7 +1349,8 @@ ChatProxy.prototype = {
|
|
|
1320
1349
|
}
|
|
1321
1350
|
},
|
|
1322
1351
|
|
|
1323
|
-
|
|
1352
|
+
pinglocalhost: function(callback){
|
|
1353
|
+
Utils.QBLog('[QBChat]', 'ping localhost');
|
|
1324
1354
|
var self = this;
|
|
1325
1355
|
var id = this.helpers.getUniqueId('ping');
|
|
1326
1356
|
var builder = Utils.getEnv().browser ? $iq : XMPP.Stanza;
|
|
@@ -1332,7 +1362,6 @@ ChatProxy.prototype = {
|
|
|
1332
1362
|
to = 'http://localhost';
|
|
1333
1363
|
_callback = callback;
|
|
1334
1364
|
|
|
1335
|
-
|
|
1336
1365
|
var iqParams = {
|
|
1337
1366
|
from: this.helpers.getUserCurrentJid(),
|
|
1338
1367
|
id: id,
|
|
@@ -1343,7 +1372,7 @@ ChatProxy.prototype = {
|
|
|
1343
1372
|
stanza.c('ping', { xmlns: "urn:xmpp:ping" });
|
|
1344
1373
|
|
|
1345
1374
|
var noAnswer = function () {
|
|
1346
|
-
_callback('No answer');
|
|
1375
|
+
_callback('Local ping No answer');
|
|
1347
1376
|
self._pings[id] = undefined;
|
|
1348
1377
|
delete self._pings[id];
|
|
1349
1378
|
};
|
|
@@ -1359,6 +1388,93 @@ ChatProxy.prototype = {
|
|
|
1359
1388
|
return id;
|
|
1360
1389
|
},
|
|
1361
1390
|
|
|
1391
|
+
isOnline: function(no, yes) {
|
|
1392
|
+
//
|
|
1393
|
+
const server = 'chat.quickblox.com';
|
|
1394
|
+
try {
|
|
1395
|
+
this.ping(server, (error) => {
|
|
1396
|
+
if (error) {
|
|
1397
|
+
no();
|
|
1398
|
+
} else {
|
|
1399
|
+
yes();
|
|
1400
|
+
}
|
|
1401
|
+
});
|
|
1402
|
+
} catch (err) {
|
|
1403
|
+
no();
|
|
1404
|
+
}
|
|
1405
|
+
},
|
|
1406
|
+
/*
|
|
1407
|
+
isOnlineAction0: function(no, yes) {
|
|
1408
|
+
const host = 'chat.quickblox.com';
|
|
1409
|
+
try {
|
|
1410
|
+
this.ping(host, function (error) {
|
|
1411
|
+
console.log('isOnlineAction0 call ping');
|
|
1412
|
+
if (error) {
|
|
1413
|
+
console.log('call isOnlineAction0, ping - Failed, ', error);
|
|
1414
|
+
no();
|
|
1415
|
+
} else {
|
|
1416
|
+
console.log('call isOnlineAction0, ping - OK');
|
|
1417
|
+
yes();
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
} catch (err) {
|
|
1421
|
+
console.log('call isOnlineAction0, Exception isOnlineAction0 function, ', err);
|
|
1422
|
+
no();
|
|
1423
|
+
}
|
|
1424
|
+
},
|
|
1425
|
+
|
|
1426
|
+
isOnlineAction1: function(no, yes) {
|
|
1427
|
+
try {
|
|
1428
|
+
var jid = this.helpers.getUserCurrentJid();
|
|
1429
|
+
console.log('JID: ', jid);
|
|
1430
|
+
this.ping(
|
|
1431
|
+
jid,
|
|
1432
|
+
function (err) {
|
|
1433
|
+
console.log('isOnlineAction1 call ping');
|
|
1434
|
+
if (err) {
|
|
1435
|
+
console.log('isOnlineAction1 call ping');
|
|
1436
|
+
no();
|
|
1437
|
+
}
|
|
1438
|
+
else {
|
|
1439
|
+
console.log('call isOnlineAction1, ping - OK');
|
|
1440
|
+
yes();
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
);
|
|
1444
|
+
} catch (e) {
|
|
1445
|
+
console.log('call isOnlineAction1, Exception isOnlineAction1 function, ', e);
|
|
1446
|
+
no();
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
|
|
1450
|
+
isOnlineAction2: function(no, yes) {
|
|
1451
|
+
var params = {
|
|
1452
|
+
order: {
|
|
1453
|
+
field: 'created_at',
|
|
1454
|
+
sort: 'asc'
|
|
1455
|
+
},
|
|
1456
|
+
page: 1,
|
|
1457
|
+
per_page: 10
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
try {
|
|
1461
|
+
qbMain.users.listUsers(params, function(error, result){
|
|
1462
|
+
if (error) {
|
|
1463
|
+
console.log('isOnlineAction2 call ping');
|
|
1464
|
+
no();
|
|
1465
|
+
}
|
|
1466
|
+
else {
|
|
1467
|
+
console.log('call isOnlineAction2, ping - OK');
|
|
1468
|
+
yes();
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1471
|
+
} catch(e) {
|
|
1472
|
+
console.log('call isOnlineAction2, Exception isOnlineAction2 function, ', e);
|
|
1473
|
+
no();
|
|
1474
|
+
}
|
|
1475
|
+
},
|
|
1476
|
+
*/
|
|
1477
|
+
|
|
1362
1478
|
ping: function (jid_or_user_id, callback) {
|
|
1363
1479
|
Utils.QBLog('[QBChat]', 'Call ping ');
|
|
1364
1480
|
var self = this;
|
|
@@ -1424,6 +1540,11 @@ ChatProxy.prototype = {
|
|
|
1424
1540
|
if (Utils.getEnv().browser) {
|
|
1425
1541
|
this.connection.flush();
|
|
1426
1542
|
this.connection.disconnect();
|
|
1543
|
+
if (this._checkConnectionPingTimer !== undefined) {
|
|
1544
|
+
Utils.QBLog('[QBChat]', 'Stop ping to localhost.');
|
|
1545
|
+
clearInterval(this._checkConnectionPingTimer);
|
|
1546
|
+
this._checkConnectionPingTimer = undefined;
|
|
1547
|
+
}
|
|
1427
1548
|
} else {
|
|
1428
1549
|
this.Client.end();
|
|
1429
1550
|
}
|
|
@@ -1536,7 +1657,6 @@ RosterProxy.prototype = {
|
|
|
1536
1657
|
|
|
1537
1658
|
function _callbackWrap(stanza) {
|
|
1538
1659
|
var items = _getItems(stanza);
|
|
1539
|
-
/** TODO */
|
|
1540
1660
|
for (var i = 0, len = items.length; i < len; i++) {
|
|
1541
1661
|
var userId = self.helpers.getIdFromNode( chatUtils.getAttr(items[i], 'jid') ),
|
|
1542
1662
|
ask = chatUtils.getAttr(items[i], 'ask'),
|