Browse Source

ref(ParticipantConnectionStatus): use ES6 class syntax

master
paweldomas 9 years ago
parent
commit
342bebb8ce
2 changed files with 29 additions and 29 deletions
  1. 2
    2
      JitsiConference.js
  2. 27
    27
      modules/connectivity/ParticipantConnectionStatus.js

+ 2
- 2
JitsiConference.js View File

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
+import ParticipantConnectionStatus
22
+    from "./modules/connectivity/ParticipantConnectionStatus";
23
 import TalkMutedDetection from "./modules/TalkMutedDetection";
23
 import TalkMutedDetection from "./modules/TalkMutedDetection";
24
 
24
 
25
 /**
25
 /**

+ 27
- 27
modules/connectivity/ParticipantConnectionStatus.js View File

19
 /**
19
 /**
20
  * Class is responsible for emitting
20
  * Class is responsible for emitting
21
  * JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED events.
21
  * JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED events.
22
+ */
23
+export default class ParticipantConnectionStatus {
24
+
25
+/**
26
+ * Creates new instance of <tt>ParticipantConnectionStatus</tt>.
22
  *
27
  *
23
  * @constructor
28
  * @constructor
24
  * @param {RTC} rtc the RTC service instance
29
  * @param {RTC} rtc the RTC service instance
26
  * @param {number} rtcMuteTimeout (optional) custom value for
31
  * @param {number} rtcMuteTimeout (optional) custom value for
27
  * {@link ParticipantConnectionStatus.rtcMuteTimeout}.
32
  * {@link ParticipantConnectionStatus.rtcMuteTimeout}.
28
  */
33
  */
29
-function ParticipantConnectionStatus(rtc, conference, rtcMuteTimeout) {
34
+constructor(rtc, conference, rtcMuteTimeout) {
30
     this.rtc = rtc;
35
     this.rtc = rtc;
31
     this.conference = conference;
36
     this.conference = conference;
32
     /**
37
     /**
54
  * Initializes <tt>ParticipantConnectionStatus</tt> and bind required event
59
  * Initializes <tt>ParticipantConnectionStatus</tt> and bind required event
55
  * listeners.
60
  * listeners.
56
  */
61
  */
57
-ParticipantConnectionStatus.prototype.init = function() {
62
+init() {
58
 
63
 
59
     this._onEndpointConnStatusChanged
64
     this._onEndpointConnStatusChanged
60
         = this.onEndpointConnStatusChanged.bind(this);
65
         = this.onEndpointConnStatusChanged.bind(this);
89
         // signalling mute/unmute events.
94
         // signalling mute/unmute events.
90
         this._onSignallingMuteChanged = this.onSignallingMuteChanged.bind(this);
95
         this._onSignallingMuteChanged = this.onSignallingMuteChanged.bind(this);
91
     }
96
     }
92
-};
97
+}
93
 
98
 
94
 /**
99
 /**
95
  * Removes all event listeners and disposes of all resources held by this
100
  * Removes all event listeners and disposes of all resources held by this
96
  * instance.
101
  * instance.
97
  */
102
  */
98
-ParticipantConnectionStatus.prototype.dispose = function () {
103
+dispose() {
99
 
104
 
100
     this.rtc.removeListener(
105
     this.rtc.removeListener(
101
         RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
106
         RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
115
     Object.keys(this.trackTimers).forEach(function (participantId) {
120
     Object.keys(this.trackTimers).forEach(function (participantId) {
116
         this.clearTimeout(participantId);
121
         this.clearTimeout(participantId);
117
     }.bind(this));
122
     }.bind(this));
118
-};
123
+}
119
 
124
 
120
 /**
125
 /**
121
  * Handles RTCEvents.ENDPOINT_CONN_STATUS_CHANGED triggered when we receive
126
  * Handles RTCEvents.ENDPOINT_CONN_STATUS_CHANGED triggered when we receive
124
  * @param endpointId {string} the endpoint ID(MUC nickname/resource JID)
129
  * @param endpointId {string} the endpoint ID(MUC nickname/resource JID)
125
  * @param isActive {boolean} true if the connection is OK or false otherwise
130
  * @param isActive {boolean} true if the connection is OK or false otherwise
126
  */
131
  */
127
-ParticipantConnectionStatus.prototype.onEndpointConnStatusChanged
128
-= function(endpointId, isActive) {
132
+onEndpointConnStatusChanged(endpointId, isActive) {
129
 
133
 
130
     logger.debug(
134
     logger.debug(
131
         'Detector RTCEvents.ENDPOINT_CONN_STATUS_CHANGED('
135
         'Detector RTCEvents.ENDPOINT_CONN_STATUS_CHANGED('
147
             this._changeConnectionStatus(endpointId, isActive);
151
             this._changeConnectionStatus(endpointId, isActive);
148
         }
152
         }
149
     }
153
     }
150
-};
154
+}
151
 
155
 
152
-ParticipantConnectionStatus.prototype._changeConnectionStatus
153
-= function (endpointId, newStatus) {
156
+_changeConnectionStatus(endpointId, newStatus) {
154
     var participant = this.conference.getParticipantById(endpointId);
157
     var participant = this.conference.getParticipantById(endpointId);
155
     if (!participant) {
158
     if (!participant) {
156
         // This will happen when participant exits the conference with broken
159
         // This will happen when participant exits the conference with broken
185
             JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
188
             JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
186
             endpointId, newStatus);
189
             endpointId, newStatus);
187
     }
190
     }
188
-};
191
+}
189
 
