Преглед на файлове

feat: add PARTICIPANT_CONN_STATUS_CHANGED conference event

The event is triggered when the notification about the user's connection
status change arrives from the JVB.
dev1
paweldomas преди 9 години
родител
ревизия
34b05f11f6
променени са 6 файла, в които са добавени 108 реда и са изтрити 0 реда
  1. 5
    0
      JitsiConference.js
  2. 10
    0
      JitsiConferenceEvents.js
  3. 21
    0
      JitsiParticipant.js
  4. 8
    0
      modules/RTC/DataChannels.js
  5. 63
    0
      modules/connectivity/ParticipantConnectionStatus.js
  6. 1
    0
      service/RTC/RTCEvents.js

+ 5
- 0
JitsiConference.js Целия файл

18
 var JitsiConferenceEventManager = require("./JitsiConferenceEventManager");
18
 var JitsiConferenceEventManager = require("./JitsiConferenceEventManager");
19
 var VideoType = require('./service/RTC/VideoType');
19
 var VideoType = require('./service/RTC/VideoType');
20
 var Transcriber = require("./modules/transcription/transcriber");
20
 var Transcriber = require("./modules/transcription/transcriber");
21
+var ParticipantConnectionStatus
22
+    = require("./modules/connectivity/ParticipantConnectionStatus");
21
 
23
 
22
 /**
24
 /**
23
  * Creates a JitsiConference object with the given name and properties.
25
  * Creates a JitsiConference object with the given name and properties.
92
         this.eventManager.setupRTCListeners();
94
         this.eventManager.setupRTCListeners();
93
     }
95
     }
94
 
96
 
97
+    this.participantConnectionStatus
98
+        = new ParticipantConnectionStatus(this.rtc, this);
99
+
95
     if(!this.statistics) {
100
     if(!this.statistics) {
96
         this.statistics = new Statistics(this.xmpp, {
101
         this.statistics = new Statistics(this.xmpp, {
97
             callStatsID: this.options.config.callStatsID,
102
             callStatsID: this.options.config.callStatsID,

+ 10
- 0
JitsiConferenceEvents.js Целия файл

81
  * New text message was received.
81
  * New text message was received.
82
  */
82
  */
83
 export const MESSAGE_RECEIVED = "conference.messageReceived";
83
 export const MESSAGE_RECEIVED = "conference.messageReceived";
