浏览代码

Captures the versions of conferencing system components.

dev1
paweldomas 9 年前
父节点
当前提交
f4900ec533
共有 3 个文件被更改,包括 100 次插入1 次删除
  1. 2
    0
      JitsiConference.js
  2. 81
    0
      modules/version/ComponentsVersions.js
  3. 17
    1
      modules/xmpp/ChatRoom.js

+ 2
- 0
JitsiConference.js 查看文件

13
 var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');
13
 var JitsiDTMFManager = require('./modules/DTMF/JitsiDTMFManager');
14
 var JitsiTrackEvents = require("./JitsiTrackEvents");
14
 var JitsiTrackEvents = require("./JitsiTrackEvents");
15
 var Settings = require("./modules/settings/Settings");
15
 var Settings = require("./modules/settings/Settings");
16
+var ComponentsVersions = require("./modules/version/ComponentsVersions");
16
 
17
 
17
 /**
18
 /**
18
  * Creates a JitsiConference object with the given name and properties.
19
  * Creates a JitsiConference object with the given name and properties.
37
     this.settings = new Settings();
38
     this.settings = new Settings();
38
     this.room = this.xmpp.createRoom(this.options.name, this.options.config,
39
     this.room = this.xmpp.createRoom(this.options.name, this.options.config,
39
         this.settings);
40
         this.settings);
41
+    this.componentsVersions = new ComponentsVersions(this.room);
40
     this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
42
     this.room.updateDeviceAvailability(RTC.getDeviceAvailability());
41
     this.rtc = new RTC(this.room, options);
43
     this.rtc = new RTC(this.room, options);
42
     this.statistics = new Statistics(this.xmpp, {
44
     this.statistics = new Statistics(this.xmpp, {

+ 81
- 0
modules/version/ComponentsVersions.js 查看文件

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
+

+ 17
- 1
modules/xmpp/ChatRoom.js 查看文件

349
 
349
 
350
 ChatRoom.prototype.processNode = function (node, from) {
350
 ChatRoom.prototype.processNode = function (node, from) {
351
     if(this.presHandlers[node.tagName])
351
     if(this.presHandlers[node.tagName])
352
-        this.presHandlers[node.tagName](node, Strophe.getResourceFromJid(from));
352
+        this.presHandlers[node.tagName](
353
+                node, Strophe.getResourceFromJid(from), from);
353
 };
354
 };
354
 
355
 
355
 ChatRoom.prototype.sendMessage = function (body, nickname) {
356
 ChatRoom.prototype.sendMessage = function (body, nickname) {
545
     delete this.presHandlers[name];
546
     delete this.presHandlers[name];
546
 };
547
 };
547
 
548
 
549
+/**
550
+ * Checks if the user identified by given <tt>mucJid</tt> is the conference
551
+ * focus.
552
+ * @param mucJid the full MUC address of the user to be checked.
553
+ * @returns {boolean} <tt>true</tt> if MUC user is the conference focus.
554
+ */
555
+ChatRoom.prototype.isFocus = function (mucJid) {
556
+    var member = this.members[mucJid];
557
+    if (member) {
558
+        return member.isFocus;
559
+    } else {
560
+        return null;
561
+    }
562
+};
563
+
548
 ChatRoom.prototype.isModerator = function () {
564
 ChatRoom.prototype.isModerator = function () {
549
     return this.role === 'moderator';
565
     return this.role === 'moderator';
550
 };
566
 };

正在加载...
取消
保存