192
 
190
 /**
193
 /**
191
  * Reset the postponed "connection interrupted" event which was previously
194
  * Reset the postponed "connection interrupted" event which was previously
194
  * @param participantId the participant for which the "connection interrupted"
197
  * @param participantId the participant for which the "connection interrupted"
195
  * timeout was scheduled
198
  * timeout was scheduled
196
  */
199
  */
197
-ParticipantConnectionStatus.prototype.clearTimeout = function (participantId) {
200
+clearTimeout(participantId) {
198
     if (this.trackTimers[participantId]) {
201
     if (this.trackTimers[participantId]) {
199
         window.clearTimeout(this.trackTimers[participantId]);
202
         window.clearTimeout(this.trackTimers[participantId]);
200
         this.trackTimers[participantId] = null;
203
         this.trackTimers[participantId] = null;
201
     }
204
     }
202
-};
205
+}
203
 
206
 
204
 /**
207
 /**
205
  * Bind signalling mute event listeners for video {JitsiRemoteTrack} when
208
  * Bind signalling mute event listeners for video {JitsiRemoteTrack} when
208
  * @param {JitsiTrack} remoteTrack the {JitsiTrack} which is being added to
211
  * @param {JitsiTrack} remoteTrack the {JitsiTrack} which is being added to
209
  * the conference.
212
  * the conference.
210
  */
213
  */
211
-ParticipantConnectionStatus.prototype.onRemoteTrackAdded
212
-= function(remoteTrack) {
214
+onRemoteTrackAdded(remoteTrack) {
213
     if (!remoteTrack.isLocal() && remoteTrack.getType() === MediaType.VIDEO) {
215
     if (!remoteTrack.isLocal() && remoteTrack.getType() === MediaType.VIDEO) {
214
 
216
 
215
         logger.debug(
217
         logger.debug(
219
             JitsiTrackEvents.TRACK_MUTE_CHANGED,
221
             JitsiTrackEvents.TRACK_MUTE_CHANGED,
220
             this._onSignallingMuteChanged);
222
             this._onSignallingMuteChanged);
221
     }
223
     }
222
-};
224
+}
223
 
225
 
224
 /**
226
 /**
225
  * Removes all event listeners bound to the remote video track and clears any
227
  * Removes all event listeners bound to the remote video track and clears any
228
  * @param {JitsiRemoteTrack} remoteTrack the remote track which is being removed
230
  * @param {JitsiRemoteTrack} remoteTrack the remote track which is being removed
229
  * from the conference.
231
  * from the conference.
230
  */
232
  */
