Skip to content

Commit 3e7b06c

Browse files
committed
fix(caps): add event to notify when caps version for a user is changed
1 parent 4f5cf8d commit 3e7b06c

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

JitsiConferenceEventManager.js

+10
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,16 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function () {
506506
*/
507507
JitsiConferenceEventManager.prototype.setupXMPPListeners = function () {
508508
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+
});
509519
conference.xmpp.addListener(
510520
XMPPEvents.CALL_INCOMING, conference.onIncomingCall.bind(conference));
511521
conference.xmpp.addListener(

JitsiConferenceEvents.js

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ export const MESSAGE_RECEIVED = "conference.messageReceived";
100100
*/
101101
export const PARTICIPANT_CONN_STATUS_CHANGED
102102
= "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";
103108
/**
104109
* Indicates that a the value of a specific property of a specific participant
105110
* has changed.

JitsiParticipantEvents.js

Whitespace-only changes.

modules/xmpp/Caps.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* global $, b64_sha1, Strophe */
22
import XMPPEvents from "../../service/xmpp/XMPPEvents";
3+
import Listenable from "../util/Listenable";
34

45
/**
56
* The property
@@ -19,14 +20,15 @@ function compareIdentities(a, b) {
1920
/**
2021
* Implements xep-0115 ( http://xmpp.org/extensions/xep-0115.html )
2122
*/
22-
export default class Caps {
23+
export default class Caps extends Listenable {
2324
/**
2425
* Constructs new Caps instance.
2526
* @param {Strophe.Connection} connection the strophe connection object
2627
* @param {String} node the value of the node attribute of the "c" xml node
2728
* that will be sent to the other participants
2829
*/
2930
constructor(connection = {}, node = "http://jitsi.org/jitsimeet") {
31+
super();
3032
this.node = node;
3133
this.disco = connection.disco;
3234
if(!this.disco) {
@@ -193,7 +195,12 @@ export default class Caps {
193195
const caps = stanza.querySelector("c");
194196
const version = caps.getAttribute("ver");
195197
const node = caps.getAttribute("node");
198+
const oldVersion = this.jidToVersion[from];
196199
this.jidToVersion[from] = {version, node};
200+
if(oldVersion && oldVersion.version !== version) {
201+
this.eventEmitter.emit(XMPPEvents.PARTCIPANT_FEATURES_CHANGED,
202+
from);
203+
}
197204
// return true to not remove the handler from Strophe
198205
return true;
199206
}

service/xmpp/XMPPEvents.js

+4
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ var XMPPEvents = {
106106
// Note: currently this event fires every time we receive presence from
107107
// someone (regardless of whether or not the "video type" changed).
108108
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",
109113
PASSWORD_REQUIRED: "xmpp.password_required",
110114
PEERCONNECTION_READY: "xmpp.peerconnection_ready",
111115
/**

0 commit comments

Comments
 (0)