Skip to content

Commit 891ee8f

Browse files
Vladlukhanindimaspirit
authored andcommitted
Added onReconnectFailedListener, onInvalidEventsListener , recipient_id to message object in onMessageListener
Added onReconnectFailedListener for catching authentication fail; Added onInvalidEventsListener for information on ignore (some exceptions); Added property recipient_id for the message object (message.recipient_id) in onMessageListener (only for forwarded messages);
1 parent bd42f73 commit 891ee8f

File tree

10 files changed

+225
-204
lines changed

10 files changed

+225
-204
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ For correct work of JS SDK you must include the library in your html before `qu
2020

2121
```html
2222
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
23-
<script src="https://cdnjs.cloudflare.com/ajax/libs/quickblox/2.1.4/quickblox.min.js"></script>
23+
<script src="https://cdnjs.cloudflare.com/ajax/libs/quickblox/2.1.5/quickblox.min.js"></script>
2424
```
2525

2626
## Bower and RequireJS

bower.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.1.4",
4+
"version": "2.1.5",
55
"homepage": "https://quickblox.com/developers/Javascript",
66
"main": "quickblox.js",
77
"license": "Apache 2.0",

js/modules/qbChat.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ function ChatProxy(service, webrtcModule, conn) {
7979
extraParams = stanza.querySelector('extraParams'),
8080
delay = stanza.querySelector('delay'),
8181
messageId = stanza.getAttribute('id'),
82+
recipient = stanza.querySelector('forwarded') ? stanza.querySelector('forwarded').querySelector('message').getAttribute('to') : null,
83+
recipientId = recipient ? self.helpers.getIdFromNode(recipient) : null,
8284
dialogId = type === 'groupchat' ? self.helpers.getDialogIdFromNode(from) : null,
8385
userId = type === 'groupchat' ? self.helpers.getIdFromResource(from) : self.helpers.getIdFromNode(from),
8486
marker = delivered || read || null;
8587

86-
8788
// ignore invite messages from MUC
8889
//
8990
if (invite) return true;
9091

91-
9292
// parse extra params
9393
var extraParamsParsed;
9494
if(extraParams){
@@ -139,6 +139,7 @@ function ChatProxy(service, webrtcModule, conn) {
139139
var message = {
140140
id: messageId,
141141
dialog_id: dialogId,
142+
recipient_id: recipientId,
142143
type: type,
143144
body: (body && body.textContent) || null,
144145
extension: extraParamsParsed ? extraParamsParsed.extension : null,
@@ -329,22 +330,31 @@ ChatProxy.prototype = {
329330
switch (status) {
330331
case Strophe.Status.ERROR:
331332
err = Utils.getError(422, 'Status.ERROR - An error has occurred');
332-
if (typeof callback === 'function') callback(err, null);
333+
if (typeof callback === 'function') {
334+
callback(err, null);
335+
}
333336
break;
334337
case Strophe.Status.CONNECTING:
335338
Utils.QBLog('[ChatProxy]', 'Status.CONNECTING');
336339
Utils.QBLog('[ChatProxy]', 'Chat Protocol - ' + (config.chatProtocol.active === 1 ? 'BOSH' : 'WebSocket'));
337340
break;
338341
case Strophe.Status.CONNFAIL:
339342
err = Utils.getError(422, 'Status.CONNFAIL - The connection attempt failed');
340-
if (typeof callback === 'function') callback(err, null);
343+
if (typeof callback === 'function') {
344+
callback(err, null);
345+
}
341346
break;
342347
case Strophe.Status.AUTHENTICATING:
343348
Utils.QBLog('[ChatProxy]', 'Status.AUTHENTICATING');
344349
break;
345350
case Strophe.Status.AUTHFAIL:
346351
err = Utils.getError(401, 'Status.AUTHFAIL - The authentication attempt failed');
347-
if (typeof callback === 'function') callback(err, null);
352+
if (typeof callback === 'function') {
353+
callback(err, null);
354+
}
355+
if(self._isDisconnected && typeof self.onReconnectFailedListener === 'function'){
356+
Utils.safeCallbackCall(self.onReconnectFailedListener, err);
357+
}
348358
break;
349359
case Strophe.Status.CONNECTED:
350360
Utils.QBLog('[ChatProxy]', 'Status.CONNECTED at ' + getLocalTime());

0 commit comments

Comments
 (0)