quickblox 2.19.0 → 2.19.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.
@@ -39,7 +39,7 @@ function ChatProxy(service) {
39
39
  */
40
40
  if (Utils.getEnv().browser) {
41
41
  // strophe js
42
- self.connection = Connection(self.onLogListener);
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 == "http://jabber.org/protocol/muc#user") {
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 == "301") {
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,6 +757,7 @@ ChatProxy.prototype = {
751
757
  /** Connect for browser env. */
752
758
  if (Utils.getEnv().browser) {
753
759
  Utils.QBLog('[QBChat]', '!!---Browser env - connected--!!');
760
+
754
761
  self.connection.connect(userJid, params.password, function (status, condition, elem) {
755
762
  Utils.QBLog('[QBChat]', 'self.connection.connect called with status ' + status);
756
763
  Utils.QBLog('[QBChat]', 'self.connection.connect called with condition ' + condition);
@@ -1070,7 +1077,7 @@ ChatProxy.prototype = {
1070
1077
  self._isConnecting = false;
1071
1078
 
1072
1079
  // reconnect to chat and enable check connection
1073
- self._establishConnection(params);
1080
+ self._establishConnection(params,'NODE:DISCONNECTED');
1074
1081
  });
1075
1082
 
1076
1083
  self.Client.on('error', function () {
@@ -1152,39 +1159,39 @@ ChatProxy.prototype = {
1152
1159
  }
1153
1160
  },
1154
1161
 
1155
- _establishConnection: function (params) {
1162
+ _establishConnection: function (params, description) {
1156
1163
  var self = this;
1157
- Utils.QBLog('[QBChat]', '_establishConnection called');
1164
+ Utils.QBLog('[QBChat]', '_establishConnection called in ' + description);
1158
1165
  if (typeof self.onLogListener === 'function') {
1159
1166
  Utils.safeCallbackCall(self.onLogListener,
1160
- '[QBChat]' + '_establishConnection called');
1167
+ '[QBChat]' + '_establishConnection called in ' + description);
1161
1168
  }
1162
1169
  if (self._isLogout || self._checkConnectionTimer) {
1163
1170
  Utils.QBLog('[QBChat]', '_establishConnection return');
1164
1171
  if (typeof self.onLogListener === 'function') {
1165
1172
  Utils.safeCallbackCall(self.onLogListener,
1166
- '[QBChat]' + ' _establishConnection return with self._isLogout: '+
1167
- self._isLogout+' and self._checkConnectionTimer ' +self._checkConnectionTimer?'set up':'undefined');
1173
+ '[QBChat]' + 'BREAK _establishConnection RETURN with self._isLogout: '+
1174
+ self._isLogout?self._isLogout:'undefined'+' and self._checkConnectionTimer ' +self._checkConnectionTimer?self._checkConnectionTimer:'undefined');
1168
1175
  }
1169
1176
  return;
1170
1177
  }
1171
1178
 
1172
1179
  var _connect = function () {
1173
- Utils.QBLog('[QBChat]', 'call _connect() in _establishConnection ');
1180
+ Utils.QBLog('[QBChat]', 'call _connect() in _establishConnection in '+description);
1174
1181
  if (typeof self.onLogListener === 'function') {
1175
1182
  Utils.safeCallbackCall(self.onLogListener,
1176
- '[QBChat]' + ' call _connect() in _establishConnection ');
1183
+ '[QBChat]' + ' call _connect() in _establishConnection in '+description);
1177
1184
  }
1178
1185
  if (!self.isConnected && !self._isConnecting && !self._sessionHasExpired) {
1179
- Utils.QBLog('[QBChat]', ' start execute connect() in _establishConnection ');
1186
+ Utils.QBLog('[QBChat]', ' start EXECUTE connect() in _establishConnection ');
1180
1187
  if (typeof self.onLogListener === 'function') {
1181
1188
  Utils.safeCallbackCall(self.onLogListener,
1182
- '[QBChat]' + ' with statuses (!self.isConnected && !self._isConnecting && !self._sessionHasExpired): '+' self.isConnected: '+self.isConnected+' self._isConnecting: '+self._isConnecting+' self._sessionHasExpired: '+self._sessionHasExpired);
1189
+ '[QBChat]' + ' start EXECUTE connect() in _establishConnection in '+description+' self.isConnected: '+self.isConnected+' self._isConnecting: '+self._isConnecting+' self._sessionHasExpired: '+self._sessionHasExpired);
1183
1190
  }
1184
1191
  self.connect(params);
1185
1192
  if (typeof self.onLogListener === 'function') {
1186
1193
  Utils.safeCallbackCall(self.onLogListener,
1187
- '[QBChat]' + 'call _connect() in _establishConnection is executed');
1194
+ '[QBChat]' + 'call _connect() in _establishConnection in '+description+' is executed');
1188
1195
  }
1189
1196
  } else {
1190
1197
  Utils.QBLog('[QBChat]', 'stop timer in _establishConnection ');
@@ -1192,7 +1199,7 @@ ChatProxy.prototype = {
1192
1199
  self._checkConnectionTimer = undefined;
1193
1200
  if (typeof self.onLogListener === 'function') {
1194
1201
  Utils.safeCallbackCall(self.onLogListener,
1195
- '[QBChat]' + 'stop timer in _establishConnection ');
1202
+ '[QBChat]' + 'stop timer in _establishConnection in '+description);
1196
1203
  }
1197
1204
  }
1198
1205
  };
@@ -1211,6 +1218,11 @@ ChatProxy.prototype = {
1211
1218
 
1212
1219
  reconnect: function () {
1213
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
+ }
1214
1226
  clearInterval(this._checkConnectionTimer);
1215
1227
  this._checkConnectionTimer = undefined;
1216
1228
  this.muc.joinedRooms = {};
@@ -1218,7 +1230,7 @@ ChatProxy.prototype = {
1218
1230
 
1219
1231
  if (Utils.getEnv().browser) {
1220
1232
  this.connection.flush();
1221
- this.connection.disconnect();
1233
+ this.connection.disconnect('call Qb.chat.reconnect');//artik should be added reasone = 'reconnect from SDK'
1222
1234
  } else {
1223
1235
  this.Client.end();
1224
1236
  }
@@ -1595,6 +1607,11 @@ ChatProxy.prototype = {
1595
1607
  * */
1596
1608
  disconnect: function () {
1597
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
+ }
1598
1615
  clearInterval(this._checkConnectionTimer);
1599
1616
  clearInterval(this._checkExpiredSessionTimer);
1600
1617
  this._checkConnectionTimer = undefined;
@@ -1605,7 +1622,7 @@ ChatProxy.prototype = {
1605
1622
 
1606
1623
  if (Utils.getEnv().browser) {
1607
1624
  this.connection.flush();
1608
- this.connection.disconnect();
1625
+ this.connection.disconnect('call QB.chat.disconnect');//artik should add reason = 'disconnect from SDK'
1609
1626
  if (this._checkConnectionPingTimer !== undefined) {
1610
1627
  Utils.QBLog('[QBChat]', 'Stop ping');
1611
1628
  clearInterval(this._checkConnectionPingTimer);
package/src/qbConfig.js CHANGED
@@ -12,8 +12,8 @@
12
12
  */
13
13
 
14
14
  var config = {
15
- version: '2.19.0',
16
- buildNumber: '1163',
15
+ version: '2.19.2',
16
+ buildNumber: '1164',
17
17
  creds: {
18
18
  'appId': 0,
19
19
  'authKey': '',
package/src/qbStrophe.js CHANGED
@@ -12,17 +12,19 @@ require('strophe.js');
12
12
  var config = require('./qbConfig');
13
13
  var chatPRTCL = config.chatProtocol;
14
14
  var Utils = require('./qbUtils');
15
- var QBChatModules = require('./modules/chat/qbChat');
16
15
 
17
16
  function Connection(onLogListenerCallback) {
18
17
  var protocol = chatPRTCL.active === 1 ? chatPRTCL.bosh : chatPRTCL.websocket;
19
18
  var conn = new Strophe.Connection(protocol);
20
- var onLogListener = config.debug? onLogListenerCallback || QBChatModules.onLogListener : null;
19
+ var onLogListener = config.debug ? onLogListenerCallback : null;
21
20
  var safeCallbackCall = function(message, data) {
22
- onLogListener = config.debug? onLogListenerCallback || QBChatModules.onLogListener : null;
21
+ onLogListener = config.debug ? onLogListenerCallback : null;
23
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 : '';
24
26
  Utils.safeCallbackCall(onLogListener,
25
- '[QBChat][QBStrophe]' + message + data);
27
+ '[QBChat][QBStrophe]' + message + ' id:'+id+' innerHTML: '+innerHTML+' outerHTML: '+outerHTML+JSON.stringify(data));
26
28
  }
27
29
  };
28
30