Skip to content

Commit f211179

Browse files
SDK version updated to 2.13.11
1 parent 7b56dc6 commit f211179

File tree

8 files changed

+115
-80
lines changed

8 files changed

+115
-80
lines changed

README.md

Lines changed: 8 additions & 6 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/quickblox.min.js"></script>
19+
<script src="https://unpkg.com/quickblox@2.13.11/quickblox.min.js"></script>
2020
```
2121

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

4242
```javascript
43-
var QB = require('quickblox');
43+
var QB = require("quickblox");
4444

4545
// OR to create many QB instances
46-
var QuickBlox = require('quickblox').QuickBlox;
46+
var QuickBlox = require("quickblox").QuickBlox;
4747
var QB1 = new QuickBlox();
4848
var QB2 = new QuickBlox();
4949
```
@@ -54,9 +54,9 @@ var QB2 = new QuickBlox();
5454

5555
# Browsers support
5656

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

6161
# Documentation
6262

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

7171
# How to contribute
72+
7273
See more information at [contributing.md](https://github.com/QuickBlox/quickblox-javascript-sdk/blob/gh-pages/.github/CONTRIBUTING.md)
7374

7475
# License
76+
7577
Apache 2.0

package.json

Lines changed: 2 additions & 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.13.10",
4+
"version": "2.13.11",
55
"homepage": "https://quickblox.com/developers/Javascript",
66
"main": "src/qbMain.js",
77
"license": "(Apache-2.0)",
@@ -76,6 +76,7 @@
7676
}
7777
},
7878
"scripts": {
79+
"dev": "NODE_ENV=develop gulp watch",
7980
"setDependencies": "npm i && npm i -g gulp-cli && npm install rimraf -g && npm install -g jasmine",
8081
"lint": "jshint src --reporter=node_modules/jshint-stylish",
8182
"build": "cross-env NODE_ENV=production npm run lint && gulp build && gulp minify",

quickblox.js

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46856,7 +46856,7 @@ ChatProxy.prototype = {
4685646856
case Strophe.Status.AUTHFAIL:
4685746857
self.isConnected = false;
4685846858
self._isConnecting = false;
46859-
46859+
4686046860
err = Utils.getError(401, 'Status.AUTHFAIL - The authentication attempt failed', 'QBChat');
4686146861

4686246862
if (isInitialConnect) {
@@ -47200,10 +47200,12 @@ ChatProxy.prototype = {
4720047200
xmlns: chatUtils.MARKERS.STATES
4720147201
});
4720247202

47203-
if(Utils.getEnv().browser){
47204-
self.connection.send(stanza);
47205-
} else {
47206-
self.Client.send(stanza);
47203+
if (self.connection.connected) {
47204+
if(Utils.getEnv().browser){
47205+
self.connection.send(stanza);
47206+
} else {
47207+
self.Client.send(stanza);
47208+
}
4720747209
}
4720847210
},
4720947211

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

47230-
if(Utils.getEnv().browser){
47231-
self.connection.send(stanza);
47232-
} else {
47233-
self.Client.send(stanza);
47232+
if (self.connection.connected) {
47233+
if(Utils.getEnv().browser){
47234+
self.connection.send(stanza);
47235+
} else {
47236+
self.Client.send(stanza);
47237+
}
4723447238
}
4723547239
},
4723647240

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

53461+
this._intervalId = null;
53462+
5345753463
this._timeInterval = 2000;
5345853464

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

53541-
setInterval(self._timeoutCallback.bind(self), self._timeInterval);
53547+
return true;
53548+
}
53549+
53550+
if (self._isStreamManagementEnabled && tagName === 'message') {
53551+
clearInterval(self._intervalId);
53552+
self._intervalId = setInterval(self._timeoutCallback.bind(self), self._timeInterval);
5354253553

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

53581-
self._originalSend.call(self._c, stanza);
53582-
53583-
if (tagName === 'message' && (type === 'chat' || type === 'groupchat') && (bodyContent || attachments.length)) {
53584-
self._sendStanzasRequest({
53585-
message: message,
53586-
time: Date.now() + self._timeInterval,
53587-
expect: self._clientSentStanzasCounter
53588-
});
53592+
try {
53593+
self._originalSend.call(self._c, stanza);
53594+
} catch (e) {
53595+
Utils.QBLog('[QBChat]', e.message);
53596+
} finally {
53597+
if (tagName === 'message' && (type === 'chat' || type === 'groupchat') && (bodyContent || attachments.length)) {
53598+
self._sendStanzasRequest({
53599+
message: message,
53600+
time: Date.now() + self._timeInterval,
53601+
expect: self._clientSentStanzasCounter
53602+
});
53603+
}
53604+
53605+
self._clientSentStanzasCounter++;
5358953606
}
5359053607

53591-
self._clientSentStanzasCounter++;
5359253608
};
5359353609

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

53600-
var stanza = Utils.getEnv().browser ? $build('r', { xmlns: self._NS}) :
53601-
chatUtils.createStanza(self._nodeBuilder, { xmlns: self._NS}, 'r');
53616+
var stanza = Utils.getEnv().browser ? $build('r', { xmlns: self._NS }) :
53617+
chatUtils.createStanza(self._nodeBuilder, { xmlns: self._NS }, 'r');
5360253618

53603-
self._originalSend.call(self._c, stanza);
53619+
if (self._c.connected) {
53620+
self._originalSend.call(self._c, stanza);
53621+
} else {
53622+
self._checkCounterOnIncomeStanza();
53623+
}
5360453624
}
5360553625
};
5360653626

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

5361153631
StreamManagement.prototype._checkCounterOnIncomeStanza = function (count){
53612-
if (this._stanzasQueue[0].expect !== count){
53613-
this.sentMessageCallback(this._stanzasQueue[0].message);
53614-
} else {
53615-
this.sentMessageCallback(null, this._stanzasQueue[0].message);
53632+
if (this._stanzasQueue.length) {
53633+
if (this._stanzasQueue[0].expect !== count){
53634+
this.sentMessageCallback(this._stanzasQueue[0].message);
53635+
} else {
53636+
this.sentMessageCallback(null, this._stanzasQueue[0].message);
53637+
}
53638+
53639+
this._stanzasQueue.shift();
5361653640
}
53617-
53618-
this._stanzasQueue.shift();
5361953641
};
5362053642

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

5364153663
var config = {
53642-
version: '2.13.10',
53643-
buildNumber: '1104',
53664+
version: '2.13.11',
53665+
buildNumber: '1105',
5364453666
creds: {
5364553667
appId: '',
5364653668
authKey: '',

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/index.html

100644100755
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,6 @@
7272
}
7373

7474
})(console);
75-
76-
77-
var lastFired = new Date().getTime();
78-
setInterval(async function() {
79-
now = new Date().getTime();
80-
if(now - lastFired > 4000) {//if it's been more than 5 seconds
81-
lastFired = now;
82-
await window.qbConnect.connect();
83-
await helpers.renderDashboard();
84-
}
85-
lastFired = now;
86-
}, 400);
8775
</script>
8876

8977
</head>

src/modules/chat/qbChat.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ ChatProxy.prototype = {
768768
case Strophe.Status.AUTHFAIL:
769769
self.isConnected = false;
770770
self._isConnecting = false;
771-
771+
772772
err = Utils.getError(401, 'Status.AUTHFAIL - The authentication attempt failed', 'QBChat');
773773

774774
if (isInitialConnect) {
@@ -1112,10 +1112,12 @@ ChatProxy.prototype = {
11121112
xmlns: chatUtils.MARKERS.STATES
11131113
});
11141114

1115-
if(Utils.getEnv().browser){
1116-
self.connection.send(stanza);
1117-
} else {
1118-
self.Client.send(stanza);
1115+
if (self.connection.connected) {
1116+
if(Utils.getEnv().browser){
1117+
self.connection.send(stanza);
1118+
} else {
1119+
self.Client.send(stanza);
1120+
}
11191121
}
11201122
},
11211123

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

1142-
if(Utils.getEnv().browser){
1143-
self.connection.send(stanza);
1144-
} else {
1145-
self.Client.send(stanza);
1144+
if (self.connection.connected) {
1145+
if(Utils.getEnv().browser){
1146+
self.connection.send(stanza);
1147+
} else {
1148+
self.Client.send(stanza);
1149+
}
11461150
}
11471151
},
11481152

src/plugins/streamManagement.js

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ function StreamManagement(options) {
4343
// The client send stanza counter.
4444
this._clientSentStanzasCounter = null;
4545

46+
this._intervalId = null;
47+
4648
this._timeInterval = 2000;
4749

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

130-
setInterval(self._timeoutCallback.bind(self), self._timeInterval);
132+
return true;
133+
}
134+
135+
if (self._isStreamManagementEnabled && tagName === 'message') {
136+
clearInterval(self._intervalId);
137+
self._intervalId = setInterval(self._timeoutCallback.bind(self), self._timeInterval);
131138

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

170-
self._originalSend.call(self._c, stanza);
171-
172-
if (tagName === 'message' && (type === 'chat' || type === 'groupchat') && (bodyContent || attachments.length)) {
173-
self._sendStanzasRequest({
174-
message: message,
175-
time: Date.now() + self._timeInterval,
176-
expect: self._clientSentStanzasCounter
177-
});
177+
try {
178+
self._originalSend.call(self._c, stanza);
179+
} catch (e) {
180+
Utils.QBLog('[QBChat]', e.message);
181+
} finally {
182+
if (tagName === 'message' && (type === 'chat' || type === 'groupchat') && (bodyContent || attachments.length)) {
183+
self._sendStanzasRequest({
184+
message: message,
185+
time: Date.now() + self._timeInterval,
186+
expect: self._clientSentStanzasCounter
187+
});
188+
}
189+
190+
self._clientSentStanzasCounter++;
178191
}
179192

180-
self._clientSentStanzasCounter++;
181193
};
182194

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

189-
var stanza = Utils.getEnv().browser ? $build('r', { xmlns: self._NS}) :
190-
chatUtils.createStanza(self._nodeBuilder, { xmlns: self._NS}, 'r');
201+
var stanza = Utils.getEnv().browser ? $build('r', { xmlns: self._NS }) :
202+
chatUtils.createStanza(self._nodeBuilder, { xmlns: self._NS }, 'r');
191203

192-
self._originalSend.call(self._c, stanza);
204+
if (self._c.connected) {
205+
self._originalSend.call(self._c, stanza);
206+
} else {
207+
self._checkCounterOnIncomeStanza();
208+
}
193209
}
194210
};
195211

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

200216
StreamManagement.prototype._checkCounterOnIncomeStanza = function (count){
201-
if (this._stanzasQueue[0].expect !== count){
202-
this.sentMessageCallback(this._stanzasQueue[0].message);
203-
} else {
204-
this.sentMessageCallback(null, this._stanzasQueue[0].message);
217+
if (this._stanzasQueue.length) {
218+
if (this._stanzasQueue[0].expect !== count){
219+
this.sentMessageCallback(this._stanzasQueue[0].message);
220+
} else {
221+
this.sentMessageCallback(null, this._stanzasQueue[0].message);
222+
}
223+
224+
this._stanzasQueue.shift();
205225
}
206-
207-
this._stanzasQueue.shift();
208226
};
209227

210228
StreamManagement.prototype._increaseReceivedStanzasCounter = function(){

src/qbConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
*/
1313

1414
var config = {
15-
version: '2.13.10',
16-
buildNumber: '1104',
15+
version: '2.13.11',
16+
buildNumber: '1105',
1717
creds: {
1818
appId: '',
1919
authKey: '',

0 commit comments

Comments
 (0)