quickblox 2.17.0 → 2.17.1-beta.2-logger

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 CHANGED
@@ -16,7 +16,7 @@ Check out our [API Reference](https://quickblox.github.io/quickblox-javascript-s
16
16
  ## Dependencies for browser
17
17
 
18
18
  ```html
19
- <script src="https://unpkg.com/quickblox@2.17.0/quickblox.min.js"></script>
19
+ <script src="https://unpkg.com/quickblox@2.17.1/quickblox.min.js"></script>
20
20
  ```
21
21
 
22
22
  ## Bower and RequireJS
@@ -74,4 +74,4 @@ See more information at [contributing.md](https://github.com/QuickBlox/quickblox
74
74
 
75
75
  # License
76
76
 
77
- Apache 2.0
77
+ Apache 2.0+logger
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "quickblox",
3
3
  "description": "QuickBlox JavaScript SDK",
4
- "version": "2.17.0",
4
+ "version": "2.17.1-beta.2-logger",
5
5
  "homepage": "https://quickblox.com/developers/Javascript",
6
6
  "main": "src/qbMain.js",
7
7
  "types": "quickblox.d.ts",
package/quickblox.d.ts CHANGED
@@ -369,29 +369,33 @@ export declare interface QBMessageStatusParams {
369
369
  }
370
370
 
371
371
  export declare interface QBChatNewMessage {
372
- type: 'chat' | 'groupchat'
373
- body: string
374
- extension: {
375
- attachments?: ChatMessageAttachment[]
376
- save_to_history: 0 | 1
377
- dialog_id: QBChatDialog['_id']
378
- }
379
- markable: 0 | 1
372
+ type: 'chat' | 'groupchat'
373
+ body?: string
374
+ extension: {
375
+ attachments?: ChatMessageAttachment[]
376
+ save_to_history: 0 | 1
377
+ dialog_id: QBChatDialog['_id']
378
+ [custom_field_N: string]: any
379
+ }
380
+ markable: 0 | 1
380
381
  }
381
382
 
382
383
  export declare interface QBChatXMPPMessage {
383
- id: string
384
- dialog_id: QBChatDialog['_id']
385
- recipient_id: null
386
- type: 'chat' | 'groupchat'
387
- body: string
388
- delay: null
389
- markable: 0 | 1
390
- extension: {
391
- attachments?: ChatMessageAttachment[]
392
- date_sent: string
393
- [custom_field_N: string]: any
394
- }
384
+ id: string
385
+ dialog_id: QBChatDialog['_id']
386
+ recipient_id: QBUser['id'] | null
387
+ type: 'chat' | 'groupchat'
388
+ body: string | null
389
+ delay: null
390
+ markable: 0 | 1
391
+ extension: {
392
+ dialog_id: QBChatDialog['_id']
393
+ message_id: QBChatMessage['_id']
394
+ date_sent: string
395
+ save_to_history: string
396
+ attachments?: ChatMessageAttachment[]
397
+ [custom_field_N: string]: string | ChatMessageAttachment[]
398
+ }
395
399
  }
396
400
 
397
401
  export declare interface QBSystemMessage {
@@ -519,6 +523,7 @@ interface QBChatModule {
519
523
  onReconnectListener?: () => void
520
524
  onReconnectFailedListener?: (error: any) => void
521
525
  onSessionExpiredListener?: (error?: QBError) => void
526
+ onLogListener?: (logLine: string) => void
522
527
  /**
523
528
  * Receive reject request
524
529
  * ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#reject-the-contact-request)).
@@ -578,6 +583,7 @@ interface QBChatModule {
578
583
  /** Send is delivered status. */
579
584
  sendDeliveredStatus(params: QBMessageStatusParams): void
580
585
  ping(jidOrUserId: string | number, callback: QBCallback<any>): string
586
+ ping(callback: QBCallback<any>): string
581
587
  pingchat(callback: QBCallback<any>): string
582
588
 
583
589
  dialog: {
@@ -711,7 +717,7 @@ interface QBChatModule {
711
717
  * Leave group chat dialog
712
718
  * ([read more](https://docs.quickblox.com/docs/js-chat-dialogs#retrieve-online-users)).
713
719
  */
714
- listOnlineUsers(dialogJid: string, callback: QBCallback<any>): void
720
+ listOnlineUsers(dialogJid: string, callback: (userIds: Array<QBUser['id']>) => void): void
715
721
  }
716
722
 
717
723
  roster: {
package/quickblox.js CHANGED
@@ -45463,7 +45463,7 @@ function ChatProxy(service) {
45463
45463
  */
45464
45464
  if (Utils.getEnv().browser) {
45465
45465
  // strophe js
45466
- self.connection = Connection();
45466
+ self.connection = Connection(self.onLogListener);
45467
45467
 
45468
45468
  /** Add extension methods to track handlers for removal on reconnect */
45469
45469
  self.connection.XHandlerReferences = [];
@@ -45579,6 +45579,7 @@ function ChatProxy(service) {
45579
45579
  * - onDisconnectedListener
45580
45580
  * - onReconnectListener
45581
45581
  * - onSessionExpiredListener
45582
+ * - onLogListener
45582
45583
  */
45583
45584
 
45584
45585
  /**
@@ -45712,6 +45713,12 @@ function ChatProxy(service) {
45712
45713
  * @memberOf QB.chat
45713
45714
  **/
45714
45715
 
45716
+ /**
45717
+ * Run after disconnect from chat to log result
45718
+ * @function onLogListener
45719
+ * @memberOf QB.chat
45720
+ **/
45721
+
45715
45722
 
45716
45723
  this._onMessage = function (stanza) {
45717
45724
  var from = chatUtils.getAttr(stanza, 'from'),
@@ -46168,7 +46175,7 @@ ChatProxy.prototype = {
46168
46175
  /** Connect for browser env. */
46169
46176
  if (Utils.getEnv().browser) {
46170
46177
  Utils.QBLog('[QBChat]', '!!---Browser env - connected--!!');
46171
-
46178
+ let disconnectCondition = '';
46172
46179
  self.connection.connect(userJid, params.password, function (status) {
46173
46180
  Utils.QBLog('[QBChat]', 'self.connection.connect called with status ' + status);
46174
46181
  switch (status) {
@@ -46297,7 +46304,14 @@ ChatProxy.prototype = {
46297
46304
  break;
46298
46305
  case Strophe.Status.DISCONNECTED:
46299
46306
  Utils.QBLog('[QBChat]', 'Status.DISCONNECTED at ' + chatUtils.getLocalTime());
46300
-
46307
+ //
46308
+ Utils.QBLog('[QBChat]', 'DISCONNECTED CONDITION: ' + disconnectCondition);
46309
+ //
46310
+ if (typeof self.onLogListener === 'function') {
46311
+ Utils.safeCallbackCall(self.onLogListener,
46312
+ '[QBChat]' + ' Status.DISCONNECTED at ' +
46313
+ chatUtils.getLocalTime()+ ' DISCONNECTED CONDITION: ' + disconnectCondition);
46314
+ }
46301
46315
  // fire 'onDisconnectedListener' only once
46302
46316
  if (self.isConnected && typeof self.onDisconnectedListener === 'function') {
46303
46317
  Utils.safeCallbackCall(self.onDisconnectedListener);
@@ -46316,6 +46330,28 @@ ChatProxy.prototype = {
46316
46330
  break;
46317
46331
  }
46318
46332
  });
46333
+ // connection error handler
46334
+ self.connection.xmlInput = function (data) {
46335
+ try {
46336
+ let parser = new DOMParser();
46337
+ let xmlDoc = parser.parseFromString(data, 'text/xml');
46338
+
46339
+ let errorElem = xmlDoc.getElementsByTagName('error');
46340
+ if (errorElem.length > 0) {
46341
+ let conditionElem = errorElem[0].getElementsByTagName('condition');
46342
+ if (conditionElem.length > 0) {
46343
+ disconnectCondition = conditionElem[0].textContent;
46344
+ console.log('Disconnect condition:', disconnectCondition);
46345
+ if (typeof self.onLogListener === 'function') {
46346
+ Utils.safeCallbackCall(self.onLogListener,
46347
+ '[QBChat]' + ' DISCONNECTED CONDITION: ' + disconnectCondition);
46348
+ }
46349
+ }
46350
+ }
46351
+ } catch (e) {
46352
+ console.error('Error parsing XML input:', e);
46353
+ }
46354
+ };
46319
46355
  }
46320
46356
 
46321
46357
  /** connect for node */
@@ -46455,20 +46491,45 @@ ChatProxy.prototype = {
46455
46491
  _establishConnection: function (params) {
46456
46492
  var self = this;
46457
46493
  Utils.QBLog('[QBChat]', '_establishConnection called');
46494
+ if (typeof self.onLogListener === 'function') {
46495
+ Utils.safeCallbackCall(self.onLogListener,
46496
+ '[QBChat]' + '_establishConnection called');
46497
+ }
46458
46498
  if (self._isLogout || self._checkConnectionTimer) {
46459
46499
  Utils.QBLog('[QBChat]', '_establishConnection return');
46500
+ if (typeof self.onLogListener === 'function') {
46501
+ Utils.safeCallbackCall(self.onLogListener,
46502
+ '[QBChat]' + ' _establishConnection return with self._isLogout: '+
46503
+ self._isLogout+' and self._checkConnectionTimer ' +self._checkConnectionTimer?'set up':'undefined');
46504
+ }
46460
46505
  return;
46461
46506
  }
46462
46507
 
46463
46508
  var _connect = function () {
46464
46509
  Utils.QBLog('[QBChat]', 'call _connect() in _establishConnection ');
46510
+ if (typeof self.onLogListener === 'function') {
46511
+ Utils.safeCallbackCall(self.onLogListener,
46512
+ '[QBChat]' + ' call _connect() in _establishConnection ');
46513
+ }
46465
46514
  if (!self.isConnected && !self._isConnecting && !self._sessionHasExpired) {
46466
- Utils.QBLog('[QBChat]', 'call connect() again in _establishConnection ');
46515
+ Utils.QBLog('[QBChat]', ' start execute connect() in _establishConnection ');
46516
+ if (typeof self.onLogListener === 'function') {
46517
+ Utils.safeCallbackCall(self.onLogListener,
46518
+ '[QBChat]' + ' with statuses (!self.isConnected && !self._isConnecting && !self._sessionHasExpired): '+' self.isConnected: '+self.isConnected+' self._isConnecting: '+self._isConnecting+' self._sessionHasExpired: '+self._sessionHasExpired);
46519
+ }
46467
46520
  self.connect(params);
46521
+ if (typeof self.onLogListener === 'function') {
46522
+ Utils.safeCallbackCall(self.onLogListener,
46523
+ '[QBChat]' + 'call _connect() in _establishConnection is executed');
46524
+ }
46468
46525
  } else {
46469
46526
  Utils.QBLog('[QBChat]', 'stop timer in _establishConnection ');
46470
46527
  clearInterval(self._checkConnectionTimer);
46471
46528
  self._checkConnectionTimer = undefined;
46529
+ if (typeof self.onLogListener === 'function') {
46530
+ Utils.safeCallbackCall(self.onLogListener,
46531
+ '[QBChat]' + 'stop timer in _establishConnection ');
46532
+ }
46472
46533
  }
46473
46534
  };
46474
46535
 
@@ -46476,6 +46537,10 @@ ChatProxy.prototype = {
46476
46537
 
46477
46538
  self._checkConnectionTimer = setInterval(function () {
46478
46539
  Utils.QBLog('[QBChat]', 'self._checkConnectionTimer called with config.chatReconnectionTimeInterval = ' + config.chatReconnectionTimeInterval);
46540
+ if (typeof self.onLogListener === 'function') {
46541
+ Utils.safeCallbackCall(self.onLogListener,
46542
+ '[QBChat]' + 'self._checkConnectionTimer called with config.chatReconnectionTimeInterval = ' + config.chatReconnectionTimeInterval);
46543
+ }
46479
46544
  _connect();
46480
46545
  }, config.chatReconnectionTimeInterval * 1000);
46481
46546
  },
@@ -53809,8 +53874,8 @@ module.exports = StreamManagement;
53809
53874
  */
53810
53875
 
53811
53876
  var config = {
53812
- version: '2.17.0',
53813
- buildNumber: '1160',
53877
+ version: '2.17.1-beta.2-logger',
53878
+ buildNumber: '1162',
53814
53879
  creds: {
53815
53880
  'appId': 0,
53816
53881
  'authKey': '',
@@ -54522,7 +54587,7 @@ var config = require('./qbConfig');
54522
54587
  var chatPRTCL = config.chatProtocol;
54523
54588
  var Utils = require('./qbUtils');
54524
54589
 
54525
- function Connection() {
54590
+ function Connection(onLogListener) {
54526
54591
  var protocol = chatPRTCL.active === 1 ? chatPRTCL.bosh : chatPRTCL.websocket;
54527
54592
  var conn = new Strophe.Connection(protocol);
54528
54593
 
@@ -54544,6 +54609,27 @@ function Connection() {
54544
54609
  } else {
54545
54610
  conn.xmlInput = function(data) {
54546
54611
  Utils.QBLog('[QBChat]', 'RECV:', data);
54612
+ //
54613
+ try {
54614
+ let parser = new DOMParser();
54615
+ let xmlDoc = parser.parseFromString(data, 'text/xml');
54616
+
54617
+ let errorElem = xmlDoc.getElementsByTagName('error');
54618
+ if (errorElem.length > 0) {
54619
+ let conditionElem = errorElem[0].getElementsByTagName('condition');
54620
+ if (conditionElem.length > 0) {
54621
+ let disconnectCondition = conditionElem[0].textContent;
54622
+ console.log('Disconnect condition:', disconnectCondition);
54623
+ if (onLogListener && typeof onLogListener === 'function') {
54624
+ Utils.safeCallbackCall(onLogListener,
54625
+ '[QBChat][QBStrophe]' + 'DISCONNECTED CONDITION: ' + disconnectCondition);
54626
+ }
54627
+ }
54628
+ }
54629
+ } catch (e) {
54630
+ console.error('Error parsing XML input:', e);
54631
+ }
54632
+ //
54547
54633
  };
54548
54634
  conn.xmlOutput = function(data) {
54549
54635
  Utils.QBLog('[QBChat]', 'SENT:', data);