Skip to content

Commit

Permalink
v2.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem-K-Koltunov committed Aug 8, 2024
1 parent 93fd4f5 commit 6e33cbc
Show file tree
Hide file tree
Showing 24 changed files with 726 additions and 278 deletions.
531 changes: 330 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Check out our [API Reference](https://quickblox.github.io/quickblox-javascript-s
## Dependencies for browser

```html
<script src="https://unpkg.com/quickblox@2.17.1/quickblox.min.js"></script>
<script src="https://unpkg.com/quickblox@2.18.0/quickblox.min.js"></script>
```

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

# License

Apache 2.0
QuickBlox SDK License Agreement. Please see the LICENSE.txt file distributed with the SDK.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "quickblox",
"description": "QuickBlox JavaScript SDK",
"version": "2.17.1",
"version": "2.18.0",
"homepage": "https://quickblox.com/developers/Javascript",
"main": "src/qbMain.js",
"types": "quickblox.d.ts",
Expand Down
1 change: 1 addition & 0 deletions quickblox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ interface QBChatModule {
onReconnectListener?: () => void
onReconnectFailedListener?: (error: any) => void
onSessionExpiredListener?: (error?: QBError) => void
onLogListener?: (logLine: string) => void
/**
* Receive reject request
* ([read more](https://docs.quickblox.com/docs/js-chat-contact-list#reject-the-contact-request)).
Expand Down
102 changes: 94 additions & 8 deletions quickblox.js
Original file line number Diff line number Diff line change
Expand Up @@ -45463,7 +45463,7 @@ function ChatProxy(service) {
*/
if (Utils.getEnv().browser) {
// strophe js
self.connection = Connection();
self.connection = Connection(self.onLogListener);

/** Add extension methods to track handlers for removal on reconnect */
self.connection.XHandlerReferences = [];
Expand Down Expand Up @@ -45579,6 +45579,7 @@ function ChatProxy(service) {
* - onDisconnectedListener
* - onReconnectListener
* - onSessionExpiredListener
* - onLogListener
*/

/**
Expand Down Expand Up @@ -45712,6 +45713,12 @@ function ChatProxy(service) {
* @memberOf QB.chat
**/

/**
* Run after disconnect from chat to log result
* @function onLogListener
* @memberOf QB.chat
**/


this._onMessage = function (stanza) {
var from = chatUtils.getAttr(stanza, 'from'),
Expand Down Expand Up @@ -46168,7 +46175,7 @@ ChatProxy.prototype = {
/** Connect for browser env. */
if (Utils.getEnv().browser) {
Utils.QBLog('[QBChat]', '!!---Browser env - connected--!!');

let disconnectCondition = '';
self.connection.connect(userJid, params.password, function (status) {
Utils.QBLog('[QBChat]', 'self.connection.connect called with status ' + status);
switch (status) {
Expand Down Expand Up @@ -46297,7 +46304,14 @@ ChatProxy.prototype = {
break;
case Strophe.Status.DISCONNECTED:
Utils.QBLog('[QBChat]', 'Status.DISCONNECTED at ' + chatUtils.getLocalTime());

//
Utils.QBLog('[QBChat]', 'DISCONNECTED CONDITION: ' + disconnectCondition);
//
if (typeof self.onLogListener === 'function') {
Utils.safeCallbackCall(self.onLogListener,
'[QBChat]' + ' Status.DISCONNECTED at ' +
chatUtils.getLocalTime()+ ' DISCONNECTED CONDITION: ' + disconnectCondition);
}
// fire 'onDisconnectedListener' only once
if (self.isConnected && typeof self.onDisconnectedListener === 'function') {
Utils.safeCallbackCall(self.onDisconnectedListener);
Expand All @@ -46316,6 +46330,28 @@ ChatProxy.prototype = {
break;
}
});
// connection error handler
self.connection.xmlInput = function (data) {
try {
let parser = new DOMParser();
let xmlDoc = parser.parseFromString(data, 'text/xml');

let errorElem = xmlDoc.getElementsByTagName('error');
if (errorElem.length > 0) {
let conditionElem = errorElem[0].getElementsByTagName('condition');
if (conditionElem.length > 0) {
disconnectCondition = conditionElem[0].textContent;
console.log('Disconnect condition:', disconnectCondition);
if (typeof self.onLogListener === 'function') {
Utils.safeCallbackCall(self.onLogListener,
'[QBChat]' + ' DISCONNECTED CONDITION: ' + disconnectCondition);
}
}
}
} catch (e) {
console.error('Error parsing XML input:', e);
}
};
}

/** connect for node */
Expand Down Expand Up @@ -46455,27 +46491,56 @@ ChatProxy.prototype = {
_establishConnection: function (params) {
var self = this;
Utils.QBLog('[QBChat]', '_establishConnection called');
if (typeof self.onLogListener === 'function') {
Utils.safeCallbackCall(self.onLogListener,
'[QBChat]' + '_establishConnection called');
}
if (self._isLogout || self._checkConnectionTimer) {
Utils.QBLog('[QBChat]', '_establishConnection return');
if (typeof self.onLogListener === 'function') {
Utils.safeCallbackCall(self.onLogListener,
'[QBChat]' + ' _establishConnection return with self._isLogout: '+
self._isLogout+' and self._checkConnectionTimer ' +self._checkConnectionTimer?'set up':'undefined');
}
return;
}

var _connect = function () {
Utils.QBLog('[QBChat]', 'call _connect() in _establishConnection ');
if (typeof self.onLogListener === 'function') {
Utils.safeCallbackCall(self.onLogListener,
'[QBChat]' + ' call _connect() in _establishConnection ');
}
if (!self.isConnected && !self._isConnecting && !self._sessionHasExpired) {
Utils.QBLog('[QBChat]', 'call connect() again in _establishConnection ');
Utils.QBLog('[QBChat]', ' start execute connect() in _establishConnection ');
if (typeof self.onLogListener === 'function') {
Utils.safeCallbackCall(self.onLogListener,
'[QBChat]' + ' with statuses (!self.isConnected && !self._isConnecting && !self._sessionHasExpired): '+' self.isConnected: '+self.isConnected+' self._isConnecting: '+self._isConnecting+' self._sessionHasExpired: '+self._sessionHasExpired);
}
self.connect(params);
if (typeof self.onLogListener === 'function') {
Utils.safeCallbackCall(self.onLogListener,
'[QBChat]' + 'call _connect() in _establishConnection is executed');
}
} else {
Utils.QBLog('[QBChat]', 'stop timer in _establishConnection ');
clearInterval(self._checkConnectionTimer);
self._checkConnectionTimer = undefined;
if (typeof self.onLogListener === 'function') {
Utils.safeCallbackCall(self.onLogListener,
'[QBChat]' + 'stop timer in _establishConnection ');
}
}
};

_connect();

self._checkConnectionTimer = setInterval(function () {
Utils.QBLog('[QBChat]', 'self._checkConnectionTimer called with config.chatReconnectionTimeInterval = ' + config.chatReconnectionTimeInterval);
if (typeof self.onLogListener === 'function') {
Utils.safeCallbackCall(self.onLogListener,
'[QBChat]' + 'self._checkConnectionTimer called with config.chatReconnectionTimeInterval = ' + config.chatReconnectionTimeInterval);
}
_connect();
}, config.chatReconnectionTimeInterval * 1000);
},
Expand Down Expand Up @@ -53809,8 +53874,8 @@ module.exports = StreamManagement;
*/

var config = {
version: '2.17.1',
buildNumber: '1161',
version: '2.18.0',
buildNumber: '1162',
creds: {
'appId': 0,
'authKey': '',
Expand Down Expand Up @@ -54252,7 +54317,7 @@ ServiceProxy.prototype = {
handleResponse: function(error, response, next, retry) {
// can add middleware here...
if (error) {
const errorMsg = JSON.stringify(error.message).toLowerCase();
const errorMsg = error.message ? JSON.stringify(error.message).toLowerCase() : '';
if (typeof config.on.sessionExpired === 'function' &&
error.code === 401 &&
errorMsg.indexOf('session does not exist') > -1) {
Expand Down Expand Up @@ -54522,7 +54587,7 @@ var config = require('./qbConfig');
var chatPRTCL = config.chatProtocol;
var Utils = require('./qbUtils');

function Connection() {
function Connection(onLogListener) {
var protocol = chatPRTCL.active === 1 ? chatPRTCL.bosh : chatPRTCL.websocket;
var conn = new Strophe.Connection(protocol);

Expand All @@ -54544,6 +54609,27 @@ function Connection() {
} else {
conn.xmlInput = function(data) {
Utils.QBLog('[QBChat]', 'RECV:', data);
//
try {
let parser = new DOMParser();
let xmlDoc = parser.parseFromString(data, 'text/xml');

let errorElem = xmlDoc.getElementsByTagName('error');
if (errorElem.length > 0) {
let conditionElem = errorElem[0].getElementsByTagName('condition');
if (conditionElem.length > 0) {
let disconnectCondition = conditionElem[0].textContent;
console.log('Disconnect condition:', disconnectCondition);
if (onLogListener && typeof onLogListener === 'function') {
Utils.safeCallbackCall(onLogListener,
'[QBChat][QBStrophe]' + 'DISCONNECTED CONDITION: ' + disconnectCondition);
}
}
}
} catch (e) {
console.error('Error parsing XML input:', e);
}
//
};
conn.xmlOutput = function(data) {
Utils.QBLog('[QBChat]', 'SENT:', data);
Expand Down
2 changes: 1 addition & 1 deletion quickblox.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion samples/chat/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ END WELCOME MESSAGE


.moreList {
height: 86px;
height: 106px;
width: 146px;
border-radius: 14px;
background-color: rgba(255, 255, 255, 0.9);
Expand Down
5 changes: 3 additions & 2 deletions samples/chat/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ <h2>Info</h2>
</div>
<ul class="moreList">
<li>Chat info</li>
<li>Leave Chat</li>
<li>Leave chat</li>
<li>Back to Chat</li>
</ul>

</div>
Expand All @@ -132,7 +133,7 @@ <h2>Info</h2>

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

</div>

Expand Down
Loading

0 comments on commit 6e33cbc

Please sign in to comment.