Skip to content

Commit 6e33cbc

Browse files
v2.17.0
1 parent 93fd4f5 commit 6e33cbc

File tree

24 files changed

+726
-278
lines changed

24 files changed

+726
-278
lines changed

LICENSE

Lines changed: 330 additions & 201 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Check out our [API Reference](https://quickblox.github.io/quickblox-javascript-s
1616
## Dependencies for browser
1717

1818
```html
19-
<script src="https://unpkg.com/quickblox@2.17.1/quickblox.min.js"></script>
19+
<script src="https://unpkg.com/quickblox@2.18.0/quickblox.min.js"></script>
2020
```
2121

2222
## Bower and RequireJS
@@ -74,4 +74,4 @@ See more information at [contributing.md](https://github.com/QuickBlox/quickblox
7474

7575
# License
7676

77-
Apache 2.0
77+
QuickBlox SDK License Agreement. Please see the LICENSE.txt file distributed with the SDK.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "quickblox",
33
"description": "QuickBlox JavaScript SDK",
4-
"version": "2.17.1",
4+
"version": "2.18.0",
55
"homepage": "https://quickblox.com/developers/Javascript",
66
"main": "src/qbMain.js",
77
"types": "quickblox.d.ts",

quickblox.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ interface QBChatModule {
523523
onReconnectListener?: () => void
524524
onReconnectFailedListener?: (error: any) => void
525525
onSessionExpiredListener?: (error?: QBError) => void
526+
onLogListener?: (logLine: string) => void
526527
/**
527528
* Receive reject request
528529
* ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#reject-the-contact-request)).

quickblox.js

Lines changed: 94 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45463,7 +45463,7 @@ function ChatProxy(service) {
4546345463
*/
4546445464
if (Utils.getEnv().browser) {
4546545465
// strophe js
45466-
self.connection = Connection();
45466+
self.connection = Connection(self.onLogListener);
4546745467

4546845468
/** Add extension methods to track handlers for removal on reconnect */
4546945469
self.connection.XHandlerReferences = [];
@@ -45579,6 +45579,7 @@ function ChatProxy(service) {
4557945579
* - onDisconnectedListener
4558045580
* - onReconnectListener
4558145581
* - onSessionExpiredListener
45582+
* - onLogListener
4558245583
*/
4558345584

4558445585
/**
@@ -45712,6 +45713,12 @@ function ChatProxy(service) {
4571245713
* @memberOf QB.chat
4571345714
**/
4571445715

45716+
/**
45717+
* Run after disconnect from chat to log result
45718+
* @function onLogListener
45719+
* @memberOf QB.chat
45720+
**/
45721+
4571545722

4571645723
this._onMessage = function (stanza) {
4571745724
var from = chatUtils.getAttr(stanza, 'from'),
@@ -46168,7 +46175,7 @@ ChatProxy.prototype = {
4616846175
/** Connect for browser env. */
4616946176
if (Utils.getEnv().browser) {
4617046177
Utils.QBLog('[QBChat]', '!!---Browser env - connected--!!');
46171-
46178+
let disconnectCondition = '';
4617246179
self.connection.connect(userJid, params.password, function (status) {
4617346180
Utils.QBLog('[QBChat]', 'self.connection.connect called with status ' + status);
4617446181
switch (status) {
@@ -46297,7 +46304,14 @@ ChatProxy.prototype = {
4629746304
break;
4629846305
case Strophe.Status.DISCONNECTED:
4629946306
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+
}
4630146315
// fire 'onDisconnectedListener' only once
4630246316
if (self.isConnected && typeof self.onDisconnectedListener === 'function') {
4630346317
Utils.safeCallbackCall(self.onDisconnectedListener);
@@ -46316,6 +46330,28 @@ ChatProxy.prototype = {
4631646330
break;
4631746331
}
4631846332
});
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+
};
4631946355
}
4632046356

4632146357
/** connect for node */
@@ -46455,27 +46491,56 @@ ChatProxy.prototype = {
4645546491
_establishConnection: function (params) {
4645646492
var self = this;
4645746493
Utils.QBLog('[QBChat]', '_establishConnection called');
46494+
if (typeof self.onLogListener === 'function') {
46495+
Utils.safeCallbackCall(self.onLogListener,
46496+
'[QBChat]' + '_establishConnection called');
46497+
}
4645846498
if (self._isLogout || self._checkConnectionTimer) {
4645946499
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+
}
4646046505
return;
4646146506
}
4646246507

4646346508
var _connect = function () {
4646446509
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+
}
4646546514
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+
}
4646746520
self.connect(params);
46521+
if (typeof self.onLogListener === 'function') {
46522+
Utils.safeCallbackCall(self.onLogListener,
46523+
'[QBChat]' + 'call _connect() in _establishConnection is executed');
46524+
}
4646846525
} else {
4646946526
Utils.QBLog('[QBChat]', 'stop timer in _establishConnection ');
4647046527
clearInterval(self._checkConnectionTimer);
4647146528
self._checkConnectionTimer = undefined;
46529+
if (typeof self.onLogListener === 'function') {
46530+
Utils.safeCallbackCall(self.onLogListener,
46531+
'[QBChat]' + 'stop timer in _establishConnection ');
46532+
}
4647246533
}
4647346534
};
4647446535

4647546536
_connect();
4647646537

4647746538
self._checkConnectionTimer = setInterval(function () {
4647846539
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+
}
4647946544
_connect();
4648046545
}, config.chatReconnectionTimeInterval * 1000);
4648146546
},
@@ -53809,8 +53874,8 @@ module.exports = StreamManagement;
5380953874
*/
5381053875

5381153876
var config = {
53812-
version: '2.17.1',
53813-
buildNumber: '1161',
53877+
version: '2.18.0',
53878+
buildNumber: '1162',
5381453879
creds: {
5381553880
'appId': 0,
5381653881
'authKey': '',
@@ -54252,7 +54317,7 @@ ServiceProxy.prototype = {
5425254317
handleResponse: function(error, response, next, retry) {
5425354318
// can add middleware here...
5425454319
if (error) {
54255-
const errorMsg = JSON.stringify(error.message).toLowerCase();
54320+
const errorMsg = error.message ? JSON.stringify(error.message).toLowerCase() : '';
5425654321
if (typeof config.on.sessionExpired === 'function' &&
5425754322
error.code === 401 &&
5425854323
errorMsg.indexOf('session does not exist') > -1) {
@@ -54522,7 +54587,7 @@ var config = require('./qbConfig');
5452254587
var chatPRTCL = config.chatProtocol;
5452354588
var Utils = require('./qbUtils');
5452454589

54525-
function Connection() {
54590+
function Connection(onLogListener) {
5452654591
var protocol = chatPRTCL.active === 1 ? chatPRTCL.bosh : chatPRTCL.websocket;
5452754592
var conn = new Strophe.Connection(protocol);
5452854593

@@ -54544,6 +54609,27 @@ function Connection() {
5454454609
} else {
5454554610
conn.xmlInput = function(data) {
5454654611
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+
//
5454754633
};
5454854634
conn.xmlOutput = function(data) {
5454954635
Utils.QBLog('[QBChat]', 'SENT:', data);

quickblox.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/chat/css/dashboard.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ END WELCOME MESSAGE
944944

945945

946946
.moreList {
947-
height: 86px;
947+
height: 106px;
948948
width: 146px;
949949
border-radius: 14px;
950950
background-color: rgba(255, 255, 255, 0.9);

samples/chat/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ <h2>Info</h2>
118118
</div>
119119
<ul class="moreList">
120120
<li>Chat info</li>
121-
<li>Leave Chat</li>
121+
<li>Leave chat</li>
122+
<li>Back to Chat</li>
122123
</ul>
123124

124125
</div>
@@ -132,7 +133,7 @@ <h2>Info</h2>
132133

133134
<div class="dashboard">
134135
<div class="dashboard_center copyright-2020-pow ">
135-
<samp style="padding-right: 6px;">Copyright © 2020 Powered by QuickBlox. All rights reserved. Sample version 1.0.0.</samp>
136+
<samp style="padding-right: 6px;">Copyright © 2020 Powered by QuickBlox. All rights reserved. Sample version 1.0.0</samp>
136137

137138
</div>
138139

0 commit comments

Comments
 (0)