@@ -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
5359453610StreamManagement.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
5361153631StreamManagement.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
5362153643StreamManagement.prototype._increaseReceivedStanzasCounter = function(){
@@ -53639,8 +53661,8 @@ module.exports = StreamManagement;
5363953661 */
5364053662
5364153663var config = {
53642- version: '2.13.10 ',
53643- buildNumber: '1104 ',
53664+ version: '2.13.11 ',
53665+ buildNumber: '1105 ',
5364453666 creds: {
5364553667 appId: '',
5364653668 authKey: '',
0 commit comments