84
+/**
85
+ * Event fired when JVB sends notification about interrupted/restored user's
86
+ * ICE connection status. First argument is the ID of the participant and
87
+ * the seconds is a boolean indicating if the connection is currently
88
+ * active(true = active, false = interrupted).
89
+ * The current status value can be obtained by calling
90
+ * JitsiParticipant.isConnectionActive().
91
+ */
92
+export const PARTICIPANT_CONN_STATUS_CHANGED
93
+    = "conference.participant_conn_status_changed";
84
 /**
94
 /**
85
  * Indicates that a the value of a specific property of a specific participant
95
  * Indicates that a the value of a specific property of a specific participant
86
  * has changed.
96
  * has changed.

+ 21
- 0
JitsiParticipant.js Целия файл

30
             video: undefined
30
             video: undefined
31
         };
31
         };
32
         this._hidden = hidden;
32
         this._hidden = hidden;
33
+        this._isConnectionActive = true;
33
         this._properties = {};
34
         this._properties = {};
34
     }
35
     }
35
 
36
 
48
         return this._properties[name];
49
         return this._properties[name];
49
     }
50
     }
50
 
51
 
52
+    /**
53
+     * Updates participant's connection status.
54
+     * @param {boolean} isActive true if the user's connection is fine or false
55
+     * when the user is having connectivity issues.
56
+     * @private
57
+     */
58
+    _setIsConnectionActive(isActive) {
59
+        this._isConnectionActive = isActive;
60
+    }
61
+
62
+    /**
63
+     * Checks participant's connectivity status.
64
+     *
65
+     * @returns {boolean} true if the connection is currently ok or false when
66
+     * the user is having connectivity issues.
67
+     */
68
+    isConnectionActive() {
69
+        return this._isConnectionActive;
70
+    }
71
+
51
     /**
72
     /**
52
      * Sets the value of a property of this participant, and fires an event if
73
      * Sets the value of a property of this participant, and fires an event if
53
      * the value has changed.
74
      * the value has changed.

+ 8
- 0
modules/RTC/DataChannels.js Целия файл

143
                     RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from,
143
                     RTCEvents.ENDPOINT_MESSAGE_RECEIVED, obj.from,
144
                     obj.msgPayload);
144
                     obj.msgPayload);
145
             }
145
             }
146
+            else if ("EndpointConnectivityStatusChangeEvent" === colibriClass) {
147
+                var endpoint = obj.endpoint;
148
+                var isActive = obj.active === "true";
149
+                logger.info("Endpoint connection status changed: " + endpoint
150
+                           + " active ? " + isActive);
151
+                self.eventEmitter.emit(RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
152
+                    endpoint, isActive);
153
+            }
146
             else {
154
             else {
147
                 logger.debug("Data channel JSON-formatted message: ", obj);
155
                 logger.debug("Data channel JSON-formatted message: ", obj);
148
                 // The received message appears to be appropriately formatted
156
                 // The received message appears to be appropriately formatted

+ 63
- 0
modules/connectivity/ParticipantConnectionStatus.js Целия файл

1
+/* global __filename, module, require */
2
+var logger = require("jitsi-meet-logger").getLogger(__filename);
3
+var RTCEvents = require("../../service/RTC/RTCEvents");
4
+import * as JitsiConferenceEvents from "../../JitsiConferenceEvents";
5
+
6
+/**
7
+ * Class is responsible for emitting
8
+ * JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED events.
9
+ *
10
+ * @constructor
11
+ * @param rtc {RTC} the RTC service instance
12
+ * @param conference {JitsiConference} parent conference instance
13
+ */
14
+function ParticipantConnectionStatus(rtc, conference) {
15
+    this.rtc = rtc;
16
+    this.conference = conference;
17
+    rtc.addListener(
18
+        RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
19
+        this.onEndpointConnStatusChanged.bind(this));
20
+}
21
+
22
+/**
23
+ * Handles RTCEvents.ENDPOINT_CONN_STATUS_CHANGED triggered when we receive
24
+ * notification over the data channel from the bridge about endpoint's
25
+ * connection status update.
26
+ * @param endpointId {string} the endpoint ID(MUC nickname/resource JID)
27
+ * @param status {boolean} true if the connection is OK or false otherwise
28
+ */
29
+ParticipantConnectionStatus.prototype.onEndpointConnStatusChanged
30
+= function(endpointId, status) {
31
+    logger.debug(
32
+        'Detector RTCEvents.ENDPOINT_CONN_STATUS_CHANGED(' + Date.now() +'): '
33
+            + endpointId +": " + status);
34
+    // Filter out events for the local JID for now
35
+    if (endpointId !== this.conference.myUserId()) {
36
+        this._changeConnectionStatus(endpointId, status);
37
+    }
38
+};
39
+
40
+ParticipantConnectionStatus.prototype._changeConnectionStatus
41
+= function (endpointId, newStatus) {
42
+    var participant = this.conference.getParticipantById(endpointId);
43
+    if (!participant) {
44
+        // This will happen when participant exits the conference with broken
45
+        // ICE connection and we join after that. The bridge keeps sending
46
+        // that notification until the conference does not expire.
47
+        logger.warn(
48
+            'Missed participant connection status update - ' +
49
+                'no participant for endpoint: ' + endpointId);
50
+        return;
51
+    }
52
+    if (participant.isConnectionActive() !== newStatus) {
53
+        participant._setIsConnectionActive(newStatus);
54
+        logger.debug(
55
+            'Emit endpoint conn status(' + Date.now() + '): ',
56
+            endpointId, newStatus);
57
+        this.conference.eventEmitter.emit(
58
+            JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
59
+            endpointId, newStatus);
60
+    }
61
+};
62
+
63
+module.exports = ParticipantConnectionStatus;

+ 1
- 0
service/RTC/RTCEvents.js Целия файл

1
 var RTCEvents = {
1
 var RTCEvents = {
2
     RTC_READY: "rtc.ready",
2
     RTC_READY: "rtc.ready",
3
     DATA_CHANNEL_OPEN: "rtc.data_channel_open",
3
     DATA_CHANNEL_OPEN: "rtc.data_channel_open",
4
+    ENDPOINT_CONN_STATUS_CHANGED: "rtc.endpoint_conn_status_changed",
4
     LASTN_CHANGED: "rtc.lastn_changed",
5
     LASTN_CHANGED: "rtc.lastn_changed",
5
     DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
6
     DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
6
     LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",
7
     LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",

Loading…
Отказ
Запис