231
-ParticipantConnectionStatus.prototype.onRemoteTrackRemoved
232
-= function(remoteTrack) {
233
+onRemoteTrackRemoved(remoteTrack) {
233
     if (!remoteTrack.isLocal() && remoteTrack.getType() === MediaType.VIDEO) {
234
     if (!remoteTrack.isLocal() && remoteTrack.getType() === MediaType.VIDEO) {
234
         logger.debug(
235
         logger.debug(
235
             'Detector on remote track removed: ',
236
             'Detector on remote track removed: ',
239
             this._onSignallingMuteChanged);
240
             this._onSignallingMuteChanged);
240
         this.clearTimeout(remoteTrack.getParticipantId());
241
         this.clearTimeout(remoteTrack.getParticipantId());
241
     }
242
     }
242
-};
243
+}
243
 
244
 
244
 /**
245
 /**
245
  * Handles RTC 'onmute' event for the video track.
246
  * Handles RTC 'onmute' event for the video track.
247
  * @param {JitsiRemoteTrack} track the video track for which 'onmute' event will
248
  * @param {JitsiRemoteTrack} track the video track for which 'onmute' event will
248
  * be processed.
249
  * be processed.
249
  */
250
  */
250
-ParticipantConnectionStatus.prototype.onTrackRtcMuted = function(track) {
251
+onTrackRtcMuted(track) {
251
     var participantId = track.getParticipantId();
252
     var participantId = track.getParticipantId();
252
     var participant = this.conference.getParticipantById(participantId);
253
     var participant = this.conference.getParticipantById(participantId);
253
     logger.debug('Detector track RTC muted: ', participantId);
254
     logger.debug('Detector track RTC muted: ', participantId);
268
             this.clearTimeout(participantId);
269
             this.clearTimeout(participantId);
269
         }.bind(this), this.rtcMuteTimeout);
270
         }.bind(this), this.rtcMuteTimeout);
270
     }
271
     }
271
-};
272
+}
272
 
273
 
273
 /**
274
 /**
274
  * Handles RTC 'onunmute' event for the video track.
275
  * Handles RTC 'onunmute' event for the video track.
276
  * @param {JitsiRemoteTrack} track the video track for which 'onunmute' event
277
  * @param {JitsiRemoteTrack} track the video track for which 'onunmute' event
277
  * will be processed.
278
  * will be processed.
278
  */
279
  */
279
-ParticipantConnectionStatus.prototype.onTrackRtcUnmuted = function(track) {
280
+onTrackRtcUnmuted(track) {
280
     logger.debug('Detector track RTC unmuted: ', track);
281
     logger.debug('Detector track RTC unmuted: ', track);
281
     var participantId = track.getParticipantId();
282
     var participantId = track.getParticipantId();
282
     if (!track.isMuted() &&
283
     if (!track.isMuted() &&
288
         this._changeConnectionStatus(participantId, true);
289
         this._changeConnectionStatus(participantId, true);
289
     }
290
     }
290
     this.clearTimeout(participantId);
291
     this.clearTimeout(participantId);
291
-};
292
+}
292
 
293
 
293
 /**
294
 /**
294
  * Here the signalling "mute"/"unmute" events are processed.
295
  * Here the signalling "mute"/"unmute" events are processed.
296
  * @param {JitsiRemoteTrack} track the remote video track for which
297
  * @param {JitsiRemoteTrack} track the remote video track for which
297
  * the signalling mute/unmute event will be processed.
298
  * the signalling mute/unmute event will be processed.
298
  */
299
  */
299
-ParticipantConnectionStatus.prototype.onSignallingMuteChanged
300
-= function (track) {
300
+onSignallingMuteChanged (track) {
301
     logger.debug(
301
     logger.debug(
302
         'Detector on track signalling mute changed: ', track, track.isMuted());
302
         'Detector on track signalling mute changed: ', track, track.isMuted());
303
     var isMuted = track.isMuted();
303
     var isMuted = track.isMuted();
313
             'Signalling got in sync - cancelling task for: ' + participantId);
313
             'Signalling got in sync - cancelling task for: ' + participantId);
314
         this.clearTimeout(participantId);
314
         this.clearTimeout(participantId);
315
     }
315
     }
316
-};
316
+}
317
 
317
 
318
-module.exports = ParticipantConnectionStatus;
318
+}

Loading…
Cancel
Save