Selaa lähdekoodia

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

master
hristoterezov 8 vuotta sitten
vanhempi
commit
3e7b06c1b1

+ 10
- 0
JitsiConferenceEventManager.js Näytä tiedosto

506
  */
506
  */
507
 JitsiConferenceEventManager.prototype.setupXMPPListeners = function () {
507
 JitsiConferenceEventManager.prototype.setupXMPPListeners = function () {
508
     var conference = this.conference;
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
     conference.xmpp.addListener(
519
     conference.xmpp.addListener(
510
         XMPPEvents.CALL_INCOMING, conference.onIncomingCall.bind(conference));
520
         XMPPEvents.CALL_INCOMING, conference.onIncomingCall.bind(conference));
511
     conference.xmpp.addListener(
521
     conference.xmpp.addListener(

+ 5
- 0
JitsiConferenceEvents.js Näytä tiedosto

100
  */
100
  */
101
 export const PARTICIPANT_CONN_STATUS_CHANGED
101
 export const PARTICIPANT_CONN_STATUS_CHANGED
102
     = "conference.participant_conn_status_changed";
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
  * Indicates that a the value of a specific property of a specific participant
109
  * Indicates that a the value of a specific property of a specific participant
105
  * has changed.
110
  * has changed.

+ 0
- 0
JitsiParticipantEvents.js Näytä tiedosto


+ 8
- 1
modules/xmpp/Caps.js Näytä tiedosto

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

+ 4
- 0
service/xmpp/XMPPEvents.js Näytä tiedosto

106
     // Note: currently this event fires every time we receive presence from
106
     // Note: currently this event fires every time we receive presence from
107
     // someone (regardless of whether or not the "video type" changed).
107
     // someone (regardless of whether or not the "video type" changed).
108
     PARTICIPANT_VIDEO_TYPE_CHANGED: "xmpp.video_type",
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
     PASSWORD_REQUIRED: "xmpp.password_required",
113
     PASSWORD_REQUIRED: "xmpp.password_required",
110
     PEERCONNECTION_READY: "xmpp.peerconnection_ready",
114
     PEERCONNECTION_READY: "xmpp.peerconnection_ready",
111
     /**
115
     /**

Loading…
Peruuta
Tallenna