소스 검색

Adds a set of properties to JitsiParticipant, which can be updated

via presence (via special items with a tag name beginning with
"jitsi_participant_). An events is fired when the value of a property changes.
dev1
Boris Grozev 9 년 전
부모
커밋
985f79da37
4개의 변경된 파일67개의 추가작업 그리고 2개의 파일을 삭제
  1. 17
    0
      JitsiConference.js
  2. 6
    1
      JitsiConferenceEvents.js
  3. 29
    0
      JitsiParticipant.js
  4. 15
    1
      modules/xmpp/ChatRoom.js

+ 17
- 0
JitsiConference.js 파일 보기

893
     return this.room.connectionTimes;
893
     return this.room.connectionTimes;
894
 };
894
 };
895
 
895
 
896
+/**
897
+ * Sets a property for the local participant.
898
+ */
899
+JitsiConference.prototype.setLocalParticipantProperty = function(name, value) {
900
+    this.sendCommand("jitsi_participant_" + name, {value: value});
901
+};
902
+
896
 /**
903
 /**
897
  * Sends the given feedback through CallStats if enabled.
904
  * Sends the given feedback through CallStats if enabled.
898
  *
905
  *
1056
     conference.room.addListener(XMPPEvents.FOCUS_LEFT, function () {
1063
     conference.room.addListener(XMPPEvents.FOCUS_LEFT, function () {
1057
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.FOCUS_LEFT);
1064
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.FOCUS_LEFT);
1058
     });
1065
     });
1066
+    conference.room.setParticipantPropertyListener(function (node, from) {
1067
+        var participant = conference.getParticipantById(from);
1068
+        if (!participant) {
1069
+            return;
1070
+        }
1071
+
1072
+        participant.setProperty(
1073
+            node.tagName.substring("jitsi_participant_".length),
1074
+            node.value);
1075
+    });
1059
 //    FIXME
1076
 //    FIXME
1060
 //    conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
1077
 //    conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
1061
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
1078
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);

+ 6
- 1
JitsiConferenceEvents.js 파일 보기

130
     /**
130
     /**
131
      * Indicates that authentication status changed.
131
      * Indicates that authentication status changed.
132
      */
132
      */
133
-    AUTH_STATUS_CHANGED: "conference.auth_status_changed"
133
+    AUTH_STATUS_CHANGED: "conference.auth_status_changed",
134
+    /**
135
+     * Indicates that a the value of a specific property of a specific
136
+     * participant has changed.
137
+     */
138
+    PARTICIPANT_PROPERTY_CHANGED: "conference.participant_property_changed"
134
 };
139
 };
135
 
140
 
136
 module.exports = JitsiConferenceEvents;
141
 module.exports = JitsiConferenceEvents;

+ 29
- 0
JitsiParticipant.js 파일 보기

1
 /* global Strophe */
1
 /* global Strophe */
2
+var JitsiConferenceEvents = require('./JitsiConferenceEvents');
2
 
3
 
3
 /**
4
 /**
4
  * Represents a participant in (a member of) a conference.
5
  * Represents a participant in (a member of) a conference.
21
         video: undefined
22
         video: undefined
22
     };
23
     };
23
     this._isHidden = isHidden;
24
     this._isHidden = isHidden;
25
+    this._properties = {};
24
 }
26
 }
25
 
27
 
26
 /**
28
 /**
30
     return this._conference;
32
     return this._conference;
31
 };
33
 };
32
 
34
 
35
+/**
36
+ * Gets the value of a property of this participant.
37
+ */
38
+JitsiParticipant.prototype.getProperty = function(name) {
39
+    return this._properties[name];
40
+};
41
+
42
+/**
43
+ * Sets the value of a property of this participant, and fires an event if the
44
+ * value has changed.
45
+ * @name the name of the property.
46
+ * @value the value to set.
47
+ */
48
+JitsiParticipant.prototype.setProperty = function(name, value) {
49
+    var oldValue = this._properties[name];
50
+    this._properties[name] = value;
51
+
52
+    if (value !== oldValue) {
53
+        this._conference.eventEmitter.emit(
54
+            JitsiConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
55
+            this,
56
+            name,
57
+            oldValue,
58
+            value);
59
+    }
60
+};
61
+
33
 /**
62
 /**
34
  * @returns {Array.<JitsiTrack>} The list of media tracks for this participant.
63
  * @returns {Array.<JitsiTrack>} The list of media tracks for this participant.
35
  */
64
  */

+ 15
- 1
modules/xmpp/ChatRoom.js 파일 보기

87
     this.phoneNumber = null;
87
     this.phoneNumber = null;
88
     this.phonePin = null;
88
     this.phonePin = null;
89
     this.connectionTimes = {};
89
     this.connectionTimes = {};
90
+    this.participantPropertyListener = null;
90
 }
91
 }
91
 
92
 
92
 ChatRoom.prototype.initPresenceMap = function () {
93
 ChatRoom.prototype.initPresenceMap = function () {
370
     }
371
     }
371
 };
372
 };
372
 
373
 
374
+/**
375
+ * Sets the special listener to be used for "command"s whose name starts with
376
+ * "jitsi_participant_".
377
+ */
378
+ChatRoom.prototype.setParticipantPropertyListener = function (listener) {
379
+    this.participantPropertyListener = listener;
380
+};
381
+
373
 ChatRoom.prototype.processNode = function (node, from) {
382
 ChatRoom.prototype.processNode = function (node, from) {
374
     // make sure we catch all errors coming from any handler
383
     // make sure we catch all errors coming from any handler
375
     // otherwise we can remove the presence handler from strophe
384
     // otherwise we can remove the presence handler from strophe
376
     try {
385
     try {
377
         var tagHandler = this.presHandlers[node.tagName];
386
         var tagHandler = this.presHandlers[node.tagName];
378
-        if(tagHandler)
387
+        if (node.tagName.startsWith("jitsi_participant_")) {
388
+            tagHandler = this.participantPropertyListener;
389
+        }
390
+
391
+        if(tagHandler) {
379
             tagHandler(node, Strophe.getResourceFromJid(from), from);
392
             tagHandler(node, Strophe.getResourceFromJid(from), from);
393
+        }
380
     } catch (e) {
394
     } catch (e) {
381
         GlobalOnErrorHandler.callErrorHandler(e);
395
         GlobalOnErrorHandler.callErrorHandler(e);
382
         logger.error('Error processing:' + node.tagName + ' node.', e);
396
         logger.error('Error processing:' + node.tagName + ' node.', e);

Loading…
취소
저장