瀏覽代碼

Clean up ComponentVersions.

master
Boris Grozev 5 年之前
父節點
當前提交
f4fc0ddc9a
共有 1 個檔案被更改,包括 11 行新增46 行删除
  1. 11
    46
      modules/version/ComponentsVersions.js

+ 11
- 46
modules/version/ComponentsVersions.js 查看文件

@@ -2,24 +2,6 @@ import Statistics from '../statistics/statistics';
2 2
 
3 3
 const logger = require('jitsi-meet-logger').getLogger(__filename);
4 4
 
5
-/**
6
- * The constant for the name of the focus component.
7
- * @type {string}
8
- */
9
-ComponentsVersions.FOCUS_COMPONENT = 'focus';
10
-
11
-/**
12
- * The constant for the name of the videobridge component.
13
- * @type {string}
14
- */
15
-ComponentsVersions.VIDEOBRIDGE_COMPONENT = 'videobridge';
16
-
17
-/**
18
- * The constant for the name of the XMPP server component.
19
- * @type {string}
20
- */
21
-ComponentsVersions.XMPP_SERVER_COMPONENT = 'xmpp';
22
-
23 5
 /**
24 6
  * Creates new instance of <tt>ComponentsVersions</tt> which will be discovering
25 7
  * the versions of conferencing system components in given
@@ -34,20 +16,14 @@ export default function ComponentsVersions(conference) {
34 16
 
35 17
     this.conference = conference;
36 18
     this.conference.addCommandListener(
37
-        'versions', this.processPresence.bind(this));
19
+        'versions', this.processVersions.bind(this));
38 20
 }
39 21
 
40
-ComponentsVersions.prototype.processPresence
41
-    = function(node, mucResource, mucJid) {
42
-        if (node.attributes.xmlns !== 'http://jitsi.org/jitmeet') {
43
-            logger.warn('Ignored presence versions node - invalid xmlns', node);
44
-
45
-            return;
46
-        }
47
-
22
+ComponentsVersions.prototype.processVersions
23
+    = function(versions, mucResource, mucJid) {
48 24
         if (!this.conference._isFocus(mucJid)) {
49 25
             logger.warn(
50
-                `Received versions not from the focus user: ${node}`,
26
+                `Received versions not from the focus user: ${versions}`,
51 27
                 mucJid);
52 28
 
53 29
             return;
@@ -55,29 +31,18 @@ ComponentsVersions.prototype.processPresence
55 31
 
56 32
         const log = [];
57 33
 
58
-        node.children.forEach(item => {
59
-
60
-            const componentName = item.attributes.name;
61
-
62
-            if (componentName !== ComponentsVersions.FOCUS_COMPONENT
63
-            && componentName !== ComponentsVersions.XMPP_SERVER_COMPONENT
64
-            && componentName !== ComponentsVersions.VIDEOBRIDGE_COMPONENT) {
65
-                logger.warn(
66
-                    `Received version for not supported component name: ${
67
-                        componentName}`);
68
-
69
-                return;
70
-            }
34
+        versions.children.forEach(component => {
71 35
 
72
-            const version = item.value;
36
+            const name = component.attributes.name;
37
+            const version = component.value;
73 38
 
74
-            if (this.versions[componentName] !== version) {
75
-                this.versions[componentName] = version;
76
-                logger.info(`Got ${componentName} version: ${version}`);
39
+            if (this.versions[name] !== version) {
40
+                this.versions[name] = version;
41
+                logger.info(`Got ${name} version: ${version}`);
77 42
 
78 43
                 log.push({
79 44
                     id: 'component_version',
80
-                    component: componentName,
45
+                    component: name,
81 46
                     version
82 47
                 });
83 48
             }

Loading…
取消
儲存