Skip to content

Commit

Permalink
SDK version updated to 2.13.11
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-khomutovskyi-qb committed Apr 7, 2022
1 parent 7b56dc6 commit f211179
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 80 deletions.
14 changes: 8 additions & 6 deletions README.md
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/quickblox.min.js"></script>
<script src="https://unpkg.com/quickblox@2.13.11/quickblox.min.js"></script>
```

## Bower and RequireJS
Expand All @@ -40,10 +40,10 @@ npm install quickblox --save
And you're ready to go:

```javascript
var QB = require('quickblox');
var QB = require("quickblox");

// OR to create many QB instances
var QuickBlox = require('quickblox').QuickBlox;
var QuickBlox = require("quickblox").QuickBlox;
var QB1 = new QuickBlox();
var QB2 = new QuickBlox();
```
Expand All @@ -54,9 +54,9 @@ var QB2 = new QuickBlox();

# Browsers support

| Edge | Firefox | Chrome | Safari | Opera | Node.js |
|:----:|:-------:|:------:|:------:|:-----:|:-------:|
| 14+ | 52+ | 50+ | 11.1+ | 36+ | 6+ |
| Edge | Firefox | Chrome | Safari | Opera | Node.js |
| :--: | :-----: | :----: | :----: | :---: | :-----: |
| 14+ | 52+ | 50+ | 11.1+ | 36+ | 6+ |

# Documentation

Expand All @@ -69,7 +69,9 @@ Please raise questions, requests for help etc. via https://stackoverflow.com/que
Feedback and suggestions for improvement always welcome :)

# How to contribute

See more information at [contributing.md](https://github.com/QuickBlox/quickblox-javascript-sdk/blob/gh-pages/.github/CONTRIBUTING.md)

# License

Apache 2.0
3 changes: 2 additions & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "quickblox",
"description": "QuickBlox JavaScript SDK",
"version": "2.13.10",
"version": "2.13.11",
"homepage": "https://quickblox.com/developers/Javascript",
"main": "src/qbMain.js",
"license": "(Apache-2.0)",
Expand Down Expand Up @@ -76,6 +76,7 @@
}
},
"scripts": {
"dev": "NODE_ENV=develop gulp watch",
"setDependencies": "npm i && npm i -g gulp-cli && npm install rimraf -g && npm install -g jasmine",
"lint": "jshint src --reporter=node_modules/jshint-stylish",
"build": "cross-env NODE_ENV=production npm run lint && gulp build && gulp minify",
Expand Down
82 changes: 52 additions & 30 deletions quickblox.js
Expand Up @@ -46856,7 +46856,7 @@ ChatProxy.prototype = {
case Strophe.Status.AUTHFAIL:
self.isConnected = false;
self._isConnecting = false;

err = Utils.getError(401, 'Status.AUTHFAIL - The authentication attempt failed', 'QBChat');

if (isInitialConnect) {
Expand Down Expand Up @@ -47200,10 +47200,12 @@ ChatProxy.prototype = {
xmlns: chatUtils.MARKERS.STATES
});

if(Utils.getEnv().browser){
self.connection.send(stanza);
} else {
self.Client.send(stanza);
if (self.connection.connected) {
if(Utils.getEnv().browser){
self.connection.send(stanza);
} else {
self.Client.send(stanza);
}
}
},

Expand All @@ -47227,10 +47229,12 @@ ChatProxy.prototype = {
xmlns: chatUtils.MARKERS.STATES
});

if(Utils.getEnv().browser){
self.connection.send(stanza);
} else {
self.Client.send(stanza);
if (self.connection.connected) {
if(Utils.getEnv().browser){
self.connection.send(stanza);
} else {
self.Client.send(stanza);
}
}
},

Expand Down Expand Up @@ -53454,6 +53458,8 @@ function StreamManagement(options) {
// The client send stanza counter.
this._clientSentStanzasCounter = null;

this._intervalId = null;

this._timeInterval = 2000;

this.sentMessageCallback = null;
Expand Down Expand Up @@ -53538,7 +53544,12 @@ StreamManagement.prototype._addEnableHandlers = function () {
if(tagName === 'enabled'){
self._isStreamManagementEnabled = true;

setInterval(self._timeoutCallback.bind(self), self._timeInterval);
return true;
}

if (self._isStreamManagementEnabled && tagName === 'message') {
clearInterval(self._intervalId);
self._intervalId = setInterval(self._timeoutCallback.bind(self), self._timeInterval);

return true;
}
Expand Down Expand Up @@ -53578,17 +53589,22 @@ StreamManagement.prototype.send = function (stanza, message) {
bodyContent = chatUtils.getElementText(stanzaXML, 'body') || '',
attachments = chatUtils.getAllElements(stanzaXML, 'attachment') || '';

self._originalSend.call(self._c, stanza);

if (tagName === 'message' && (type === 'chat' || type === 'groupchat') && (bodyContent || attachments.length)) {
self._sendStanzasRequest({
message: message,
time: Date.now() + self._timeInterval,
expect: self._clientSentStanzasCounter
});
try {
self._originalSend.call(self._c, stanza);
} catch (e) {
Utils.QBLog('[QBChat]', e.message);
} finally {
if (tagName === 'message' && (type === 'chat' || type === 'groupchat') && (bodyContent || attachments.length)) {
self._sendStanzasRequest({
message: message,
time: Date.now() + self._timeInterval,
expect: self._clientSentStanzasCounter
});
}

self._clientSentStanzasCounter++;
}

self._clientSentStanzasCounter++;
};

StreamManagement.prototype._sendStanzasRequest = function (data) {
Expand All @@ -53597,10 +53613,14 @@ StreamManagement.prototype._sendStanzasRequest = function (data) {
if(self._isStreamManagementEnabled){
self._stanzasQueue.push(data);

var stanza = Utils.getEnv().browser ? $build('r', { xmlns: self._NS}) :
chatUtils.createStanza(self._nodeBuilder, { xmlns: self._NS}, 'r');
var stanza = Utils.getEnv().browser ? $build('r', { xmlns: self._NS }) :
chatUtils.createStanza(self._nodeBuilder, { xmlns: self._NS }, 'r');

self._originalSend.call(self._c, stanza);
if (self._c.connected) {
self._originalSend.call(self._c, stanza);
} else {
self._checkCounterOnIncomeStanza();
}
}
};

Expand All @@ -53609,13 +53629,15 @@ StreamManagement.prototype.getClientSentStanzasCounter = function(){
};

StreamManagement.prototype._checkCounterOnIncomeStanza = function (count){
if (this._stanzasQueue[0].expect !== count){
this.sentMessageCallback(this._stanzasQueue[0].message);
} else {
this.sentMessageCallback(null, this._stanzasQueue[0].message);
if (this._stanzasQueue.length) {
if (this._stanzasQueue[0].expect !== count){
this.sentMessageCallback(this._stanzasQueue[0].message);
} else {
this.sentMessageCallback(null, this._stanzasQueue[0].message);
}

this._stanzasQueue.shift();
}

this._stanzasQueue.shift();
};

StreamManagement.prototype._increaseReceivedStanzasCounter = function(){
Expand All @@ -53639,8 +53661,8 @@ module.exports = StreamManagement;
*/

var config = {
version: '2.13.10',
buildNumber: '1104',
version: '2.13.11',
buildNumber: '1105',
creds: {
appId: '',
authKey: '',
Expand Down
2 changes: 1 addition & 1 deletion quickblox.min.js

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions samples/chat/index.html 100644 → 100755
Expand Up @@ -72,18 +72,6 @@
}

})(console);


var lastFired = new Date().getTime();
setInterval(async function() {
now = new Date().getTime();
if(now - lastFired > 4000) {//if it's been more than 5 seconds
lastFired = now;
await window.qbConnect.connect();
await helpers.renderDashboard();
}
lastFired = now;
}, 400);
</script>

</head>
Expand Down
22 changes: 13 additions & 9 deletions src/modules/chat/qbChat.js
Expand Up @@ -768,7 +768,7 @@ ChatProxy.prototype = {
case Strophe.Status.AUTHFAIL:
self.isConnected = false;
self._isConnecting = false;

err = Utils.getError(401, 'Status.AUTHFAIL - The authentication attempt failed', 'QBChat');

if (isInitialConnect) {
Expand Down Expand Up @@ -1112,10 +1112,12 @@ ChatProxy.prototype = {
xmlns: chatUtils.MARKERS.STATES
});

if(Utils.getEnv().browser){
self.connection.send(stanza);
} else {
self.Client.send(stanza);
if (self.connection.connected) {
if(Utils.getEnv().browser){
self.connection.send(stanza);
} else {
self.Client.send(stanza);
}
}
},

Expand All @@ -1139,10 +1141,12 @@ ChatProxy.prototype = {
xmlns: chatUtils.MARKERS.STATES
});

if(Utils.getEnv().browser){
self.connection.send(stanza);
} else {
self.Client.send(stanza);
if (self.connection.connected) {
if(Utils.getEnv().browser){
self.connection.send(stanza);
} else {
self.Client.send(stanza);
}
}
},

Expand Down
56 changes: 37 additions & 19 deletions src/plugins/streamManagement.js
Expand Up @@ -43,6 +43,8 @@ function StreamManagement(options) {
// The client send stanza counter.
this._clientSentStanzasCounter = null;

this._intervalId = null;

this._timeInterval = 2000;

this.sentMessageCallback = null;
Expand Down Expand Up @@ -127,7 +129,12 @@ StreamManagement.prototype._addEnableHandlers = function () {
if(tagName === 'enabled'){
self._isStreamManagementEnabled = true;

setInterval(self._timeoutCallback.bind(self), self._timeInterval);
return true;
}

if (self._isStreamManagementEnabled && tagName === 'message') {
clearInterval(self._intervalId);
self._intervalId = setInterval(self._timeoutCallback.bind(self), self._timeInterval);

return true;
}
Expand Down Expand Up @@ -167,17 +174,22 @@ StreamManagement.prototype.send = function (stanza, message) {
bodyContent = chatUtils.getElementText(stanzaXML, 'body') || '',
attachments = chatUtils.getAllElements(stanzaXML, 'attachment') || '';

self._originalSend.call(self._c, stanza);

if (tagName === 'message' && (type === 'chat' || type === 'groupchat') && (bodyContent || attachments.length)) {
self._sendStanzasRequest({
message: message,
time: Date.now() + self._timeInterval,
expect: self._clientSentStanzasCounter
});
try {
self._originalSend.call(self._c, stanza);
} catch (e) {
Utils.QBLog('[QBChat]', e.message);
} finally {
if (tagName === 'message' && (type === 'chat' || type === 'groupchat') && (bodyContent || attachments.length)) {
self._sendStanzasRequest({
message: message,
time: Date.now() + self._timeInterval,
expect: self._clientSentStanzasCounter
});
}

self._clientSentStanzasCounter++;
}

self._clientSentStanzasCounter++;
};

StreamManagement.prototype._sendStanzasRequest = function (data) {
Expand All @@ -186,10 +198,14 @@ StreamManagement.prototype._sendStanzasRequest = function (data) {
if(self._isStreamManagementEnabled){
self._stanzasQueue.push(data);

var stanza = Utils.getEnv().browser ? $build('r', { xmlns: self._NS}) :
chatUtils.createStanza(self._nodeBuilder, { xmlns: self._NS}, 'r');
var stanza = Utils.getEnv().browser ? $build('r', { xmlns: self._NS }) :
chatUtils.createStanza(self._nodeBuilder, { xmlns: self._NS }, 'r');

self._originalSend.call(self._c, stanza);
if (self._c.connected) {
self._originalSend.call(self._c, stanza);
} else {
self._checkCounterOnIncomeStanza();
}
}
};

Expand All @@ -198,13 +214,15 @@ StreamManagement.prototype.getClientSentStanzasCounter = function(){
};

StreamManagement.prototype._checkCounterOnIncomeStanza = function (count){
if (this._stanzasQueue[0].expect !== count){
this.sentMessageCallback(this._stanzasQueue[0].message);
} else {
this.sentMessageCallback(null, this._stanzasQueue[0].message);
if (this._stanzasQueue.length) {
if (this._stanzasQueue[0].expect !== count){
this.sentMessageCallback(this._stanzasQueue[0].message);
} else {
this.sentMessageCallback(null, this._stanzasQueue[0].message);
}

this._stanzasQueue.shift();
}

this._stanzasQueue.shift();
};

StreamManagement.prototype._increaseReceivedStanzasCounter = function(){
Expand Down
4 changes: 2 additions & 2 deletions src/qbConfig.js
Expand Up @@ -12,8 +12,8 @@
*/

var config = {
version: '2.13.10',
buildNumber: '1104',
version: '2.13.11',
buildNumber: '1105',
creds: {
appId: '',
authKey: '',
Expand Down

0 comments on commit f211179

Please sign in to comment.