Browse Source

fix(caps): add event to notify when caps version for a user is changed

tags/v0.0.2
hristoterezov 7 years ago
parent
commit
3e7b06c1b1

+ 10
- 0
JitsiConferenceEventManager.js View File

@@ -506,6 +506,16 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function () {
506 506
  */
507 507
 JitsiConferenceEventManager.prototype.setupXMPPListeners = function () {
508 508
     var conference = this.conference;
509
+    conference.xmpp.caps.addListener(XMPPEvents.PARTCIPANT_FEATURES_CHANGED,
510
+        from => {
511
+            const participant = conference.getParticipantId(
512
+                Strophe.getResourceFromJid(from));
513
+            if(participant) {
514
+                conference.eventEmitter.emit(
515
+                    JitsiConferenceEvents.PARTCIPANT_FEATURES_CHANGED,
516
+                    participant);
517
+            }
518
+        });
509 519
     conference.xmpp.addListener(
510 520
         XMPPEvents.CALL_INCOMING, conference.onIncomingCall.bind(conference));
511 521
     conference.xmpp.addListener(

+ 5
- 0
JitsiConferenceEvents.js View File

@@ -100,6 +100,11 @@ export const MESSAGE_RECEIVED = "conference.messageReceived";
100 100
  */
101 101
 export const PARTICIPANT_CONN_STATUS_CHANGED
102 102
     = "conference.participant_conn_status_changed";
103
+/**
104
+ * Indicates that the features of the participant has been changed.
105
+ */
106
+export const PARTCIPANT_FEATURES_CHANGED
107
+    = "conference.partcipant_features_changed";
103 108
 /**
104 109
  * Indicates that a the value of a specific property of a specific participant
105 110
  * has changed.

+ 0
- 0
JitsiParticipantEvents.js View File


+ 8
- 1
modules/xmpp/Caps.js View File

@@ -1,5 +1,6 @@
1 1
 /* global $, b64_sha1, Strophe */
2 2
 import XMPPEvents from "../../service/xmpp/XMPPEvents";
3
+import Listenable from "../util/Listenable";
3 4
 
4 5
 /**
5 6
  * The property
@@ -19,7 +20,7 @@ function compareIdentities(a, b) {
19 20
 /**
20 21
  * Implements xep-0115 ( http://xmpp.org/extensions/xep-0115.html )
21 22
  */
22
-export default class Caps {
23
+export default class Caps extends Listenable {
23 24
     /**
24 25
      * Constructs new Caps instance.
25 26
      * @param {Strophe.Connection} connection the strophe connection object
@@ -27,6 +28,7 @@ export default class Caps {
27 28
      * that will be sent to the other participants
28 29
      */
29 30
     constructor(connection = {}, node = "http://jitsi.org/jitsimeet") {
31
+        super();
30 32
         this.node = node;
31 33
         this.disco = connection.disco;
32 34
         if(!this.disco) {
@@ -193,7 +195,12 @@ export default class Caps {
193 195
         const caps = stanza.querySelector("c");
194 196
         const version = caps.getAttribute("ver");
195 197
         const node = caps.getAttribute("node");
198
+        const oldVersion = this.jidToVersion[from];
196 199
         this.jidToVersion[from] = {version, node};
200
+        if(oldVersion && oldVersion.version !== version) {
201
+            this.eventEmitter.emit(XMPPEvents.PARTCIPANT_FEATURES_CHANGED,
202
+                from);
203
+        }
197 204
         // return true to not remove the handler from Strophe
198 205
         return true;
199 206
     }

+ 4
- 0
service/xmpp/XMPPEvents.js View File

@@ -106,6 +106,10 @@ var XMPPEvents = {
106 106
     // Note: currently this event fires every time we receive presence from
107 107
     // someone (regardless of whether or not the "video type" changed).
108 108
     PARTICIPANT_VIDEO_TYPE_CHANGED: "xmpp.video_type",
109
+    /**
110
+     * Indicates that the features of the participant has been changed.
111
+     */
112
+    PARTCIPANT_FEATURES_CHANGED: "xmpp.partcipant_features_changed",
109 113
     PASSWORD_REQUIRED: "xmpp.password_required",
110 114
     PEERCONNECTION_READY: "xmpp.peerconnection_ready",
111 115
     /**

Loading…
Cancel
Save