|
@@ -0,0 +1,81 @@
|
|
1
|
+var logger = require("jitsi-meet-logger").getLogger(__filename);
|
|
2
|
+
|
|
3
|
+/**
|
|
4
|
+ * The constant for the name of the focus component.
|
|
5
|
+ * @type {string}
|
|
6
|
+ */
|
|
7
|
+ComponentsVersions.FOCUS_COMPONENT = "focus";
|
|
8
|
+/**
|
|
9
|
+ * The constant for the name of the videobridge component.
|
|
10
|
+ * @type {string}
|
|
11
|
+ */
|
|
12
|
+ComponentsVersions.VIDEOBRIDGE_COMPONENT = "videobridge";
|
|
13
|
+/**
|
|
14
|
+ * The contant for the name of the XMPP server component.
|
|
15
|
+ * @type {string}
|
|
16
|
+ */
|
|
17
|
+ComponentsVersions.XMPP_SERVER_COMPONENT = "xmpp";
|
|
18
|
+
|
|
19
|
+/**
|
|
20
|
+ * Creates new instance of <tt>ComponentsVersions</tt> which will be discovering
|
|
21
|
+ * the versions of conferencing system components in given <tt>ChatRoom</tt>.
|
|
22
|
+ * @param chatRoom <tt>ChatRoom</tt> instance which will be used to listen for
|
|
23
|
+ * focus presence updates.
|
|
24
|
+ * @constructor
|
|
25
|
+ */
|
|
26
|
+function ComponentsVersions(chatRoom) {
|
|
27
|
+
|
|
28
|
+ this.versions = {};
|
|
29
|
+
|
|
30
|
+ this.chatRoom = chatRoom;
|
|
31
|
+ this.chatRoom.addPresenceListener(
|
|
32
|
+ 'versions', this.processPresence.bind(this));
|
|
33
|
+}
|
|
34
|
+
|
|
35
|
+ComponentsVersions.prototype.processPresence =
|
|
36
|
+function(node, mucResource, mucJid) {
|
|
37
|
+
|
|
38
|
+ if (node.attributes.xmlns !== 'http://jitsi.org/jitmeet') {
|
|
39
|
+ logger.warn("Ignored presence versions node - invalid xmlns", node);
|
|
40
|
+ return;
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ if (!this.chatRoom.isFocus(mucJid)) {
|
|
44
|
+ logger.warn(
|
|
45
|
+ "Received versions not from the focus user: " + node, mucJid);
|
|
46
|
+ return;
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ node.children.forEach(function(item){
|
|
50
|
+
|
|
51
|
+ var componentName = item.attributes.name;
|
|
52
|
+ if (componentName !== ComponentsVersions.FOCUS_COMPONENT &&
|
|
53
|
+ componentName !== ComponentsVersions.XMPP_SERVER_COMPONENT &&
|
|
54
|
+ componentName !== ComponentsVersions.VIDEOBRIDGE_COMPONENT) {
|
|
55
|
+ logger.warn(
|
|
56
|
+ "Received version for not supported component name: "
|
|
57
|
+ + componentName);
|
|
58
|
+ return;
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ var version = item.value;
|
|
62
|
+ if (this.versions[componentName] !== version) {
|
|
63
|
+ this.versions[componentName] = version;
|
|
64
|
+ logger.info("Got " + componentName + " version: " + version);
|
|
65
|
+ }
|
|
66
|
+ }.bind(this));
|
|
67
|
+};
|
|
68
|
+
|
|
69
|
+/**
|
|
70
|
+ * Obtains the version of conferencing system component.
|
|
71
|
+ * @param componentName the name of the component for which we want to obtain
|
|
72
|
+ * the version.
|
|
73
|
+ * @returns {String} which describes the version of the component identified by
|
|
74
|
+ * given <tt>componentName</tt> or <tt>undefined</tt> if not found.
|
|
75
|
+ */
|
|
76
|
+ComponentsVersions.prototype.getComponentVersion = function(componentName) {
|
|
77
|
+ return this.versions[componentName];
|
|
78
|
+};
|
|
79
|
+
|
|
80
|
+module.exports = ComponentsVersions;
|
|
81
|
+
|