quickblox 2.18.0 → 2.19.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/LICENSE +4 -0
- package/README.md +1 -2
- package/package.json +2 -2
- package/quickblox.js +8168 -6572
- package/quickblox.min.js +1 -1
- package/src/modules/chat/qbChat.js +157 -52
- package/src/qbConfig.js +2 -2
- package/src/qbStrophe.js +53 -44
|
@@ -39,7 +39,7 @@ function ChatProxy(service) {
|
|
|
39
39
|
*/
|
|
40
40
|
if (Utils.getEnv().browser) {
|
|
41
41
|
// strophe js
|
|
42
|
-
self.connection = Connection(self.
|
|
42
|
+
self.connection = Connection(self._OnLogListener.bind(this));
|
|
43
43
|
|
|
44
44
|
/** Add extension methods to track handlers for removal on reconnect */
|
|
45
45
|
self.connection.XHandlerReferences = [];
|
|
@@ -295,7 +295,6 @@ function ChatProxy(service) {
|
|
|
295
295
|
* @memberOf QB.chat
|
|
296
296
|
**/
|
|
297
297
|
|
|
298
|
-
|
|
299
298
|
this._onMessage = function (stanza) {
|
|
300
299
|
var from = chatUtils.getAttr(stanza, 'from'),
|
|
301
300
|
to = chatUtils.getAttr(stanza, 'to'),
|
|
@@ -418,12 +417,12 @@ function ChatProxy(service) {
|
|
|
418
417
|
}
|
|
419
418
|
|
|
420
419
|
// MUC presences go here
|
|
421
|
-
if (xXMLNS && xXMLNS ==
|
|
420
|
+
if (xXMLNS && xXMLNS == 'http://jabber.org/protocol/muc#user') {
|
|
422
421
|
dialogId = self.helpers.getDialogIdFromNode(from);
|
|
423
422
|
userId = self.helpers.getUserIdFromRoomJid(from);
|
|
424
423
|
|
|
425
424
|
// KICK from dialog event
|
|
426
|
-
if (status && statusCode ==
|
|
425
|
+
if (status && statusCode == '301') {
|
|
427
426
|
if (typeof self.onKickOccupant === 'function') {
|
|
428
427
|
var actorElement = chatUtils.getElement(chatUtils.getElement(x, 'item'), 'actor');
|
|
429
428
|
var initiatorUserJid = chatUtils.getAttr(actorElement, 'jid');
|
|
@@ -701,6 +700,13 @@ function ChatProxy(service) {
|
|
|
701
700
|
----------------------------------------------------------------------------- */
|
|
702
701
|
ChatProxy.prototype = {
|
|
703
702
|
|
|
703
|
+
_OnLogListener: function (message) {
|
|
704
|
+
var self = this;
|
|
705
|
+
if (typeof self.onLogListener === 'function') {
|
|
706
|
+
Utils.safeCallbackCall(self.onLogListener, message);
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
|
|
704
710
|
/**
|
|
705
711
|
* self.connection to the chat. {@link https://quickblox.com/developers/Web_XMPP_Chat_Sample#Login_to_Chat More info.}
|
|
706
712
|
* @memberof QB.chat
|
|
@@ -751,11 +757,21 @@ ChatProxy.prototype = {
|
|
|
751
757
|
/** Connect for browser env. */
|
|
752
758
|
if (Utils.getEnv().browser) {
|
|
753
759
|
Utils.QBLog('[QBChat]', '!!---Browser env - connected--!!');
|
|
754
|
-
|
|
755
|
-
self.connection.connect(userJid, params.password, function (status) {
|
|
760
|
+
|
|
761
|
+
self.connection.connect(userJid, params.password, function (status, condition, elem) {
|
|
756
762
|
Utils.QBLog('[QBChat]', 'self.connection.connect called with status ' + status);
|
|
763
|
+
Utils.QBLog('[QBChat]', 'self.connection.connect called with condition ' + condition);
|
|
764
|
+
Utils.QBLog('[QBChat]', 'self.connection.connect called with elem ' + elem);
|
|
757
765
|
switch (status) {
|
|
758
766
|
case Strophe.Status.ERROR:
|
|
767
|
+
Utils.QBLog('[QBChat]', 'Status.ERROR at ' + chatUtils.getLocalTime());
|
|
768
|
+
Utils.QBLog('[QBChat]', 'ERROR CONDITION: ' + condition);
|
|
769
|
+
|
|
770
|
+
if (typeof self.onLogListener === 'function') {
|
|
771
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
772
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status.ERROR at ' +
|
|
773
|
+
chatUtils.getLocalTime()+ ' ERROR CONDITION: ' + condition);
|
|
774
|
+
}
|
|
759
775
|
self.isConnected = false;
|
|
760
776
|
self._isConnecting = false;
|
|
761
777
|
|
|
@@ -767,6 +783,14 @@ ChatProxy.prototype = {
|
|
|
767
783
|
|
|
768
784
|
break;
|
|
769
785
|
case Strophe.Status.CONNFAIL:
|
|
786
|
+
Utils.QBLog('[QBChat]', 'Status.CONNFAIL at ' + chatUtils.getLocalTime());
|
|
787
|
+
Utils.QBLog('[QBChat]', 'CONNFAIL CONDITION: ' + condition);
|
|
788
|
+
|
|
789
|
+
if (typeof self.onLogListener === 'function') {
|
|
790
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
791
|
+
'[QBChat]' + '[SDK v'+config.version+']' +' Status.CONNFAIL at ' +
|
|
792
|
+
chatUtils.getLocalTime()+ ' CONNFAIL CONDITION: ' + condition);
|
|
793
|
+
}
|
|
770
794
|
self.isConnected = false;
|
|
771
795
|
self._isConnecting = false;
|
|
772
796
|
|
|
@@ -778,10 +802,24 @@ ChatProxy.prototype = {
|
|
|
778
802
|
|
|
779
803
|
break;
|
|
780
804
|
case Strophe.Status.AUTHENTICATING:
|
|
781
|
-
Utils.QBLog('[QBChat]', 'Status.AUTHENTICATING');
|
|
805
|
+
Utils.QBLog('[QBChat]', 'Status.AUTHENTICATING at ' + chatUtils.getLocalTime());
|
|
806
|
+
Utils.QBLog('[QBChat]', 'AUTHENTICATING CONDITION: ' + condition);
|
|
782
807
|
|
|
808
|
+
if (typeof self.onLogListener === 'function') {
|
|
809
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
810
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status.AUTHENTICATING at ' +
|
|
811
|
+
chatUtils.getLocalTime()+ ' AUTHENTICATING CONDITION: ' + condition);
|
|
812
|
+
}
|
|
783
813
|
break;
|
|
784
814
|
case Strophe.Status.AUTHFAIL:
|
|
815
|
+
Utils.QBLog('[QBChat]', 'Status.AUTHFAIL at ' + chatUtils.getLocalTime());
|
|
816
|
+
Utils.QBLog('[QBChat]', 'AUTHFAIL CONDITION: ' + condition);
|
|
817
|
+
|
|
818
|
+
if (typeof self.onLogListener === 'function') {
|
|
819
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
820
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status.AUTHFAIL at ' +
|
|
821
|
+
chatUtils.getLocalTime()+ ' AUTHFAIL CONDITION: ' + condition);
|
|
822
|
+
}
|
|
785
823
|
self.isConnected = false;
|
|
786
824
|
self._isConnecting = false;
|
|
787
825
|
|
|
@@ -798,9 +836,24 @@ ChatProxy.prototype = {
|
|
|
798
836
|
break;
|
|
799
837
|
case Strophe.Status.CONNECTING:
|
|
800
838
|
Utils.QBLog('[QBChat]', 'Status.CONNECTING', '(Chat Protocol - ' + (config.chatProtocol.active === 1 ? 'BOSH' : 'WebSocket' + ')'));
|
|
839
|
+
Utils.QBLog('[QBChat]', 'Status.CONNECTING at ' + chatUtils.getLocalTime());
|
|
840
|
+
Utils.QBLog('[QBChat]', 'CONNECTING CONDITION: ' + condition);
|
|
801
841
|
|
|
842
|
+
if (typeof self.onLogListener === 'function') {
|
|
843
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
844
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status.CONNECTING at ' + '(Chat Protocol - ' + config.chatProtocol.active === 1 ? 'BOSH' : 'WebSocket' + ')'+
|
|
845
|
+
chatUtils.getLocalTime()+ ' CONNECTING CONDITION: ' + condition);
|
|
846
|
+
}
|
|
802
847
|
break;
|
|
803
848
|
case Strophe.Status.CONNECTED:
|
|
849
|
+
Utils.QBLog('[QBChat]', 'Status.CONNECTED at ' + chatUtils.getLocalTime());
|
|
850
|
+
Utils.QBLog('[QBChat]', 'CONNECTED CONDITION: ' + condition);
|
|
851
|
+
|
|
852
|
+
if (typeof self.onLogListener === 'function') {
|
|
853
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
854
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status.CONNECTED at ' +
|
|
855
|
+
chatUtils.getLocalTime()+ ' CONNECTED CONDITION: ' + condition);
|
|
856
|
+
}
|
|
804
857
|
// Remove any handlers that might exist from a previous connection via
|
|
805
858
|
// extension method added to the connection on initialization in qbMain.
|
|
806
859
|
// NOTE: streamManagement also adds handlers, so do this first.
|
|
@@ -832,7 +885,7 @@ ChatProxy.prototype = {
|
|
|
832
885
|
self.isConnected = false;
|
|
833
886
|
self._isConnecting = false;
|
|
834
887
|
self._chatPingFailedCounter = 0;
|
|
835
|
-
self._establishConnection(params);
|
|
888
|
+
self._establishConnection(params,'CONNECTED have SDK ping failed');
|
|
836
889
|
}
|
|
837
890
|
} else {
|
|
838
891
|
Utils.QBLog('[QBChat]',
|
|
@@ -876,17 +929,23 @@ ChatProxy.prototype = {
|
|
|
876
929
|
|
|
877
930
|
break;
|
|
878
931
|
case Strophe.Status.DISCONNECTING:
|
|
879
|
-
Utils.QBLog('[QBChat]', 'Status.DISCONNECTING');
|
|
932
|
+
Utils.QBLog('[QBChat]', 'Status.DISCONNECTING at ' + chatUtils.getLocalTime());
|
|
933
|
+
Utils.QBLog('[QBChat]', 'DISCONNECTING CONDITION: ' + condition);
|
|
934
|
+
|
|
935
|
+
if (typeof self.onLogListener === 'function') {
|
|
936
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
937
|
+
'[QBChat]' + '[SDK v'+config.version+']' +' Status.DISCONNECTING at ' +
|
|
938
|
+
chatUtils.getLocalTime()+ ' DISCONNECTING CONDITION: ' + condition);
|
|
939
|
+
}
|
|
880
940
|
break;
|
|
881
941
|
case Strophe.Status.DISCONNECTED:
|
|
882
942
|
Utils.QBLog('[QBChat]', 'Status.DISCONNECTED at ' + chatUtils.getLocalTime());
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
//
|
|
943
|
+
Utils.QBLog('[QBChat]', 'DISCONNECTED CONDITION: ' + condition);
|
|
944
|
+
|
|
886
945
|
if (typeof self.onLogListener === 'function') {
|
|
887
946
|
Utils.safeCallbackCall(self.onLogListener,
|
|
888
|
-
'[QBChat]' + ' Status.DISCONNECTED at ' +
|
|
889
|
-
chatUtils.getLocalTime()+ ' DISCONNECTED CONDITION: ' +
|
|
947
|
+
'[QBChat]' + '[SDK v'+config.version+']' +' Status.DISCONNECTED at ' +
|
|
948
|
+
chatUtils.getLocalTime()+ ' DISCONNECTED CONDITION: ' + condition);
|
|
890
949
|
}
|
|
891
950
|
// fire 'onDisconnectedListener' only once
|
|
892
951
|
if (self.isConnected && typeof self.onDisconnectedListener === 'function') {
|
|
@@ -898,36 +957,72 @@ ChatProxy.prototype = {
|
|
|
898
957
|
self.connection.reset();
|
|
899
958
|
|
|
900
959
|
// reconnect to chat and enable check connection
|
|
901
|
-
self._establishConnection(params);
|
|
960
|
+
self._establishConnection(params,'DISCONNECTED');
|
|
902
961
|
|
|
903
962
|
break;
|
|
904
963
|
case Strophe.Status.ATTACHED:
|
|
905
|
-
Utils.QBLog('[QBChat]', 'Status.ATTACHED');
|
|
964
|
+
Utils.QBLog('[QBChat]', 'Status.ATTACHED at ' + chatUtils.getLocalTime());
|
|
965
|
+
Utils.QBLog('[QBChat]', 'ATTACHED CONDITION: ' + condition);
|
|
966
|
+
|
|
967
|
+
if (typeof self.onLogListener === 'function') {
|
|
968
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
969
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status.ATTACHED at ' +
|
|
970
|
+
chatUtils.getLocalTime()+ ' ATTACHED CONDITION: ' + condition);
|
|
971
|
+
}
|
|
906
972
|
break;
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
let errorElem = xmlDoc.getElementsByTagName('error');
|
|
916
|
-
if (errorElem.length > 0) {
|
|
917
|
-
let conditionElem = errorElem[0].getElementsByTagName('condition');
|
|
918
|
-
if (conditionElem.length > 0) {
|
|
919
|
-
disconnectCondition = conditionElem[0].textContent;
|
|
920
|
-
console.log('Disconnect condition:', disconnectCondition);
|
|
921
|
-
if (typeof self.onLogListener === 'function') {
|
|
922
|
-
Utils.safeCallbackCall(self.onLogListener,
|
|
923
|
-
'[QBChat]' + ' DISCONNECTED CONDITION: ' + disconnectCondition);
|
|
924
|
-
}
|
|
973
|
+
case Strophe.Status.REDIRECT:
|
|
974
|
+
Utils.QBLog('[QBChat]', 'Status.REDIRECT at ' + chatUtils.getLocalTime());
|
|
975
|
+
Utils.QBLog('[QBChat]', 'REDIRECT CONDITION: ' + condition);
|
|
976
|
+
|
|
977
|
+
if (typeof self.onLogListener === 'function') {
|
|
978
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
979
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status.REDIRECT at ' +
|
|
980
|
+
chatUtils.getLocalTime()+ ' REDIRECT CONDITION: ' + condition);
|
|
925
981
|
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
982
|
+
break;
|
|
983
|
+
case Strophe.Status.CONNTIMEOUT:
|
|
984
|
+
Utils.QBLog('[QBChat]', 'Status.CONNTIMEOUT at ' + chatUtils.getLocalTime());
|
|
985
|
+
Utils.QBLog('[QBChat]', 'CONNTIMEOUT CONDITION: ' + condition);
|
|
986
|
+
|
|
987
|
+
if (typeof self.onLogListener === 'function') {
|
|
988
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
989
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status.CONNTIMEOUT at ' +
|
|
990
|
+
chatUtils.getLocalTime()+ ' CONNTIMEOUT CONDITION: ' + condition);
|
|
991
|
+
}
|
|
992
|
+
break;
|
|
993
|
+
case Strophe.Status.BINDREQUIRED:
|
|
994
|
+
Utils.QBLog('[QBChat]', 'Status.BINDREQUIRED at ' + chatUtils.getLocalTime());
|
|
995
|
+
Utils.QBLog('[QBChat]', 'BINDREQUIRED CONDITION: ' + condition);
|
|
996
|
+
|
|
997
|
+
if (typeof self.onLogListener === 'function') {
|
|
998
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
999
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status.BINDREQUIRED at ' +
|
|
1000
|
+
chatUtils.getLocalTime()+ ' BINDREQUIRED CONDITION: ' + condition);
|
|
1001
|
+
}
|
|
1002
|
+
break;
|
|
1003
|
+
case Strophe.Status.ATTACHFAIL:
|
|
1004
|
+
Utils.QBLog('[QBChat]', 'Status.ATTACHFAIL at ' + chatUtils.getLocalTime());
|
|
1005
|
+
Utils.QBLog('[QBChat]', 'ATTACHFAIL CONDITION: ' + condition);
|
|
1006
|
+
|
|
1007
|
+
if (typeof self.onLogListener === 'function') {
|
|
1008
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
1009
|
+
'[QBChat]' + '[SDK v'+config.version+']' +' Status.ATTACHFAIL at ' +
|
|
1010
|
+
chatUtils.getLocalTime()+ ' ATTACHFAIL CONDITION: ' + condition);
|
|
1011
|
+
}
|
|
1012
|
+
break;
|
|
1013
|
+
|
|
1014
|
+
default:
|
|
1015
|
+
Utils.QBLog('[QBChat]', 'Status is unknown at ' + chatUtils.getLocalTime());
|
|
1016
|
+
Utils.QBLog('[QBChat]', 'unknown CONDITION: ' + condition);
|
|
1017
|
+
|
|
1018
|
+
if (typeof self.onLogListener === 'function') {
|
|
1019
|
+
Utils.safeCallbackCall(self.onLogListener,
|
|
1020
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Status is unknown at ' +
|
|
1021
|
+
chatUtils.getLocalTime()+ ' unknown CONDITION: ' + condition);
|
|
1022
|
+
}
|
|
1023
|
+
break;
|
|
929
1024
|
}
|
|
930
|
-
};
|
|
1025
|
+
});
|
|
931
1026
|
}
|
|
932
1027
|
|
|
933
1028
|
/** connect for node */
|
|
@@ -982,7 +1077,7 @@ ChatProxy.prototype = {
|
|
|
982
1077
|
self._isConnecting = false;
|
|
983
1078
|
|
|
984
1079
|
// reconnect to chat and enable check connection
|
|
985
|
-
self._establishConnection(params);
|
|
1080
|
+
self._establishConnection(params,'NODE:DISCONNECTED');
|
|
986
1081
|
});
|
|
987
1082
|
|
|
988
1083
|
self.Client.on('error', function () {
|
|
@@ -1064,39 +1159,39 @@ ChatProxy.prototype = {
|
|
|
1064
1159
|
}
|
|
1065
1160
|
},
|
|
1066
1161
|
|
|
1067
|
-
_establishConnection: function (params) {
|
|
1162
|
+
_establishConnection: function (params, description) {
|
|
1068
1163
|
var self = this;
|
|
1069
|
-
Utils.QBLog('[QBChat]', '_establishConnection called');
|
|
1164
|
+
Utils.QBLog('[QBChat]', '_establishConnection called in ' + description);
|
|
1070
1165
|
if (typeof self.onLogListener === 'function') {
|
|
1071
1166
|
Utils.safeCallbackCall(self.onLogListener,
|
|
1072
|
-
'[QBChat]' + '_establishConnection called');
|
|
1167
|
+
'[QBChat]' + '_establishConnection called in ' + description);
|
|
1073
1168
|
}
|
|
1074
1169
|
if (self._isLogout || self._checkConnectionTimer) {
|
|
1075
1170
|
Utils.QBLog('[QBChat]', '_establishConnection return');
|
|
1076
1171
|
if (typeof self.onLogListener === 'function') {
|
|
1077
1172
|
Utils.safeCallbackCall(self.onLogListener,
|
|
1078
|
-
'[QBChat]' + ' _establishConnection
|
|
1079
|
-
self._isLogout+' and self._checkConnectionTimer ' +self._checkConnectionTimer?
|
|
1173
|
+
'[QBChat]' + 'BREAK _establishConnection RETURN with self._isLogout: '+
|
|
1174
|
+
self._isLogout?self._isLogout:'undefined'+' and self._checkConnectionTimer ' +self._checkConnectionTimer?self._checkConnectionTimer:'undefined');
|
|
1080
1175
|
}
|
|
1081
1176
|
return;
|
|
1082
1177
|
}
|
|
1083
1178
|
|
|
1084
1179
|
var _connect = function () {
|
|
1085
|
-
Utils.QBLog('[QBChat]', 'call _connect() in _establishConnection ');
|
|
1180
|
+
Utils.QBLog('[QBChat]', 'call _connect() in _establishConnection in '+description);
|
|
1086
1181
|
if (typeof self.onLogListener === 'function') {
|
|
1087
1182
|
Utils.safeCallbackCall(self.onLogListener,
|
|
1088
|
-
'[QBChat]' + ' call _connect() in _establishConnection ');
|
|
1183
|
+
'[QBChat]' + ' call _connect() in _establishConnection in '+description);
|
|
1089
1184
|
}
|
|
1090
1185
|
if (!self.isConnected && !self._isConnecting && !self._sessionHasExpired) {
|
|
1091
|
-
Utils.QBLog('[QBChat]', ' start
|
|
1186
|
+
Utils.QBLog('[QBChat]', ' start EXECUTE connect() in _establishConnection ');
|
|
1092
1187
|
if (typeof self.onLogListener === 'function') {
|
|
1093
1188
|
Utils.safeCallbackCall(self.onLogListener,
|
|
1094
|
-
'[QBChat]' + '
|
|
1189
|
+
'[QBChat]' + ' start EXECUTE connect() in _establishConnection in '+description+' self.isConnected: '+self.isConnected+' self._isConnecting: '+self._isConnecting+' self._sessionHasExpired: '+self._sessionHasExpired);
|
|
1095
1190
|
}
|
|
1096
1191
|
self.connect(params);
|
|
1097
1192
|
if (typeof self.onLogListener === 'function') {
|
|
1098
1193
|
Utils.safeCallbackCall(self.onLogListener,
|
|
1099
|
-
'[QBChat]' + 'call _connect() in _establishConnection is executed');
|
|
1194
|
+
'[QBChat]' + 'call _connect() in _establishConnection in '+description+' is executed');
|
|
1100
1195
|
}
|
|
1101
1196
|
} else {
|
|
1102
1197
|
Utils.QBLog('[QBChat]', 'stop timer in _establishConnection ');
|
|
@@ -1104,7 +1199,7 @@ ChatProxy.prototype = {
|
|
|
1104
1199
|
self._checkConnectionTimer = undefined;
|
|
1105
1200
|
if (typeof self.onLogListener === 'function') {
|
|
1106
1201
|
Utils.safeCallbackCall(self.onLogListener,
|
|
1107
|
-
'[QBChat]' + 'stop timer in _establishConnection ');
|
|
1202
|
+
'[QBChat]' + 'stop timer in _establishConnection in '+description);
|
|
1108
1203
|
}
|
|
1109
1204
|
}
|
|
1110
1205
|
};
|
|
@@ -1123,6 +1218,11 @@ ChatProxy.prototype = {
|
|
|
1123
1218
|
|
|
1124
1219
|
reconnect: function () {
|
|
1125
1220
|
Utils.QBLog('[QBChat]', 'Call reconnect ');
|
|
1221
|
+
if (typeof this.onLogListener === 'function') {
|
|
1222
|
+
Utils.safeCallbackCall(this.onLogListener,
|
|
1223
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Call reconnect ' +
|
|
1224
|
+
chatUtils.getLocalTime());
|
|
1225
|
+
}
|
|
1126
1226
|
clearInterval(this._checkConnectionTimer);
|
|
1127
1227
|
this._checkConnectionTimer = undefined;
|
|
1128
1228
|
this.muc.joinedRooms = {};
|
|
@@ -1130,7 +1230,7 @@ ChatProxy.prototype = {
|
|
|
1130
1230
|
|
|
1131
1231
|
if (Utils.getEnv().browser) {
|
|
1132
1232
|
this.connection.flush();
|
|
1133
|
-
this.connection.disconnect()
|
|
1233
|
+
this.connection.disconnect('call Qb.chat.reconnect');//artik should be added reasone = 'reconnect from SDK'
|
|
1134
1234
|
} else {
|
|
1135
1235
|
this.Client.end();
|
|
1136
1236
|
}
|
|
@@ -1507,6 +1607,11 @@ ChatProxy.prototype = {
|
|
|
1507
1607
|
* */
|
|
1508
1608
|
disconnect: function () {
|
|
1509
1609
|
Utils.QBLog('[QBChat]', 'Call disconnect ');
|
|
1610
|
+
if (typeof this.onLogListener === 'function') {
|
|
1611
|
+
Utils.safeCallbackCall(this.onLogListener,
|
|
1612
|
+
'[QBChat]' +'[SDK v'+config.version+']' + ' Call disconnect ' +
|
|
1613
|
+
chatUtils.getLocalTime());
|
|
1614
|
+
}
|
|
1510
1615
|
clearInterval(this._checkConnectionTimer);
|
|
1511
1616
|
clearInterval(this._checkExpiredSessionTimer);
|
|
1512
1617
|
this._checkConnectionTimer = undefined;
|
|
@@ -1517,7 +1622,7 @@ ChatProxy.prototype = {
|
|
|
1517
1622
|
|
|
1518
1623
|
if (Utils.getEnv().browser) {
|
|
1519
1624
|
this.connection.flush();
|
|
1520
|
-
this.connection.disconnect()
|
|
1625
|
+
this.connection.disconnect('call QB.chat.disconnect');//artik should add reason = 'disconnect from SDK'
|
|
1521
1626
|
if (this._checkConnectionPingTimer !== undefined) {
|
|
1522
1627
|
Utils.QBLog('[QBChat]', 'Stop ping');
|
|
1523
1628
|
clearInterval(this._checkConnectionPingTimer);
|
package/src/qbConfig.js
CHANGED
package/src/qbStrophe.js
CHANGED
|
@@ -13,56 +13,65 @@ var config = require('./qbConfig');
|
|
|
13
13
|
var chatPRTCL = config.chatProtocol;
|
|
14
14
|
var Utils = require('./qbUtils');
|
|
15
15
|
|
|
16
|
-
function Connection(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
conn.xmlOutput = function(data) {
|
|
29
|
-
if (data.childNodes[0]) {
|
|
30
|
-
for (var i = 0, len = data.childNodes.length; i < len; i++) {
|
|
31
|
-
Utils.QBLog('[QBChat]', 'SENT:', data.childNodes[i]);
|
|
16
|
+
function Connection(onLogListenerCallback) {
|
|
17
|
+
var protocol = chatPRTCL.active === 1 ? chatPRTCL.bosh : chatPRTCL.websocket;
|
|
18
|
+
var conn = new Strophe.Connection(protocol);
|
|
19
|
+
var onLogListener = config.debug ? onLogListenerCallback : null;
|
|
20
|
+
var safeCallbackCall = function(message, data) {
|
|
21
|
+
onLogListener = config.debug ? onLogListenerCallback : null;
|
|
22
|
+
if (onLogListener && typeof onLogListener === 'function') {
|
|
23
|
+
var id = data && data.id? data.id : '';
|
|
24
|
+
var innerHTML = data && data.innerHTML? data.innerHTML : '';
|
|
25
|
+
var outerHTML = data && data.outerHTML? data.outerHTML : '';
|
|
26
|
+
Utils.safeCallbackCall(onLogListener,
|
|
27
|
+
'[QBChat][QBStrophe]' + message + ' id:'+id+' innerHTML: '+innerHTML+' outerHTML: '+outerHTML+JSON.stringify(data));
|
|
32
28
|
}
|
|
33
|
-
}
|
|
34
29
|
};
|
|
35
|
-
} else {
|
|
36
|
-
conn.xmlInput = function(data) {
|
|
37
|
-
Utils.QBLog('[QBChat]', 'RECV:', data);
|
|
38
|
-
//
|
|
39
|
-
try {
|
|
40
|
-
let parser = new DOMParser();
|
|
41
|
-
let xmlDoc = parser.parseFromString(data, 'text/xml');
|
|
42
30
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (onLogListener && typeof onLogListener === 'function') {
|
|
50
|
-
Utils.safeCallbackCall(onLogListener,
|
|
51
|
-
'[QBChat][QBStrophe]' + 'DISCONNECTED CONDITION: ' + disconnectCondition);
|
|
52
|
-
}
|
|
31
|
+
if (chatPRTCL.active === 1) {
|
|
32
|
+
conn.xmlInput = function(data) {
|
|
33
|
+
if (data.childNodes[0]) {
|
|
34
|
+
for (var i = 0, len = data.childNodes.length; i < len; i++) {
|
|
35
|
+
Utils.QBLog('[QBChat]', 'RECV:', data.childNodes[i]);
|
|
36
|
+
safeCallbackCall('RECV:', data.childNodes[i]);
|
|
53
37
|
}
|
|
54
38
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
};
|
|
40
|
+
conn.xmlOutput = function(data) {
|
|
41
|
+
if (data.childNodes[0]) {
|
|
42
|
+
for (var i = 0, len = data.childNodes.length; i < len; i++) {
|
|
43
|
+
Utils.QBLog('[QBChat]', 'SENT:', data.childNodes[i]);
|
|
44
|
+
safeCallbackCall('SENT', data.childNodes[i]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
} else {
|
|
49
|
+
conn.xmlInput = function(data) {
|
|
50
|
+
Utils.QBLog('[QBChat]', 'RECV:', data);
|
|
51
|
+
safeCallbackCall('RECV:', data);
|
|
64
52
|
|
|
65
|
-
|
|
53
|
+
try {
|
|
54
|
+
let parser = new DOMParser();
|
|
55
|
+
let xmlDoc = parser.parseFromString(data, 'text/xml');
|
|
56
|
+
let errorElem = xmlDoc.getElementsByTagName('error');
|
|
57
|
+
if (errorElem.length > 0) {
|
|
58
|
+
let conditionElem = errorElem[0].getElementsByTagName('condition');
|
|
59
|
+
if (conditionElem.length > 0) {
|
|
60
|
+
let disconnectCondition = conditionElem[0].textContent;
|
|
61
|
+
console.log('Disconnect condition:', disconnectCondition);
|
|
62
|
+
safeCallbackCall('DISCONNECTED CONDITION:', disconnectCondition);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} catch (e) {
|
|
66
|
+
console.error('Error parsing XML input:', e);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
conn.xmlOutput = function(data) {
|
|
70
|
+
Utils.QBLog('[QBChat]', 'SENT:', data);
|
|
71
|
+
safeCallbackCall('SENT', data);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return conn;
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
module.exports = Connection;
|