ソースを参照

[eslint] prefer-arrow-callback

dev1
Lyubo Marinov 8年前
コミット
13bfa61028

+ 1
- 0
.eslintrc.js ファイルの表示

@@ -209,6 +209,7 @@ module.exports = {
209 209
             'always',
210 210
             { 'avoidQuotes': true }
211 211
         ],
212
+        'prefer-arrow-callback': [ 'error', { 'allowNamedFunctions': true } ],
212 213
         'prefer-const': 2,
213 214
         'prefer-reflect': 0,
214 215
         'prefer-rest-params': 2,

+ 30
- 34
JitsiConference.js ファイルの表示

@@ -246,7 +246,7 @@ JitsiConference.prototype.isExternalAuthEnabled = function() {
246 246
  * @returns {Promise}
247 247
  */
248 248
 JitsiConference.prototype.getExternalAuthUrl = function(urlForPopup) {
249
-    return new Promise(function(resolve, reject) {
249
+    return new Promise((resolve, reject) => {
250 250
         if (!this.isExternalAuthEnabled()) {
251 251
             reject();
252 252
             return;
@@ -256,7 +256,7 @@ JitsiConference.prototype.getExternalAuthUrl = function(urlForPopup) {
256 256
         } else {
257 257
             this.room.moderator.getLoginUrl(resolve, reject);
258 258
         }
259
-    }.bind(this));
259
+    });
260 260
 };
261 261
 
262 262
 /**
@@ -590,10 +590,11 @@ JitsiConference.prototype._setupNewTrack = function(newTrack) {
590 590
             && newTrack.videoType !== VideoType.DESKTOP)) {
591 591
         // Report active device to statistics
592 592
         const devices = RTC.getCurrentlyAvailableMediaDevices();
593
-        const device = devices.find(function(d) {
594
-            return d.kind === `${newTrack.getTrack().kind}input`
595
-                && d.label === newTrack.getTrack().label;
596
-        });
593
+        const device
594
+            = devices.find(
595
+                d =>
596
+                    d.kind === `${newTrack.getTrack().kind}input`
597
+                        && d.label === newTrack.getTrack().label);
597 598
         if (device) {
598 599
             Statistics.sendActiveDeviceListEvent(
599 600
                 RTC.getEventDataForActiveDevice(device));
@@ -725,14 +726,12 @@ JitsiConference.prototype.lock = function(password) {
725 726
     }
726 727
 
727 728
     const conference = this;
728
-    return new Promise(function(resolve, reject) {
729
-        conference.room.lockRoom(password || '', function() {
730
-            resolve();
731
-        }, function(err) {
732
-            reject(err);
733
-        }, function() {
734
-            reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED);
735
-        });
729
+    return new Promise((resolve, reject) => {
730
+        conference.room.lockRoom(
731
+            password || '',
732
+            () => resolve(),
733
+            err => reject(err),
734
+            () => reject(JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED));
736 735
     });
737 736
 };
738 737
 
@@ -881,9 +880,9 @@ JitsiConference.prototype.onMemberLeft = function(jid) {
881 880
 
882 881
     const removedTracks = this.rtc.removeRemoteTracks(id);
883 882
 
884
-    removedTracks.forEach(function(track) {
885
-        this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
886
-    }.bind(this));
883
+    removedTracks.forEach(
884
+        track =>
885
+            this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track));
887 886
 
888 887
     // there can be no participant in case the member that left is focus
889 888
     if (participant) {
@@ -942,13 +941,10 @@ JitsiConference.prototype.onRemoteTrackAdded = function(track) {
942 941
     const emitter = this.eventEmitter;
943 942
     track.addEventListener(
944 943
         JitsiTrackEvents.TRACK_MUTE_CHANGED,
945
-        function() {
946
-            emitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
947
-        }
948
-    );
944
+        () => emitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track));
949 945
     track.addEventListener(
950 946
         JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED,
951
-        function(audioLevel) {
947
+        audioLevel => {
952 948
             emitter.emit(
953 949
                 JitsiConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
954 950
                 id,
@@ -1016,10 +1012,11 @@ JitsiConference.prototype.onIncomingCall
1016 1012
         jingleSession.terminate(
1017 1013
             'security-error', 'Only focus can start new sessions',
1018 1014
             null /* success callback => we don't care */,
1019
-            function(error) {
1015
+            error => {
1020 1016
                 logger.warn(
1021
-                    'An error occurred while trying to terminate'
1022
-                        + ' invalid Jingle session', error);
1017
+                    'An error occurred while trying to terminate invalid Jingle'
1018
+                        + ' session',
1019
+                    error);
1023 1020
             });
1024 1021
 
1025 1022
         return;
@@ -1050,7 +1047,7 @@ JitsiConference.prototype.onIncomingCall
1050 1047
 
1051 1048
     this.rtc.initializeDataChannels(jingleSession.peerconnection);
1052 1049
     // Add local Tracks to the ChatRoom
1053
-    this.getLocalTracks().forEach(function(localTrack) {
1050
+    this.getLocalTracks().forEach(localTrack => {
1054 1051
         let ssrcInfo = null;
1055 1052
         /**
1056 1053
          * We don't do this for Firefox because, on Firefox, we keep the
@@ -1102,14 +1099,14 @@ JitsiConference.prototype.onIncomingCall
1102 1099
             GlobalOnErrorHandler.callErrorHandler(e);
1103 1100
             logger.error(e);
1104 1101
         }
1105
-    }.bind(this));
1102
+    });
1106 1103
     // Generate the 'recvonly' SSRC in case there are no video tracks
1107 1104
     if (!this.getLocalTracks(MediaType.VIDEO).length) {
1108 1105
         jingleSession.generateRecvonlySsrc();
1109 1106
     }
1110 1107
 
1111 1108
     jingleSession.acceptOffer(jingleOffer, null,
1112
-        function(error) {
1109
+        error => {
1113 1110
             GlobalOnErrorHandler.callErrorHandler(error);
1114 1111
             logger.error(
1115 1112
                 'Failed to accept incoming Jingle session', error);
@@ -1154,7 +1151,7 @@ JitsiConference.prototype.onCallEnded
1154 1151
     // will learn what their SSRC from the new PeerConnection which will be
1155 1152
     // created on incoming call event.
1156 1153
     const self = this;
1157
-    this.getLocalTracks().forEach(function(localTrack) {
1154
+    this.getLocalTracks().forEach(localTrack => {
1158 1155
         // Reset SSRC as it will no longer be valid
1159 1156
         localTrack._setSSRC(null);
1160 1157
         // Bind the handler to fetch new SSRC, it will un register itself once
@@ -1261,10 +1258,10 @@ JitsiConference.prototype.getRecordingURL = function() {
1261 1258
  */
1262 1259
 JitsiConference.prototype.toggleRecording = function(options) {
1263 1260
     if (this.room) {
1264
-        return this.room.toggleRecording(options, function(status, error) {
1261
+        return this.room.toggleRecording(options, (status, error) => {
1265 1262
             this.eventEmitter.emit(
1266 1263
                 JitsiConferenceEvents.RECORDER_STATE_CHANGED, status, error);
1267
-        }.bind(this));
1264
+        });
1268 1265
     }
1269 1266
     this.eventEmitter.emit(
1270 1267
         JitsiConferenceEvents.RECORDER_STATE_CHANGED, 'error',
@@ -1289,7 +1286,7 @@ JitsiConference.prototype.dial = function(number) {
1289 1286
     if (this.room) {
1290 1287
         return this.room.dial(number);
1291 1288
     }
1292
-    return new Promise(function(resolve, reject) {
1289
+    return new Promise((resolve, reject) => {
1293 1290
         reject(new Error('The conference is not created yet!'));
1294 1291
     });
1295 1292
 };
@@ -1301,7 +1298,7 @@ JitsiConference.prototype.hangup = function() {
1301 1298
     if (this.room) {
1302 1299
         return this.room.hangup();
1303 1300
     }
1304
-    return new Promise(function(resolve, reject) {
1301
+    return new Promise((resolve, reject) => {
1305 1302
         reject(new Error('The conference is not created yet!'));
1306 1303
     });
1307 1304
 };
@@ -1335,7 +1332,6 @@ JitsiConference.prototype.getConnectionState = function() {
1335 1332
         return this.jingleSession.getIceConnectionState();
1336 1333
     }
1337 1334
     return null;
1338
-
1339 1335
 };
1340 1336
 
1341 1337
 /**

+ 40
- 42
JitsiConferenceEventManager.js ファイルの表示

@@ -22,7 +22,7 @@ function JitsiConferenceEventManager(conference) {
22 22
 
23 23
     // Listeners related to the conference only
24 24
     conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
25
-        function(track) {
25
+        track => {
26 26
             if(!track.isLocal() || !conference.statistics) {
27 27
                 return;
28 28
             }
@@ -40,7 +40,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
40 40
     this.chatRoomForwarder = new EventEmitterForwarder(chatRoom,
41 41
         this.conference.eventEmitter);
42 42
 
43
-    chatRoom.addListener(XMPPEvents.ICE_RESTARTING, function() {
43
+    chatRoom.addListener(XMPPEvents.ICE_RESTARTING, () => {
44 44
         // All data channels have to be closed, before ICE restart
45 45
         // otherwise Chrome will not trigger "opened" event for the channel
46 46
         // established with the new bridge
@@ -48,16 +48,15 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
48 48
     });
49 49
 
50 50
     chatRoom.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
51
-        function(value) {
51
+        value => {
52 52
             // set isMutedByFocus when setAudioMute Promise ends
53 53
             conference.rtc.setAudioMute(value).then(
54
-                function() {
54
+                () => {
55 55
                     conference.isMutedByFocus = true;
56 56
                 },
57
-                function() {
57
+                () =>
58 58
                     logger.warn(
59
-                        'Error while audio muting due to focus request');
60
-                });
59
+                        'Error while audio muting due to focus request'));
61 60
         }
62 61
     );
63 62
 
@@ -120,14 +119,14 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
120 119
         JitsiConferenceErrors.GRACEFUL_SHUTDOWN);
121 120
 
122 121
     chatRoom.addListener(XMPPEvents.JINGLE_FATAL_ERROR,
123
-        function(session, error) {
122
+        (session, error) => {
124 123
             conference.eventEmitter.emit(
125 124
                 JitsiConferenceEvents.CONFERENCE_FAILED,
126 125
                 JitsiConferenceErrors.JINGLE_FATAL_ERROR, error);
127 126
         });
128 127
 
129 128
     chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
130
-        function() {
129
+        () => {
131 130
             chatRoom.eventEmitter.emit(
132 131
                 XMPPEvents.CONFERENCE_SETUP_FAILED,
133 132
                 new Error('ICE fail'));
@@ -146,7 +145,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
146 145
         JitsiConferenceErrors.FOCUS_DISCONNECTED);
147 146
 
148 147
     chatRoom.addListener(XMPPEvents.FOCUS_LEFT,
149
-        function() {
148
+        () => {
150 149
             Statistics.analytics.sendEvent('conference.focusLeft');
151 150
             conference.eventEmitter.emit(
152 151
                 JitsiConferenceEvents.CONFERENCE_FAILED,
@@ -184,7 +183,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
184 183
         JitsiConferenceEvents.CONFERENCE_FAILED,
185 184
         JitsiConferenceErrors.SETUP_FAILED);
186 185
 
187
-    chatRoom.setParticipantPropertyListener(function(node, from) {
186
+    chatRoom.setParticipantPropertyListener((node, from) => {
188 187
         const participant = conference.getParticipantById(from);
189 188
         if (!participant) {
190 189
             return;
@@ -198,7 +197,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
198 197
     this.chatRoomForwarder.forward(XMPPEvents.KICKED,
199 198
         JitsiConferenceEvents.KICKED);
200 199
     chatRoom.addListener(XMPPEvents.KICKED,
201
-        function() {
200
+        () => {
202 201
             conference.room = null;
203 202
             conference.leave();
204 203
         });
@@ -218,14 +217,14 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
218 217
     chatRoom.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
219 218
         conference.onDisplayNameChanged.bind(conference));
220 219
 
221
-    chatRoom.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, function(role) {
220
+    chatRoom.addListener(XMPPEvents.LOCAL_ROLE_CHANGED, role => {
222 221
         conference.eventEmitter.emit(JitsiConferenceEvents.USER_ROLE_CHANGED,
223 222
             conference.myUserId(), role);
224 223
 
225 224
         // log all events for the recorder operated by the moderator
226 225
         if (conference.statistics && conference.isModerator()) {
227 226
             conference.on(JitsiConferenceEvents.RECORDER_STATE_CHANGED,
228
-                function(status, error) {
227
+                (status, error) => {
229 228
                     const logObject = {
230 229
                         id: 'recorder_status',
231 230
                         status
@@ -242,7 +241,7 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
242 241
         conference.onUserRoleChanged.bind(conference));
243 242
 
244 243
     chatRoom.addListener(AuthenticationEvents.IDENTITY_UPDATED,
245
-        function(authEnabled, authIdentity) {
244
+        (authEnabled, authIdentity) => {
246 245
             conference.authEnabled = authEnabled;
247 246
             conference.authIdentity = authIdentity;
248 247
             conference.eventEmitter.emit(
@@ -251,14 +250,14 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
251 250
         });
252 251
 
253 252
     chatRoom.addListener(XMPPEvents.MESSAGE_RECEIVED,
254
-        function(jid, displayName, txt, myJid, ts) {
253
+        (jid, displayName, txt, myJid, ts) => {
255 254
             const id = Strophe.getResourceFromJid(jid);
256 255
             conference.eventEmitter.emit(JitsiConferenceEvents.MESSAGE_RECEIVED,
257 256
                 id, txt, ts);
258 257
         });
259 258
 
260 259
     chatRoom.addListener(XMPPEvents.PRESENCE_STATUS,
261
-        function(jid, status) {
260
+        (jid, status) => {
262 261
             const id = Strophe.getResourceFromJid(jid);
263 262
             const participant = conference.getParticipantById(id);
264 263
             if (!participant || participant._status === status) {
@@ -270,17 +269,17 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
270 269
         });
271 270
 
272 271
     conference.room.addListener(XMPPEvents.LOCAL_UFRAG_CHANGED,
273
-        function(ufrag) {
272
+        ufrag => {
274 273
             Statistics.sendLog(
275 274
                 JSON.stringify({id: 'local_ufrag', value: ufrag}));
276 275
         });
277 276
     conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED,
278
-        function(ufrag) {
277
+        ufrag => {
279 278
             Statistics.sendLog(
280 279
                 JSON.stringify({id: 'remote_ufrag', value: ufrag}));
281 280
         });
282 281
 
283
-    chatRoom.addPresenceListener('startmuted', function(data, from) {
282
+    chatRoom.addPresenceListener('startmuted', (data, from) => {
284 283
         let isModerator = false;
285 284
         if (conference.myUserId() === from && conference.isModerator()) {
286 285
             isModerator = true;
@@ -318,24 +317,24 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
318 317
         }
319 318
     });
320 319
 
321
-    chatRoom.addPresenceListener('videomuted', function(values, from) {
320
+    chatRoom.addPresenceListener('videomuted', (values, from) => {
322 321
         conference.rtc.handleRemoteTrackMute(MediaType.VIDEO,
323 322
             values.value == 'true', from);
324 323
     });
325 324
 
326
-    chatRoom.addPresenceListener('audiomuted', function(values, from) {
325
+    chatRoom.addPresenceListener('audiomuted', (values, from) => {
327 326
         conference.rtc.handleRemoteTrackMute(MediaType.AUDIO,
328 327
             values.value == 'true', from);
329 328
     });
330 329
 
331
-    chatRoom.addPresenceListener('videoType', function(data, from) {
330
+    chatRoom.addPresenceListener('videoType', (data, from) => {
332 331
         conference.rtc.handleRemoteTrackVideoTypeChanged(data.value, from);
333 332
     });
334 333
 
335
-    chatRoom.addPresenceListener('devices', function(data, from) {
334
+    chatRoom.addPresenceListener('devices', (data, from) => {
336 335
         let isAudioAvailable = false;
337 336
         let isVideoAvailable = false;
338
-        data.children.forEach(function(config) {
337
+        data.children.forEach(config => {
339 338
             if (config.tagName === 'audio') {
340 339
                 isAudioAvailable = config.value === 'true';
341 340
             }
@@ -378,11 +377,11 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
378 377
     if(conference.statistics) {
379 378
         // FIXME ICE related events should end up in RTCEvents eventually
380 379
         chatRoom.addListener(XMPPEvents.CONNECTION_ICE_FAILED,
381
-            function(pc) {
380
+            pc => {
382 381
                 conference.statistics.sendIceConnectionFailedEvent(pc);
383 382
             });
384 383
         chatRoom.addListener(XMPPEvents.ADD_ICE_CANDIDATE_FAILED,
385
-            function(e, pc) {
384
+            (e, pc) => {
386 385
                 conference.statistics.sendAddIceCandidateFailed(e, pc);
387 386
             });
388 387
     }
@@ -407,7 +406,7 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
407 406
         conference.onRemoteTrackRemoved.bind(conference));
408 407
 
409 408
     rtc.addListener(RTCEvents.DOMINANT_SPEAKER_CHANGED,
410
-        function(id) {
409
+        id => {
411 410
             if(conference.lastDominantSpeaker !== id && conference.room) {
412 411
                 conference.lastDominantSpeaker = id;
413 412
                 conference.eventEmitter.emit(
@@ -419,7 +418,7 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
419 418
             }
420 419
         });
421 420
 
422
-    rtc.addListener(RTCEvents.DATA_CHANNEL_OPEN, function() {
421
+    rtc.addListener(RTCEvents.DATA_CHANNEL_OPEN, () => {
423 422
         const now = window.performance.now();
424 423
         logger.log('(TIME) data channel opened ', now);
425 424
         conference.room.connectionTimes['data.channel.opened'] = now;
@@ -433,13 +432,12 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
433 432
     this.rtcForwarder.forward(RTCEvents.LASTN_ENDPOINT_CHANGED,
434 433
         JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED);
435 434
 
436
-    rtc.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED,
437
-        function(devices) {
438
-            conference.room.updateDeviceAvailability(devices);
439
-        });
435
+    rtc.addListener(
436
+        RTCEvents.AVAILABLE_DEVICES_CHANGED,
437
+        devices => conference.room.updateDeviceAvailability(devices));
440 438
 
441 439
     rtc.addListener(RTCEvents.ENDPOINT_MESSAGE_RECEIVED,
442
-        function(from, payload) {
440
+        (from, payload) => {
443 441
             const participant = conference.getParticipantById(from);
444 442
             if (participant) {
445 443
                 conference.eventEmitter.emit(
@@ -497,13 +495,13 @@ JitsiConferenceEventManager.prototype.setupXMPPListeners = function() {
497 495
         XMPPEvents.CALL_ENDED, conference.onCallEnded.bind(conference));
498 496
 
499 497
     conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
500
-        function(audioMuted, videoMuted) {
498
+        (audioMuted, videoMuted) => {
501 499
             conference.startAudioMuted = audioMuted;
502 500
             conference.startVideoMuted = videoMuted;
503 501
 
504 502
             // mute existing local tracks because this is initial mute from
505 503
             // Jicofo
506
-            conference.getLocalTracks().forEach(function(track) {
504
+            conference.getLocalTracks().forEach(track => {
507 505
                 switch (track.getType()) {
508 506
                 case MediaType.AUDIO:
509 507
                     conference.startAudioMuted && track.mute();
@@ -527,7 +525,7 @@ JitsiConferenceEventManager.prototype.setupStatisticsListeners = function() {
527 525
         return;
528 526
     }
529 527
 
530
-    conference.statistics.addAudioLevelListener(function(ssrc, level) {
528
+    conference.statistics.addAudioLevelListener((ssrc, level) => {
531 529
         const resource = conference.rtc.getResourceBySSRC(ssrc);
532 530
         if (!resource) {
533 531
             return;
@@ -536,18 +534,18 @@ JitsiConferenceEventManager.prototype.setupStatisticsListeners = function() {
536 534
         conference.rtc.setAudioLevel(resource, level);
537 535
     });
538 536
     // Forward the "before stats disposed" event
539
-    conference.statistics.addBeforeDisposedListener(function() {
537
+    conference.statistics.addBeforeDisposedListener(() => {
540 538
         conference.eventEmitter.emit(
541 539
             JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED);
542 540
     });
543
-    conference.statistics.addConnectionStatsListener(function(stats) {
541
+    conference.statistics.addConnectionStatsListener(stats => {
544 542
         const ssrc2resolution = stats.resolution;
545 543
 
546 544
         const id2resolution = {};
547 545
 
548 546
         // preprocess resolutions: group by user id, skip incorrect
549 547
         // resolutions etc.
550
-        Object.keys(ssrc2resolution).forEach(function(ssrc) {
548
+        Object.keys(ssrc2resolution).forEach(ssrc => {
551 549
             const resolution = ssrc2resolution[ssrc];
552 550
 
553 551
             if (!resolution.width || !resolution.height
@@ -573,8 +571,8 @@ JitsiConferenceEventManager.prototype.setupStatisticsListeners = function() {
573 571
             JitsiConferenceEvents.CONNECTION_STATS, stats);
574 572
     });
575 573
 
576
-    conference.statistics.addByteSentStatsListener(function(stats) {
577
-        conference.getLocalTracks(MediaType.AUDIO).forEach(function(track) {
574
+    conference.statistics.addByteSentStatsListener(stats => {
575
+        conference.getLocalTracks(MediaType.AUDIO).forEach(track => {
578 576
             const ssrc = track.getSSRC();
579 577
             if (!ssrc || !stats.hasOwnProperty(ssrc)) {
580 578
                 return;

+ 2
- 2
JitsiConnection.js ファイルの表示

@@ -18,14 +18,14 @@ function JitsiConnection(appID, token, options) {
18 18
     this.xmpp = new XMPP(options, token);
19 19
 
20 20
     this.addEventListener(JitsiConnectionEvents.CONNECTION_FAILED,
21
-        function(errType, msg) {
21
+        (errType, msg) => {
22 22
             // sends analytics and callstats event
23 23
             Statistics.sendEventToAll(`connection.failed.${errType}`,
24 24
                 {label: msg});
25 25
         });
26 26
 
27 27
     this.addEventListener(JitsiConnectionEvents.CONNECTION_DISCONNECTED,
28
-        function(msg) {
28
+        msg => {
29 29
             // we can see disconnects from normal tab closing of the browser
30 30
             // and then there are no msgs, but we want to log only disconnects
31 31
             // when there is real error

+ 10
- 8
JitsiMediaDevices.js ファイルの表示

@@ -7,13 +7,15 @@ import Statistics from './modules/statistics/statistics';
7 7
 
8 8
 const eventEmitter = new EventEmitter();
9 9
 
10
-RTC.addListener(RTCEvents.DEVICE_LIST_CHANGED,
11
-    function(devices) {
12
-        eventEmitter.emit(JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED, devices);
13
-    });
10
+RTC.addListener(
11
+    RTCEvents.DEVICE_LIST_CHANGED,
12
+    devices =>
13
+        eventEmitter.emit(
14
+            JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED,
15
+            devices));
14 16
 
15 17
 RTC.addListener(RTCEvents.DEVICE_LIST_AVAILABLE,
16
-    function(devices) {
18
+    devices => {
17 19
         // log output device
18 20
         logOutputDevice(
19 21
             JitsiMediaDevices.getAudioOutputDevice(),
@@ -26,9 +28,9 @@ RTC.addListener(RTCEvents.DEVICE_LIST_AVAILABLE,
26 28
  * @param devices list of devices
27 29
  */
28 30
 function logOutputDevice(deviceID, devices) {
29
-    const device = devices.find(function(d) {
30
-        return d.kind === 'audiooutput' && d.deviceId === deviceID;
31
-    });
31
+    const device
32
+        = devices.find(
33
+            d => d.kind === 'audiooutput' && d.deviceId === deviceID);
32 34
 
33 35
     if (device) {
34 36
         Statistics.sendActiveDeviceListEvent(

+ 4
- 4
JitsiMeetJS.js ファイルの表示

@@ -214,7 +214,7 @@ const LibJitsiMeet = {
214 214
         let promiseFulfilled = false;
215 215
 
216 216
         if (firePermissionPromptIsShownEvent === true) {
217
-            window.setTimeout(function() {
217
+            window.setTimeout(() => {
218 218
                 if (!promiseFulfilled) {
219 219
                     JitsiMediaDevices.emitEvent(
220 220
                         JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN,
@@ -230,7 +230,7 @@ const LibJitsiMeet = {
230 230
             = window.performance.now();
231 231
 
232 232
         return RTC.obtainAudioAndVideoPermissions(options || {})
233
-            .then(function(tracks) {
233
+            .then(tracks => {
234 234
                 promiseFulfilled = true;
235 235
 
236 236
                 window.connectionTimes['obtainPermissions.end']
@@ -248,7 +248,7 @@ const LibJitsiMeet = {
248 248
                                 track.setAudioLevel.bind(track));
249 249
                             track.addEventListener(
250 250
                                 JitsiTrackEvents.LOCAL_TRACK_STOPPED,
251
-                                function() {
251
+                                () => {
252 252
                                     Statistics.stopLocalStats(mStream);
253 253
                                 });
254 254
                         }
@@ -267,7 +267,7 @@ const LibJitsiMeet = {
267 267
                 }
268 268
 
269 269
                 return tracks;
270
-            }).catch(function(error) {
270
+            }).catch(error => {
271 271
                 promiseFulfilled = true;
272 272
 
273 273
                 if(error.name === JitsiTrackErrors.UNSUPPORTED_RESOLUTION) {

+ 5
- 4
JitsiParticipant.js ファイルの表示

@@ -58,10 +58,11 @@ export default class JitsiParticipant {
58 58
      * {@link JitsiTrack.isWebRTCTrackMuted}.
59 59
      */
60 60
     hasAnyVideoTrackWebRTCMuted() {
61
-        return this.getTracks().some(function(jitsiTrack) {
62
-            return jitsiTrack.getType() === MediaType.VIDEO
63
-                && jitsiTrack.isWebRTCTrackMuted();
64
-        });
61
+        return (
62
+            this.getTracks().some(
63
+                jitsiTrack =>
64
+                    jitsiTrack.getType() === MediaType.VIDEO
65
+                        && jitsiTrack.isWebRTCTrackMuted()));
65 66
     }
66 67
 
67 68
     /**

+ 43
- 52
doc/example/example.js ファイルの表示

@@ -27,22 +27,20 @@ const remoteTracks = {};
27 27
 function onLocalTracks(tracks) {
28 28
     localTracks = tracks;
29 29
     for(let i = 0; i < localTracks.length; i++) {
30
-        localTracks[i].addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
31
-            function(audioLevel) {
32
-                console.log(`Audio Level local: ${audioLevel}`);
33
-            });
34
-        localTracks[i].addEventListener(JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
35
-            function() {
36
-                console.log('local track muted');
37
-            });
38
-        localTracks[i].addEventListener(JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
39
-            function() {
40
-                console.log('local track stoped');
41
-            });
42
-        localTracks[i].addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_OUTPUT_CHANGED,
43
-            function(deviceId) {
44
-                console.log(`track audio output device was changed to ${deviceId}`);
45
-            });
30
+        localTracks[i].addEventListener(
31
+            JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
32
+            audioLevel => console.log(`Audio Level local: ${audioLevel}`));
33
+        localTracks[i].addEventListener(
34
+            JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
35
+            () => console.log('local track muted'));
36
+        localTracks[i].addEventListener(
37
+            JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
38
+            () => console.log('local track stoped'));
39
+        localTracks[i].addEventListener(
40
+            JitsiMeetJS.events.track.TRACK_AUDIO_OUTPUT_CHANGED,
41
+            deviceId =>
42
+                console.log(
43
+                    `track audio output device was changed to ${deviceId}`));
46 44
         if(localTracks[i].getType() == 'video') {
47 45
             $('body').append(`<video autoplay='1' id='localVideo${i}' />`);
48 46
             localTracks[i].attach($(`#localVideo${i}`)[0]);
@@ -69,22 +67,19 @@ function onRemoteTrack(track) {
69 67
         remoteTracks[participant] = [];
70 68
     }
71 69
     const idx = remoteTracks[participant].push(track);
72
-    track.addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
73
-        function(audioLevel) {
74
-            console.log(`Audio Level remote: ${audioLevel}`);
75
-        });
76
-    track.addEventListener(JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
77
-        function() {
78
-            console.log('remote track muted');
79
-        });
80
-    track.addEventListener(JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
81
-        function() {
82
-            console.log('remote track stoped');
83
-        });
70
+    track.addEventListener(
71
+        JitsiMeetJS.events.track.TRACK_AUDIO_LEVEL_CHANGED,
72
+        audioLevel => console.log(`Audio Level remote: ${audioLevel}`));
73
+    track.addEventListener(
74
+        JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
75
+        () => console.log('remote track muted'));
76
+    track.addEventListener(
77
+        JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
78
+        () => console.log('remote track stoped'));
84 79
     track.addEventListener(JitsiMeetJS.events.track.TRACK_AUDIO_OUTPUT_CHANGED,
85
-        function(deviceId) {
86
-            console.log(`track audio output device was changed to ${deviceId}`);
87
-        });
80
+        deviceId =>
81
+            console.log(
82
+                `track audio output device was changed to ${deviceId}`));
88 83
     const id = participant + track.getType() + idx;
89 84
     if(track.getType() == 'video') {
90 85
         $('body').append(`<video autoplay='1' id='${participant}video${idx}' />`);
@@ -122,30 +117,30 @@ function onUserLeft(id) {
122 117
 function onConnectionSuccess() {
123 118
     room = connection.initJitsiConference('conference', confOptions);
124 119
     room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
125
-    room.on(JitsiMeetJS.events.conference.TRACK_REMOVED, function(track) {
120
+    room.on(JitsiMeetJS.events.conference.TRACK_REMOVED, track => {
126 121
         console.log(`track removed!!!${track}`);
127 122
     });
128 123
     room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
129
-    room.on(JitsiMeetJS.events.conference.USER_JOINED, function(id) {
124
+    room.on(JitsiMeetJS.events.conference.USER_JOINED, id => {
130 125
         console.log('user join'); remoteTracks[id] = [];
131 126
     });
132 127
     room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);
133
-    room.on(JitsiMeetJS.events.conference.TRACK_MUTE_CHANGED, function(track) {
128
+    room.on(JitsiMeetJS.events.conference.TRACK_MUTE_CHANGED, track => {
134 129
         console.log(`${track.getType()} - ${track.isMuted()}`);
135 130
     });
136
-    room.on(JitsiMeetJS.events.conference.DISPLAY_NAME_CHANGED, function(userID, displayName) {
131
+    room.on(JitsiMeetJS.events.conference.DISPLAY_NAME_CHANGED, (userID, displayName) => {
137 132
         console.log(`${userID} - ${displayName}`);
138 133
     });
139 134
     room.on(JitsiMeetJS.events.conference.TRACK_AUDIO_LEVEL_CHANGED,
140
-      function(userID, audioLevel) {
135
+      (userID, audioLevel) => {
141 136
           console.log(`${userID} - ${audioLevel}`);
142 137
       });
143
-    room.on(JitsiMeetJS.events.conference.RECORDER_STATE_CHANGED, function() {
138
+    room.on(JitsiMeetJS.events.conference.RECORDER_STATE_CHANGED, () => {
144 139
         console.log(`${room.isRecordingSupported()} - ${
145 140
              room.getRecordingState()} - ${
146 141
              room.getRecordingURL()}`);
147 142
     });
148
-    room.on(JitsiMeetJS.events.conference.PHONE_NUMBER_CHANGED, function() {
143
+    room.on(JitsiMeetJS.events.conference.PHONE_NUMBER_CHANGED, () => {
149 144
         console.log(
150 145
             `${room.getPhoneNumber()} - ${
151 146
              room.getPhonePin()}`);
@@ -193,19 +188,19 @@ function switchVideo() { // eslint-disable-line no-unused-vars
193 188
         localTracks.pop();
194 189
     }
195 190
     JitsiMeetJS.createLocalTracks({devices: isVideo ? ['video'] : ['desktop']})
196
-        .then(function(tracks) {
191
+        .then(tracks => {
197 192
             localTracks.push(tracks[0]);
198 193
             localTracks[1].addEventListener(JitsiMeetJS.events.track.TRACK_MUTE_CHANGED,
199
-                function() {
194
+                () => {
200 195
                     console.log('local track muted');
201 196
                 });
202 197
             localTracks[1].addEventListener(JitsiMeetJS.events.track.LOCAL_TRACK_STOPPED,
203
-                function() {
198
+                () => {
204 199
                     console.log('local track stoped');
205 200
                 });
206 201
             localTracks[1].attach($('#localVideo1')[0]);
207 202
             room.addTrack(localTracks[1]);
208
-        }).catch(function(error) {
203
+        }).catch(error => {
209 204
             console.log(error);
210 205
         });
211 206
 }
@@ -244,7 +239,7 @@ const initOptions = {
244 239
     // The URL to the Firefox extension for desktop sharing.
245 240
     desktopSharingFirefoxExtensionURL: null
246 241
 };
247
-JitsiMeetJS.init(initOptions).then(function() {
242
+JitsiMeetJS.init(initOptions).then(() => {
248 243
     connection = new JitsiMeetJS.JitsiConnection(null, null, options);
249 244
 
250 245
     connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, onConnectionSuccess);
@@ -255,24 +250,20 @@ JitsiMeetJS.init(initOptions).then(function() {
255 250
 
256 251
     connection.connect();
257 252
     JitsiMeetJS.createLocalTracks({devices: ['audio', 'video']})
258
-        .then(onLocalTracks).catch(function(error) {
253
+        .then(onLocalTracks).catch(error => {
259 254
             throw error;
260 255
         });
261
-}).catch(function(error) {
256
+}).catch(error => {
262 257
     console.log(error);
263 258
 });
264 259
 
265 260
 if (JitsiMeetJS.mediaDevices.isDeviceChangeAvailable('output')) {
266
-    JitsiMeetJS.mediaDevices.enumerateDevices(function(devices) {
267
-        const audioOutputDevices = devices.filter(function(d) {
268
-            return d.kind === 'audiooutput';
269
-        });
261
+    JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
262
+        const audioOutputDevices = devices.filter(d => d.kind === 'audiooutput');
270 263
 
271 264
         if (audioOutputDevices.length > 1) {
272 265
             $('#audioOutputSelect').html(
273
-                audioOutputDevices.map(function(d) {
274
-                    return `<option value="${d.deviceId}">${d.label}</option>`;
275
-                }).join('\n')
266
+                audioOutputDevices.map(d => `<option value="${d.deviceId}">${d.label}</option>`).join('\n')
276 267
             );
277 268
 
278 269
             $('#audioOutputSelectWrapper').show();

+ 2
- 2
modules/RTC/DataChannels.js ファイルの表示

@@ -169,7 +169,7 @@ DataChannels.prototype.onDataChannel = function(event) {
169 169
  * Closes all currently opened data channels.
170 170
  */
171 171
 DataChannels.prototype.closeAllChannels = function() {
172
-    this._dataChannels.forEach(function(dc) {
172
+    this._dataChannels.forEach(dc => {
173 173
         // the DC will be removed from the array on 'onclose' event
174 174
         dc.close();
175 175
     });
@@ -253,7 +253,7 @@ DataChannels.prototype._some = function(callback, thisArg) {
253 253
  * or Error with "No opened data channels found!" message.
254 254
  */
255 255
 DataChannels.prototype.send = function(jsonObject) {
256
-    if(!this._some(function(dataChannel) {
256
+    if(!this._some(dataChannel => {
257 257
         if (dataChannel.readyState == 'open') {
258 258
             dataChannel.send(JSON.stringify(jsonObject));
259 259
             return true;

+ 13
- 22
modules/RTC/JitsiLocalTrack.js ファイルの表示

@@ -33,13 +33,13 @@ function JitsiLocalTrack(stream, track, mediaType, videoType, resolution,
33 33
 
34 34
     JitsiTrack.call(this,
35 35
         null /* RTC */, stream, track,
36
-        function() {
36
+        () => {
37 37
             if(!this.dontFireRemoveEvent) {
38 38
                 this.eventEmitter.emit(
39 39
                     JitsiTrackEvents.LOCAL_TRACK_STOPPED);
40 40
             }
41 41
             this.dontFireRemoveEvent = false;
42
-        }.bind(this) /* inactiveHandler */,
42
+        } /* inactiveHandler */,
43 43
         mediaType, videoType, null /* ssrc */);
44 44
     this.dontFireRemoveEvent = false;
45 45
     this.resolution = resolution;
@@ -106,9 +106,7 @@ function JitsiLocalTrack(stream, track, mediaType, videoType, resolution,
106 106
         // device ID "".
107 107
         if (typeof self.getTrack().readyState === 'undefined'
108 108
             && typeof self._realDeviceId !== 'undefined'
109
-            && !devices.find(function(d) {
110
-                return d.deviceId === self._realDeviceId;
111
-            })) {
109
+            && !devices.find(d => d.deviceId === self._realDeviceId)) {
112 110
             self._trackEnded = true;
113 111
         }
114 112
     };
@@ -257,10 +255,10 @@ function createMuteUnmutePromise(track, mute) {
257 255
     track.inMuteOrUnmuteProgress = true;
258 256
 
259 257
     return track._setMute(mute)
260
-        .then(function() {
258
+        .then(() => {
261 259
             track.inMuteOrUnmuteProgress = false;
262 260
         })
263
-        .catch(function(status) {
261
+        .catch(status => {
264 262
             track.inMuteOrUnmuteProgress = false;
265 263
             throw status;
266 264
         });
@@ -324,11 +322,9 @@ JitsiLocalTrack.prototype._setMute = function(mute) {
324 322
             }
325 323
 
326 324
             promise = RTCUtils.obtainAudioAndVideoPermissions(streamOptions)
327
-                .then(function(streamsInfo) {
325
+                .then(streamsInfo => {
328 326
                     const mediaType = self.getType();
329
-                    const streamInfo = streamsInfo.find(function(info) {
330
-                        return info.mediaType === mediaType;
331
-                    });
327
+                    const streamInfo = streamsInfo.find(info => info.mediaType === mediaType);
332 328
 
333 329
                     if(!streamInfo) {
334 330
                         throw new JitsiTrackError(
@@ -346,9 +342,7 @@ JitsiLocalTrack.prototype._setMute = function(mute) {
346 342
                         }
347 343
                     }
348 344
 
349
-                    self.containers = self.containers.map(function(cont) {
350
-                        return RTCUtils.attachMediaStream(cont, self.stream);
351
-                    });
345
+                    self.containers = self.containers.map(cont => RTCUtils.attachMediaStream(cont, self.stream));
352 346
 
353 347
                     return self._addStreamToConferenceAsUnmute();
354 348
                 });
@@ -356,9 +350,7 @@ JitsiLocalTrack.prototype._setMute = function(mute) {
356 350
     }
357 351
 
358 352
     return promise
359
-        .then(function() {
360
-            return self._sendMuteStatus(mute);
361
-        })
353
+        .then(() => self._sendMuteStatus(mute))
362 354
         .then(function() {
363 355
             self.eventEmitter.emit(JitsiTrackEvents.TRACK_MUTE_CHANGED, this);
364 356
         });
@@ -466,9 +458,8 @@ JitsiLocalTrack.prototype.dispose = function() {
466 458
     }
467 459
 
468 460
     return promise
469
-        .then(function() {
470
-            return JitsiTrack.prototype.dispose.call(self); // super.dispose();
471
-        });
461
+        .then(() => JitsiTrack.prototype.dispose.call(self) // super.dispose();
462
+        );
472 463
 };
473 464
 
474 465
 /**
@@ -561,12 +552,12 @@ JitsiLocalTrack.prototype._setByteSent = function(bytesSent) {
561 552
     const iceConnectionState
562 553
         = this.conference ? this.conference.getConnectionState() : null;
563 554
     if(this._testByteSent && 'connected' === iceConnectionState) {
564
-        setTimeout(function() {
555
+        setTimeout(() => {
565 556
             if(this._bytesSent <= 0) {
566 557
                 // we are not receiving anything from the microphone
567 558
                 this._fireNoDataFromSourceEvent();
568 559
             }
569
-        }.bind(this), 3000);
560
+        }, 3000);
570 561
         this._testByteSent = false;
571 562
     }
572 563
 };

+ 4
- 4
modules/RTC/JitsiRemoteTrack.js ファイルの表示

@@ -61,24 +61,24 @@ JitsiRemoteTrack.prototype._bindMuteHandlers = function() {
61 61
     // 2. It does mix MediaStream('inactive') with MediaStreamTrack events
62 62
     // 3. Allowing to bind more than one event handler requires too much
63 63
     //    refactoring around camera issues detection.
64
-    this.track.addEventListener('mute', function() {
64
+    this.track.addEventListener('mute', () => {
65 65
 
66 66
         logger.debug(
67 67
             `"onmute" event(${Date.now()}): `,
68 68
             this.getParticipantId(), this.getType(), this.getSSRC());
69 69
 
70 70
         this.rtc.eventEmitter.emit(RTCEvents.REMOTE_TRACK_MUTE, this);
71
-    }.bind(this));
71
+    });
72 72
 
73 73
     // Bind 'onunmute'
74
-    this.track.addEventListener('unmute', function() {
74
+    this.track.addEventListener('unmute', () => {
75 75
 
76 76
         logger.debug(
77 77
             `"onunmute" event(${Date.now()}): `,
78 78
             this.getParticipantId(), this.getType(), this.getSSRC());
79 79
 
80 80
         this.rtc.eventEmitter.emit(RTCEvents.REMOTE_TRACK_UNMUTE, this);
81
-    }.bind(this));
81
+    });
82 82
 };
83 83
 
84 84
 /**

+ 5
- 7
modules/RTC/JitsiTrack.js ファイルの表示

@@ -112,7 +112,7 @@ JitsiTrack.prototype._setHandler = function(type, handler) {
112 112
         }
113 113
         addMediaStreamInactiveHandler(this.stream, handler);
114 114
     } else if(trackHandler2Prop.hasOwnProperty(type)) {
115
-        this.stream.getVideoTracks().forEach(function(track) {
115
+        this.stream.getVideoTracks().forEach(track => {
116 116
             track[trackHandler2Prop[type]] = handler;
117 117
         }, this);
118 118
     }
@@ -411,17 +411,15 @@ JitsiTrack.prototype.setAudioOutput = function(audioOutputDeviceId) {
411 411
         return Promise.resolve();
412 412
     }
413 413
 
414
-    return Promise.all(this.containers.map(function(element) {
415
-        return element.setSinkId(audioOutputDeviceId)
416
-            .catch(function(error) {
414
+    return Promise.all(this.containers.map(element => element.setSinkId(audioOutputDeviceId)
415
+            .catch(error => {
417 416
                 logger.warn(
418 417
                     'Failed to change audio output device on element. Default'
419 418
                     + ' or previously set audio output device will be used.',
420 419
                     element, error);
421 420
                 throw error;
422
-            });
423
-    }))
424
-    .then(function() {
421
+            })))
422
+    .then(() => {
425 423
         self.eventEmitter.emit(JitsiTrackEvents.TRACK_AUDIO_OUTPUT_CHANGED,
426 424
             audioOutputDeviceId);
427 425
     });

+ 4
- 6
modules/RTC/RTC.js ファイルの表示

@@ -18,7 +18,7 @@ const logger = getLogger(__filename);
18 18
 function createLocalTracks(tracksInfo, options) {
19 19
     const newTracks = [];
20 20
     let deviceId = null;
21
-    tracksInfo.forEach(function(trackInfo) {
21
+    tracksInfo.forEach(trackInfo => {
22 22
         if (trackInfo.mediaType === MediaType.AUDIO) {
23 23
             deviceId = options.micDeviceId;
24 24
         } else if (trackInfo.videoType === VideoType.CAMERA) {
@@ -93,7 +93,7 @@ export default class RTC extends Listenable {
93 93
      */
94 94
     static obtainAudioAndVideoPermissions(options) {
95 95
         return RTCUtils.obtainAudioAndVideoPermissions(options).then(
96
-            function(tracksInfo) {
96
+            tracksInfo => {
97 97
                 const tracks = createLocalTracks(tracksInfo, options);
98 98
                 return !tracks.some(track =>
99 99
                     !track._isReceivingData()) ? tracks
@@ -366,7 +366,7 @@ export default class RTC extends Listenable {
366 366
      */
367 367
     setAudioMute(value) {
368 368
         const mutePromises = [];
369
-        this.getLocalTracks(MediaType.AUDIO).forEach(function(audioTrack) {
369
+        this.getLocalTracks(MediaType.AUDIO).forEach(audioTrack => {
370 370
             // this is a Promise
371 371
             mutePromises.push(value ? audioTrack.mute() : audioTrack.unmute());
372 372
         });
@@ -665,9 +665,7 @@ export default class RTC extends Listenable {
665 665
      * matches given SSRC or <tt>undefined</tt> if no such track was found.
666 666
      */
667 667
     getRemoteTrackBySSRC(ssrc) {
668
-        return this.getRemoteTracks().find(function(remoteTrack) {
669
-            return ssrc == remoteTrack.getSSRC();
670
-        });
668
+        return this.getRemoteTracks().find(remoteTrack => ssrc == remoteTrack.getSSRC());
671 669
     }
672 670
 
673 671
     /**

+ 43
- 53
modules/RTC/RTCUtils.js ファイルの表示

@@ -71,9 +71,8 @@ function initRawEnumerateDevicesWithCallback() {
71 71
         && navigator.mediaDevices.enumerateDevices
72 72
         ? function(callback) {
73 73
             navigator.mediaDevices.enumerateDevices().then(
74
-                callback, function() {
75
-                    callback([]);
76
-                });
74
+                callback,
75
+                () => callback([]));
77 76
         }
78 77
         // Safari:
79 78
         // "ReferenceError: Can't find variable: MediaStreamTrack"
@@ -81,9 +80,9 @@ function initRawEnumerateDevicesWithCallback() {
81 80
         // until WebRTC is ready.
82 81
         : MediaStreamTrack && MediaStreamTrack.getSources
83 82
         ? function(callback) {
84
-            MediaStreamTrack.getSources(function(sources) {
85
-                callback(sources.map(convertMediaStreamTrackSource));
86
-            });
83
+            MediaStreamTrack.getSources(
84
+                sources =>
85
+                    callback(sources.map(convertMediaStreamTrackSource)));
87 86
         }
88 87
         : undefined;
89 88
 }
@@ -359,7 +358,7 @@ function pollForAvailableMediaDevices() {
359 358
     // do not matter. This fixes situation when we have no devices initially,
360 359
     // and then plug in a new one.
361 360
     if (rawEnumerateDevicesWithCallback) {
362
-        rawEnumerateDevicesWithCallback(function(devices) {
361
+        rawEnumerateDevicesWithCallback(devices => {
363 362
             // We don't fire RTCEvents.DEVICE_LIST_CHANGED for the first time
364 363
             // we call enumerateDevices(). This is the initial step.
365 364
             if (typeof currentlyAvailableMediaDevices === 'undefined') {
@@ -418,7 +417,7 @@ function onReady(options, GUM) {
418 417
     initRawEnumerateDevicesWithCallback();
419 418
 
420 419
     if (rtcUtils.isDeviceListAvailable() && rawEnumerateDevicesWithCallback) {
421
-        rawEnumerateDevicesWithCallback(function(devices) {
420
+        rawEnumerateDevicesWithCallback(devices => {
422 421
             currentlyAvailableMediaDevices = devices.splice(0);
423 422
 
424 423
             eventEmitter.emit(RTCEvents.DEVICE_LIST_AVAILABLE,
@@ -427,10 +426,7 @@ function onReady(options, GUM) {
427 426
             if (isDeviceChangeEventSupported) {
428 427
                 navigator.mediaDevices.addEventListener(
429 428
                     'devicechange',
430
-                    function() {
431
-                        rtcUtils.enumerateDevices(
432
-                            onMediaDevicesListChanged);
433
-                    });
429
+                    () => rtcUtils.enumerateDevices(onMediaDevicesListChanged));
434 430
             } else {
435 431
                 pollForAvailableMediaDevices();
436 432
             }
@@ -461,16 +457,14 @@ const getUserMediaStatus = {
461 457
  */
462 458
 function wrapGetUserMedia(getUserMedia) {
463 459
     return function(constraints, successCallback, errorCallback) {
464
-        getUserMedia(constraints, function(stream) {
460
+        getUserMedia(constraints, stream => {
465 461
             maybeApply(successCallback, [stream]);
466 462
             if (!getUserMediaStatus.initialized) {
467 463
                 getUserMediaStatus.initialized = true;
468
-                getUserMediaStatus.callbacks.forEach(function(callback) {
469
-                    callback();
470
-                });
464
+                getUserMediaStatus.callbacks.forEach(callback => callback());
471 465
                 getUserMediaStatus.callbacks.length = 0;
472 466
             }
473
-        }, function(error) {
467
+        }, error => {
474 468
             maybeApply(errorCallback, [error]);
475 469
         });
476 470
     };
@@ -497,8 +491,8 @@ function afterUserMediaInitialized(callback) {
497 491
 function wrapEnumerateDevices(enumerateDevices) {
498 492
     return function(callback) {
499 493
         // enumerate devices only after initial getUserMedia
500
-        afterUserMediaInitialized(function() {
501
-            enumerateDevices().then(callback, function(err) {
494
+        afterUserMediaInitialized(() => {
495
+            enumerateDevices().then(callback, err => {
502 496
                 logger.error('cannot enumerate devices: ', err);
503 497
                 callback([]);
504 498
             });
@@ -512,9 +506,8 @@ function wrapEnumerateDevices(enumerateDevices) {
512 506
  * @param {Function} callback function to call when received devices list.
513 507
  */
514 508
 function enumerateDevicesThroughMediaStreamTrack(callback) {
515
-    MediaStreamTrack.getSources(function(sources) {
516
-        callback(sources.map(convertMediaStreamTrackSource));
517
-    });
509
+    MediaStreamTrack.getSources(
510
+        sources => callback(sources.map(convertMediaStreamTrackSource)));
518 511
 }
519 512
 
520 513
 /**
@@ -546,13 +539,14 @@ function obtainDevices(options) {
546 539
     const device = options.devices.splice(0, 1);
547 540
     const devices = [];
548 541
     devices.push(device);
549
-    options.deviceGUM[device](function(stream) {
550
-        options.streams = options.streams || {};
551
-        options.streams[device] = stream;
552
-        obtainDevices(options);
553
-    },
554
-        function(error) {
555
-            Object.keys(options.streams).forEach(function(device) {
542
+    options.deviceGUM[device](
543
+        stream => {
544
+            options.streams = options.streams || {};
545
+            options.streams[device] = stream;
546
+            obtainDevices(options);
547
+        },
548
+        error => {
549
+            Object.keys(options.streams).forEach(device => {
556 550
                 rtcUtils.stopMediaStream(options.streams[device]);
557 551
             });
558 552
             logger.error(
@@ -741,7 +735,7 @@ class RTCUtils extends Listenable {
741 735
             logger.info(`Disable NS: ${disableNS}`);
742 736
         }
743 737
 
744
-        return new Promise(function(resolve, reject) {
738
+        return new Promise((resolve, reject) => {
745 739
             if (RTCBrowserType.isFirefox()) {
746 740
                 const FFversion = RTCBrowserType.getFirefoxVersion();
747 741
                 if (FFversion < 40) {
@@ -758,7 +752,7 @@ class RTCUtils extends Listenable {
758 752
                     navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices)
759 753
                 );
760 754
                 this.pc_constraints = {};
761
-                this.attachMediaStream = wrapAttachMediaStream(function(element, stream) {
755
+                this.attachMediaStream = wrapAttachMediaStream((element, stream) => {
762 756
                     //  srcObject is being standardized and FF will eventually
763 757
                     //  support that unprefixed. FF also supports the
764 758
                     //  "element.src = URL.createObjectURL(...)" combo, but that
@@ -804,7 +798,7 @@ class RTCUtils extends Listenable {
804 798
                     this.getUserMedia = getUserMedia;
805 799
                     this.enumerateDevices = enumerateDevicesThroughMediaStreamTrack;
806 800
                 }
807
-                this.attachMediaStream = wrapAttachMediaStream(function(element, stream) {
801
+                this.attachMediaStream = wrapAttachMediaStream((element, stream) => {
808 802
                     defaultSetVideoSrc(element, stream);
809 803
                     return element;
810 804
                 });
@@ -923,7 +917,7 @@ class RTCUtils extends Listenable {
923 917
                 onReady(options, this.getUserMediaWithConstraints.bind(this));
924 918
                 resolve();
925 919
             }
926
-        }.bind(this));
920
+        });
927 921
     }
928 922
 
929 923
     /**
@@ -945,13 +939,14 @@ class RTCUtils extends Listenable {
945 939
         logger.info('Get media constraints', constraints);
946 940
 
947 941
         try {
948
-            this.getUserMedia(constraints,
949
-                function(stream) {
942
+            this.getUserMedia(
943
+                constraints,
944
+                stream => {
950 945
                     logger.log('onUserMediaSuccess');
951 946
                     setAvailableDevices(um, stream);
952 947
                     success_callback(stream);
953 948
                 },
954
-                function(error) {
949
+                error => {
955 950
                     setAvailableDevices(um, undefined);
956 951
                     logger.warn('Failed to get access to local media. Error ',
957 952
                         error, constraints);
@@ -987,7 +982,7 @@ class RTCUtils extends Listenable {
987 982
 
988 983
         options = options || {};
989 984
         const dsOptions = options.desktopSharingExtensionExternalInstallation;
990
-        return new Promise(function(resolve, reject) {
985
+        return new Promise((resolve, reject) => {
991 986
             const successCallback = function(stream) {
992 987
                 resolve(handleLocalStream(stream, options.resolution));
993 988
             };
@@ -1044,7 +1039,7 @@ class RTCUtils extends Listenable {
1044 1039
                 if(options.devices.length) {
1045 1040
                     this.getUserMediaWithConstraints(
1046 1041
                         options.devices,
1047
-                        function(stream) {
1042
+                        stream => {
1048 1043
                             const audioDeviceRequested
1049 1044
                                 = options.devices.indexOf('audio') !== -1;
1050 1045
                             const videoDeviceRequested
@@ -1083,7 +1078,7 @@ class RTCUtils extends Listenable {
1083 1078
                                 // set to not ask for permissions)
1084 1079
                                 self.getUserMediaWithConstraints(
1085 1080
                                     devices,
1086
-                                    function() {
1081
+                                    () => {
1087 1082
                                         // we already failed to obtain this
1088 1083
                                         // media, so we are not supposed in any
1089 1084
                                         // way to receive success for this call
@@ -1096,7 +1091,7 @@ class RTCUtils extends Listenable {
1096 1091
                                             devices)
1097 1092
                                         );
1098 1093
                                     },
1099
-                                    function(error) {
1094
+                                    error => {
1100 1095
                                         // rejects with real error for not
1101 1096
                                         // obtaining the media
1102 1097
                                         reject(error);
@@ -1107,10 +1102,10 @@ class RTCUtils extends Listenable {
1107 1102
                             if(hasDesktop) {
1108 1103
                                 screenObtainer.obtainStream(
1109 1104
                                     dsOptions,
1110
-                                    function(desktopStream) {
1105
+                                    desktopStream => {
1111 1106
                                         successCallback({audioVideo: stream,
1112 1107
                                             desktopStream});
1113
-                                    }, function(error) {
1108
+                                    }, error => {
1114 1109
                                         self.stopMediaStream(stream);
1115 1110
 
1116 1111
                                         reject(error);
@@ -1119,21 +1114,16 @@ class RTCUtils extends Listenable {
1119 1114
                                 successCallback({audioVideo: stream});
1120 1115
                             }
1121 1116
                         },
1122
-                        function(error) {
1123
-                            reject(error);
1124
-                        },
1117
+                        error => reject(error),
1125 1118
                         options);
1126 1119
                 } else if (hasDesktop) {
1127 1120
                     screenObtainer.obtainStream(
1128 1121
                         dsOptions,
1129
-                        function(stream) {
1130
-                            successCallback({desktopStream: stream});
1131
-                        }, function(error) {
1132
-                            reject(error);
1133
-                        });
1122
+                        stream => successCallback({desktopStream: stream}),
1123
+                        error => reject(error));
1134 1124
                 }
1135 1125
             }
1136
-        }.bind(this));
1126
+        });
1137 1127
     }
1138 1128
 
1139 1129
     getDeviceAvailability() {
@@ -1212,7 +1202,7 @@ class RTCUtils extends Listenable {
1212 1202
      * @param mediaStream MediaStream object to stop.
1213 1203
      */
1214 1204
     stopMediaStream(mediaStream) {
1215
-        mediaStream.getTracks().forEach(function(track) {
1205
+        mediaStream.getTracks().forEach(track => {
1216 1206
             // stop() not supported with IE
1217 1207
             if (!RTCBrowserType.isTemasysPluginUsed() && track.stop) {
1218 1208
                 track.stop();
@@ -1262,7 +1252,7 @@ class RTCUtils extends Listenable {
1262 1252
         }
1263 1253
 
1264 1254
         return featureDetectionAudioEl.setSinkId(deviceId)
1265
-            .then(function() {
1255
+            .then(() => {
1266 1256
                 audioOutputDeviceId = deviceId;
1267 1257
                 audioOutputChanged = true;
1268 1258
 

+ 12
- 12
modules/RTC/TraceablePeerConnection.js ファイルの表示

@@ -167,12 +167,12 @@ function TraceablePeerConnection(rtc, id, signalingLayer, ice_config,
167 167
     };
168 168
     // XXX: do all non-firefox browsers which we support also support this?
169 169
     if (!RTCBrowserType.isFirefox() && this.maxstats) {
170
-        this.statsinterval = window.setInterval(function() {
171
-            self.peerconnection.getStats(function(stats) {
170
+        this.statsinterval = window.setInterval(() => {
171
+            self.peerconnection.getStats(stats => {
172 172
                 const results = stats.result();
173 173
                 const now = new Date();
174 174
                 for (let i = 0; i < results.length; ++i) {
175
-                    results[i].names().forEach(function(name) {
175
+                    results[i].names().forEach(name => {
176 176
                         const id = `${results[i].id}-${name}`;
177 177
                         if (!self.stats[id]) {
178 178
                             self.stats[id] = {
@@ -281,7 +281,7 @@ TraceablePeerConnection.prototype._remoteTrackAdded = function(stream, track) {
281 281
     let ssrcLines = SDPUtil.find_lines(mediaLines[0], 'a=ssrc:');
282 282
 
283 283
     ssrcLines = ssrcLines.filter(
284
-        function(line) {
284
+        line => {
285 285
             const msid
286 286
                 = RTCBrowserType.isTemasysPluginUsed() ? 'mslabel' : 'msid';
287 287
             return line.indexOf(`${msid}:${streamId}`) !== -1;
@@ -508,7 +508,7 @@ const normalizePlanB = function(desc) {
508 508
 
509 509
     if (typeof session !== 'undefined'
510 510
         && typeof session.media !== 'undefined' && Array.isArray(session.media)) {
511
-        session.media.forEach(function(mLine) {
511
+        session.media.forEach(mLine => {
512 512
 
513 513
             // Chrome appears to be picky about the order in which a=ssrc lines
514 514
             // are listed in an m-line when rtx is enabled (and thus there are
@@ -522,7 +522,7 @@ const normalizePlanB = function(desc) {
522 522
 
523 523
             if (typeof mLine.ssrcGroups !== 'undefined'
524 524
                 && Array.isArray(mLine.ssrcGroups)) {
525
-                mLine.ssrcGroups.forEach(function(group) {
525
+                mLine.ssrcGroups.forEach(group => {
526 526
                     if (typeof group.semantics !== 'undefined'
527 527
                         && group.semantics === 'FID') {
528 528
                         if (typeof group.ssrcs !== 'undefined') {
@@ -594,7 +594,7 @@ const getters = {
594 594
         return desc;
595 595
     }
596 596
 };
597
-Object.keys(getters).forEach(function(prop) {
597
+Object.keys(getters).forEach(prop => {
598 598
     Object.defineProperty(
599 599
         TraceablePeerConnection.prototype,
600 600
         prop, {
@@ -655,11 +655,11 @@ TraceablePeerConnection.prototype.setLocalDescription
655 655
 
656 656
             const self = this;
657 657
             this.peerconnection.setLocalDescription(description,
658
-        function() {
658
+        () => {
659 659
             self.trace('setLocalDescriptionOnSuccess');
660 660
             successCallback();
661 661
         },
662
-        function(err) {
662
+        err => {
663 663
             self.trace('setLocalDescriptionOnFailure', err);
664 664
             self.eventEmitter.emit(
665 665
                 RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
@@ -701,11 +701,11 @@ TraceablePeerConnection.prototype.setRemoteDescription
701 701
 
702 702
             const self = this;
703 703
             this.peerconnection.setRemoteDescription(description,
704
-        function() {
704
+        () => {
705 705
             self.trace('setRemoteDescriptionOnSuccess');
706 706
             successCallback();
707 707
         },
708
-        function(err) {
708
+        err => {
709 709
             self.trace('setRemoteDescriptionOnFailure', err);
710 710
             self.eventEmitter.emit(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
711 711
                 err, self.peerconnection);
@@ -799,7 +799,7 @@ const _fixAnswerRFC4145Setup = function(offer, answer) {
799 799
     if (offer && answer
800 800
             && offer.media && answer.media
801 801
             && offer.media.length == answer.media.length) {
802
-        answer.media.forEach(function(a, i) {
802
+        answer.media.forEach((a, i) => {
803 803
             if (SDPUtil.find_line(
804 804
                     offer.media[i],
805 805
                     'a=setup:actpass',

+ 4
- 4
modules/connectivity/ParticipantConnectionStatus.js ファイルの表示

@@ -155,10 +155,10 @@ export default class ParticipantConnectionStatus {
155 155
                 this._onRemoteTrackRemoved);
156 156
         }
157 157
 
158
-        Object.keys(this.trackTimers).forEach(function(participantId) {
158
+        Object.keys(this.trackTimers).forEach(participantId => {
159 159
             this.clearTimeout(participantId);
160 160
             this.clearRtcMutedTimestamp(participantId);
161
-        }.bind(this));
161
+        });
162 162
 
163 163
         // Clear RTC connection status cache
164 164
         this.connStatusFromJvb = {};
@@ -375,11 +375,11 @@ export default class ParticipantConnectionStatus {
375 375
             // it some time, before the connection interrupted event is
376 376
             // triggered.
377 377
             this.clearTimeout(participantId);
378
-            this.trackTimers[participantId] = window.setTimeout(function() {
378
+            this.trackTimers[participantId] = window.setTimeout(() => {
379 379
                 logger.debug(`RTC mute timeout for: ${participantId}`);
380 380
                 this.clearTimeout(participantId);
381 381
                 this.figureOutConnectionStatus(participantId);
382
-            }.bind(this), this.rtcMuteTimeout);
382
+            }, this.rtcMuteTimeout);
383 383
         }
384 384
     }
385 385
 

+ 13
- 13
modules/statistics/CallStats.js ファイルの表示

@@ -235,7 +235,7 @@ const reportType = {
235 235
     MST_WITH_USERID: 'mstWithUserID'
236 236
 };
237 237
 
238
-CallStats.prototype.pcCallback = _try_catch(function(err, msg) {
238
+CallStats.prototype.pcCallback = _try_catch((err, msg) => {
239 239
     if (callStats && err !== 'success') {
240 240
         logger.error(`Monitoring status: ${err} msg: ${msg}`);
241 241
     }
@@ -300,7 +300,7 @@ CallStats.prototype.associateStreamWithVideoTag
300 300
  * @param type {String} "audio"/"video"
301 301
  * @param {CallStats} cs callstats instance related to the event
302 302
  */
303
-CallStats.sendMuteEvent = _try_catch(function(mute, type, cs) {
303
+CallStats.sendMuteEvent = _try_catch((mute, type, cs) => {
304 304
     let event;
305 305
 
306 306
     if (type === 'video') {
@@ -318,7 +318,7 @@ CallStats.sendMuteEvent = _try_catch(function(mute, type, cs) {
318 318
  * false for not stopping
319 319
  * @param {CallStats} cs callstats instance related to the event
320 320
  */
321
-CallStats.sendScreenSharingEvent = _try_catch(function(start, cs) {
321
+CallStats.sendScreenSharingEvent = _try_catch((start, cs) => {
322 322
     CallStats._reportEvent.call(
323 323
         cs,
324 324
         start ? fabricEvent.screenShareStart : fabricEvent.screenShareStop);
@@ -328,7 +328,7 @@ CallStats.sendScreenSharingEvent = _try_catch(function(start, cs) {
328 328
  * Notifies CallStats that we are the new dominant speaker in the conference.
329 329
  * @param {CallStats} cs callstats instance related to the event
330 330
  */
331
-CallStats.sendDominantSpeakerEvent = _try_catch(function(cs) {
331
+CallStats.sendDominantSpeakerEvent = _try_catch(cs => {
332 332
     CallStats._reportEvent.call(cs, fabricEvent.dominantSpeaker);
333 333
 });
334 334
 
@@ -337,7 +337,7 @@ CallStats.sendDominantSpeakerEvent = _try_catch(function(cs) {
337 337
  * @param {{deviceList: {String:String}}} list of devices with their data
338 338
  * @param {CallStats} cs callstats instance related to the event
339 339
  */
340
-CallStats.sendActiveDeviceListEvent = _try_catch(function(devicesData, cs) {
340
+CallStats.sendActiveDeviceListEvent = _try_catch((devicesData, cs) => {
341 341
     CallStats._reportEvent.call(cs, fabricEvent.activeDeviceList, devicesData);
342 342
 });
343 343
 
@@ -379,7 +379,7 @@ CallStats.prototype.sendTerminateEvent = _try_catch(function() {
379 379
  * @param {RTCPeerConnection} pc connection on which failure occured.
380 380
  * @param {CallStats} cs callstats instance related to the error (optional)
381 381
  */
382
-CallStats.prototype.sendIceConnectionFailedEvent = _try_catch(function(pc, cs) {
382
+CallStats.prototype.sendIceConnectionFailedEvent = _try_catch((pc, cs) => {
383 383
     CallStats._reportError.call(
384 384
         cs, wrtcFuncNames.iceConnectionFailure, null, pc);
385 385
 });
@@ -435,7 +435,7 @@ CallStats._reportError = function(type, e, pc) {
435 435
  * @param {Error} e error to send
436 436
  * @param {CallStats} cs callstats instance related to the error (optional)
437 437
  */
438
-CallStats.sendGetUserMediaFailed = _try_catch(function(e, cs) {
438
+CallStats.sendGetUserMediaFailed = _try_catch((e, cs) => {
439 439
     CallStats._reportError.call(cs, wrtcFuncNames.getUserMedia, e, null);
440 440
 });
441 441
 
@@ -446,7 +446,7 @@ CallStats.sendGetUserMediaFailed = _try_catch(function(e, cs) {
446 446
  * @param {RTCPeerConnection} pc connection on which failure occured.
447 447
  * @param {CallStats} cs callstats instance related to the error (optional)
448 448
  */
449
-CallStats.sendCreateOfferFailed = _try_catch(function(e, pc, cs) {
449
+CallStats.sendCreateOfferFailed = _try_catch((e, pc, cs) => {
450 450
     CallStats._reportError.call(cs, wrtcFuncNames.createOffer, e, pc);
451 451
 });
452 452
 
@@ -457,7 +457,7 @@ CallStats.sendCreateOfferFailed = _try_catch(function(e, pc, cs) {
457 457
  * @param {RTCPeerConnection} pc connection on which failure occured.
458 458
  * @param {CallStats} cs callstats instance related to the error (optional)
459 459
  */
460
-CallStats.sendCreateAnswerFailed = _try_catch(function(e, pc, cs) {
460
+CallStats.sendCreateAnswerFailed = _try_catch((e, pc, cs) => {
461 461
     CallStats._reportError.call(cs, wrtcFuncNames.createAnswer, e, pc);
462 462
 });
463 463
 
@@ -468,7 +468,7 @@ CallStats.sendCreateAnswerFailed = _try_catch(function(e, pc, cs) {
468 468
  * @param {RTCPeerConnection} pc connection on which failure occured.
469 469
  * @param {CallStats} cs callstats instance related to the error (optional)
470 470
  */
471
-CallStats.sendSetLocalDescFailed = _try_catch(function(e, pc, cs) {
471
+CallStats.sendSetLocalDescFailed = _try_catch((e, pc, cs) => {
472 472
     CallStats._reportError.call(cs, wrtcFuncNames.setLocalDescription, e, pc);
473 473
 });
474 474
 
@@ -479,7 +479,7 @@ CallStats.sendSetLocalDescFailed = _try_catch(function(e, pc, cs) {
479 479
  * @param {RTCPeerConnection} pc connection on which failure occured.
480 480
  * @param {CallStats} cs callstats instance related to the error (optional)
481 481
  */
482
-CallStats.sendSetRemoteDescFailed = _try_catch(function(e, pc, cs) {
482
+CallStats.sendSetRemoteDescFailed = _try_catch((e, pc, cs) => {
483 483
     CallStats._reportError.call(cs, wrtcFuncNames.setRemoteDescription, e, pc);
484 484
 });
485 485
 
@@ -490,7 +490,7 @@ CallStats.sendSetRemoteDescFailed = _try_catch(function(e, pc, cs) {
490 490
  * @param {RTCPeerConnection} pc connection on which failure occured.
491 491
  * @param {CallStats} cs callstats instance related to the error (optional)
492 492
  */
493
-CallStats.sendAddIceCandidateFailed = _try_catch(function(e, pc, cs) {
493
+CallStats.sendAddIceCandidateFailed = _try_catch((e, pc, cs) => {
494 494
     CallStats._reportError.call(cs, wrtcFuncNames.addIceCandidate, e, pc);
495 495
 });
496 496
 
@@ -500,7 +500,7 @@ CallStats.sendAddIceCandidateFailed = _try_catch(function(e, pc, cs) {
500 500
  * @param {Error} e error to send or {String} message
501 501
  * @param {CallStats} cs callstats instance related to the error (optional)
502 502
  */
503
-CallStats.sendApplicationLog = _try_catch(function(e, cs) {
503
+CallStats.sendApplicationLog = _try_catch((e, cs) => {
504 504
     CallStats._reportError.call(cs, wrtcFuncNames.applicationLog, e, null);
505 505
 });
506 506
 

+ 1
- 1
modules/statistics/LocalStatsCollector.js ファイルの表示

@@ -111,7 +111,7 @@ LocalStatsCollector.prototype.start = function() {
111 111
     const self = this;
112 112
 
113 113
     this.intervalId = setInterval(
114
-        function() {
114
+        () => {
115 115
             const array = new Uint8Array(analyser.frequencyBinCount);
116 116
             analyser.getByteTimeDomainData(array);
117 117
             const audioLevel = timeDomainDataToAudioLevel(array);

+ 5
- 5
modules/statistics/RTPStatsCollector.js ファイルの表示

@@ -244,10 +244,10 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
244 244
     const self = this;
245 245
     if(startAudioLevelStats) {
246 246
         this.audioLevelsIntervalId = setInterval(
247
-            function() {
247
+            () => {
248 248
                 // Interval updates
249 249
                 self.peerconnection.getStats(
250
-                    function(report) {
250
+                    report => {
251 251
                         let results = null;
252 252
                         if (!report || !report.result
253 253
                             || typeof report.result != 'function') {
@@ -269,10 +269,10 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
269 269
 
270 270
     if (browserSupported) {
271 271
         this.statsIntervalId = setInterval(
272
-            function() {
272
+            () => {
273 273
                 // Interval updates
274 274
                 self.peerconnection.getStats(
275
-                    function(report) {
275
+                    report => {
276 276
                         let results = null;
277 277
                         if (!report || !report.result
278 278
                             || typeof report.result != 'function') {
@@ -345,7 +345,7 @@ StatsCollector.prototype._defineGetStatValueMethod = function(keys) {
345 345
         // Array in which each element is a key-value pair.
346 346
         itemStatByKey = function(item, key) {
347 347
             let value;
348
-            item.values.some(function(pair) {
348
+            item.values.some(pair => {
349 349
                 if (pair.hasOwnProperty(key)) {
350 350
                     value = pair[key];
351 351
                     return true;

+ 10
- 11
modules/statistics/statistics.js ファイルの表示

@@ -302,7 +302,7 @@ Statistics.prototype.sendDominantSpeakerEvent = function() {
302 302
  */
303 303
 Statistics.sendActiveDeviceListEvent = function(devicesData) {
304 304
     if (Statistics.callsStatsInstances.length) {
305
-        Statistics.callsStatsInstances.forEach(function(cs) {
305
+        Statistics.callsStatsInstances.forEach(cs => {
306 306
             CallStats.sendActiveDeviceListEvent(devicesData, cs);
307 307
         });
308 308
     } else {
@@ -337,13 +337,13 @@ Statistics.prototype.associateStreamWithVideoTag
337 337
 Statistics.sendGetUserMediaFailed = function(e) {
338 338
 
339 339
     if (Statistics.callsStatsInstances.length) {
340
-        Statistics.callsStatsInstances.forEach(function(cs) {
341
-            CallStats.sendGetUserMediaFailed(
342
-                e instanceof JitsiTrackError
343
-                    ? formatJitsiTrackErrorForCallStats(e)
344
-                    : e,
345
-                cs);
346
-        });
340
+        Statistics.callsStatsInstances.forEach(
341
+            cs =>
342
+                CallStats.sendGetUserMediaFailed(
343
+                    e instanceof JitsiTrackError
344
+                        ? formatJitsiTrackErrorForCallStats(e)
345
+                        : e,
346
+                    cs));
347 347
     } else {
348 348
         CallStats.sendGetUserMediaFailed(
349 349
             e instanceof JitsiTrackError
@@ -420,9 +420,8 @@ Statistics.prototype.sendAddIceCandidateFailed = function(e, pc) {
420 420
  */
421 421
 Statistics.sendLog = function(m) {
422 422
     if (Statistics.callsStatsInstances.length) {
423
-        Statistics.callsStatsInstances.forEach(function(cs) {
424
-            CallStats.sendApplicationLog(m, cs);
425
-        });
423
+        Statistics.callsStatsInstances.forEach(
424
+            cs => CallStats.sendApplicationLog(m, cs));
426 425
     } else {
427 426
         CallStats.sendApplicationLog(m, null);
428 427
     }

+ 11
- 17
modules/transcription/audioRecorder.js ファイルの表示

@@ -65,9 +65,7 @@ function instantiateTrackRecorder(track) {
65 65
     // Create a new stream which only holds the audio track
66 66
     const originalStream = trackRecorder.track.getOriginalStream();
67 67
     const stream = createEmptyStream();
68
-    originalStream.getAudioTracks().forEach(function(track) {
69
-        stream.addTrack(track);
70
-    });
68
+    originalStream.getAudioTracks().forEach(track => stream.addTrack(track));
71 69
     // Create the MediaRecorder
72 70
     trackRecorder.recorder = new MediaRecorder(stream,
73 71
         {mimeType: audioRecorder.fileType});
@@ -186,7 +184,7 @@ audioRecorder.prototype.removeTrack = function(track) {
186 184
  */
187 185
 audioRecorder.prototype.updateNames = function() {
188 186
     const conference = this.jitsiConference;
189
-    this.recorders.forEach(function(trackRecorder) {
187
+    this.recorders.forEach(trackRecorder => {
190 188
         if(trackRecorder.track.isLocal()) {
191 189
             trackRecorder.name = 'the transcriber';
192 190
         } else {
@@ -211,9 +209,7 @@ audioRecorder.prototype.start = function() {
211 209
     // conference, that track can instantly start recording as well
212 210
     this.isRecording = true;
213 211
     // start all the mediaRecorders
214
-    this.recorders.forEach(function(trackRecorder) {
215
-        startRecorder(trackRecorder);
216
-    });
212
+    this.recorders.forEach(trackRecorder => startRecorder(trackRecorder));
217 213
     // log that recording has started
218 214
     console.log(
219 215
         `Started the recording of the audio. There are currently ${
@@ -236,7 +232,7 @@ audioRecorder.prototype.stop = function() {
236 232
  */
237 233
 audioRecorder.prototype.download = function() {
238 234
     const t = this;
239
-    this.recorders.forEach(function(trackRecorder) {
235
+    this.recorders.forEach(trackRecorder => {
240 236
         const blob = new Blob(trackRecorder.data, {type: t.fileType});
241 237
         const url = URL.createObjectURL(blob);
242 238
         const a = document.createElement('a');
@@ -264,14 +260,13 @@ audioRecorder.prototype.getRecordingResults = function() {
264 260
 
265 261
     const array = [];
266 262
     const t = this;
267
-    this.recorders.forEach(function(recorder) {
268
-        array.push(
269
-            new RecordingResult(
270
-            new Blob(recorder.data, {type: t.fileType}),
271
-            recorder.name,
272
-            recorder.startTime)
273
-        );
274
-    });
263
+    this.recorders.forEach(
264
+          recorder =>
265
+              array.push(
266
+                  new RecordingResult(
267
+                      new Blob(recorder.data, {type: t.fileType}),
268
+                      recorder.name,
269
+                      recorder.startTime)));
275 270
     return array;
276 271
 };
277 272
 
@@ -296,7 +291,6 @@ function createEmptyStream() {
296 291
         return new webkitMediaStream(); // eslint-disable-line new-cap
297 292
     }
298 293
     throw new Error('cannot create a clean mediaStream');
299
-
300 294
 }
301 295
 
302 296
 /**

+ 5
- 7
modules/transcription/transcriber.js ファイルの表示

@@ -79,7 +79,7 @@ transcriber.prototype.stop = function stop(callback) {
79 79
     const t = this;
80 80
 
81 81
     const callBack = blobCallBack.bind(this);
82
-    this.audioRecorder.getRecordingResults().forEach(function(recordingResult) {
82
+    this.audioRecorder.getRecordingResults().forEach(recordingResult => {
83 83
         t.transcriptionService.send(recordingResult, callBack);
84 84
         t.counter++;
85 85
     });
@@ -114,7 +114,7 @@ const blobCallBack = function(answer) {
114 114
         }
115 115
 
116 116
         let array = '[';
117
-        answer.wordArray.forEach(function(wordObject) {
117
+        answer.wordArray.forEach(wordObject => {
118 118
             wordObject.begin += offset;
119 119
             wordObject.end += offset;
120 120
             array += `${wordObject.word},`;
@@ -167,9 +167,7 @@ transcriber.prototype.merge = function() {
167 167
     hasPopulatedArrays(arrays);
168 168
 
169 169
     // populate all the potential Words for a first time
170
-    arrays.forEach(function(array) {
171
-        pushWordToSortedArray(potentialWords, array);
172
-    });
170
+    arrays.forEach(array => pushWordToSortedArray(potentialWords, array));
173 171
 
174 172
     // keep adding words to transcription until all arrays are exhausted
175 173
     let lowestWordArray;
@@ -178,7 +176,7 @@ transcriber.prototype.merge = function() {
178 176
     while(hasPopulatedArrays(arrays)) {
179 177
         // first select the lowest array;
180 178
         lowestWordArray = arrays[0];
181
-        arrays.forEach(function(wordArray) {
179
+        arrays.forEach(wordArray => {
182 180
             if(wordArray[0].begin < lowestWordArray[0].begin) {
183 181
                 lowestWordArray = wordArray;
184 182
             }
@@ -190,7 +188,7 @@ transcriber.prototype.merge = function() {
190 188
         // keep going until a word in another array has a smaller time
191 189
         // or the array is empty
192 190
         while(!foundSmaller && lowestWordArray.length > 0) {
193
-            arrays.forEach(function(wordArray) {
191
+            arrays.forEach(wordArray => {
194 192
                 if(wordArray[0].begin < lowestWordArray[0].begin) {
195 193
                     foundSmaller = true;
196 194
                 }

+ 1
- 1
modules/transcription/transcriptionServices/AbstractTranscriptionService.js ファイルの表示

@@ -18,7 +18,7 @@ const TranscriptionService = function() {
18 18
  */
19 19
 TranscriptionService.prototype.send = function send(recordingResult, callback) {
20 20
     const t = this;
21
-    this.sendRequest(recordingResult.blob, function(response) {
21
+    this.sendRequest(recordingResult.blob, response => {
22 22
         if(!t.verify(response)) {
23 23
             console.log('the retrieved response from the server'
24 24
                    + ' is not valid!');

+ 2
- 7
modules/util/GlobalOnErrorHandler.js ファイルの表示

@@ -19,9 +19,7 @@ const oldOnErrorHandler = window.onerror;
19 19
  * all handlers that were previously added.
20 20
  */
21 21
 function JitsiGlobalErrorHandler(message, source, lineno, colno, error) {
22
-    handlers.forEach(function(handler) {
23
-        handler(message, source, lineno, colno, error);
24
-    });
22
+    handlers.forEach(handler => handler(message, source, lineno, colno, error));
25 23
     if (oldOnErrorHandler) {
26 24
         oldOnErrorHandler(message, source, lineno, colno, error);
27 25
     }
@@ -35,9 +33,7 @@ const oldOnUnhandledRejection = window.onunhandledrejection;
35 33
  * that were previously added. This handler handles rejected Promises.
36 34
  */
37 35
 function JitsiGlobalUnhandledRejection(event) {
38
-    handlers.forEach(function(handler) {
39
-        handler(null, null, null, null, event.reason);
40
-    });
36
+    handlers.forEach(handler => handler(null, null, null, null, event.reason));
41 37
     if(oldOnUnhandledRejection) {
42 38
         oldOnUnhandledRejection(event);
43 39
     }
@@ -47,7 +43,6 @@ function JitsiGlobalUnhandledRejection(event) {
47 43
 window.onerror = JitsiGlobalErrorHandler;
48 44
 window.onunhandledrejection = JitsiGlobalUnhandledRejection;
49 45
 
50
-
51 46
 const GlobalOnErrorHandler = {
52 47
     /**
53 48
      * Adds new error handlers.

+ 2
- 2
modules/version/ComponentsVersions.js ファイルの表示

@@ -49,7 +49,7 @@ ComponentsVersions.prototype.processPresence
49 49
         }
50 50
 
51 51
         const log = [];
52
-        node.children.forEach(function(item) {
52
+        node.children.forEach(item => {
53 53
 
54 54
             const componentName = item.attributes.name;
55 55
             if (componentName !== ComponentsVersions.FOCUS_COMPONENT
@@ -72,7 +72,7 @@ ComponentsVersions.prototype.processPresence
72 72
                     version
73 73
                 });
74 74
             }
75
-        }.bind(this));
75
+        });
76 76
 
77 77
         // logs versions to stats
78 78
         if (log.length > 0) {

+ 28
- 39
modules/xmpp/ChatRoom.js ファイルの表示

@@ -18,7 +18,7 @@ const parser = {
18 18
                 tagName
19 19
             };
20 20
             node.attributes = {};
21
-            $($(this)[0].attributes).each(function(index, attr) {
21
+            $($(this)[0].attributes).each((index, attr) => {
22 22
                 node.attributes[ attr.name ] = attr.value;
23 23
             });
24 24
             const text = Strophe.getText($(this)[0]);
@@ -50,7 +50,8 @@ const parser = {
50 50
 };
51 51
 
52 52
 /**
53
- * Returns array of JS objects from the presence JSON associated with the passed nodeName
53
+ * Returns array of JS objects from the presence JSON associated with the passed
54
+ / nodeName
54 55
  * @param pres the presence JSON
55 56
  * @param nodeName the name of the node (videomuted, audiomuted, etc)
56 57
  */
@@ -126,10 +127,7 @@ export default class ChatRoom extends Listenable {
126 127
 
127 128
     join(password) {
128 129
         this.password = password;
129
-        const self = this;
130
-        this.moderator.allocateConferenceFocus(function() {
131
-            self.sendPresence(true);
132
-        });
130
+        this.moderator.allocateConferenceFocus(() => this.sendPresence(true));
133 131
     }
134 132
 
135 133
     sendPresence(fromJoin) {
@@ -197,14 +195,16 @@ export default class ChatRoom extends Listenable {
197 195
         const getInfo = $iq({type: 'get', to: this.roomjid})
198 196
         .c('query', {xmlns: Strophe.NS.DISCO_INFO});
199 197
 
200
-        this.connection.sendIQ(getInfo, function(result) {
201
-            const locked = $(result).find('>query>feature[var="muc_passwordprotected"]')
202
-            .length === 1;
198
+        this.connection.sendIQ(getInfo, result => {
199
+            const locked
200
+                = $(result).find('>query>feature[var="muc_passwordprotected"]')
201
+                        .length
202
+                    === 1;
203 203
             if (locked != this.locked) {
204 204
                 this.eventEmitter.emit(XMPPEvents.MUC_LOCK_CHANGED, locked);
205 205
                 this.locked = locked;
206 206
             }
207
-        }.bind(this), function(error) {
207
+        }, error => {
208 208
             GlobalOnErrorHandler.callErrorHandler(error);
209 209
             logger.error('Error getting room info: ', error);
210 210
         });
@@ -220,8 +220,7 @@ export default class ChatRoom extends Listenable {
220 220
 
221 221
         const self = this;
222 222
 
223
-        this.connection.sendIQ(getForm, function(form) {
224
-
223
+        this.connection.sendIQ(getForm, form => {
225 224
             if (!$(form).find(
226 225
                     '>query>x[xmlns="jabber:x:data"]'
227 226
                     + '>field[var="muc#roomconfig_whois"]').length) {
@@ -245,7 +244,7 @@ export default class ChatRoom extends Listenable {
245 244
 
246 245
             self.connection.sendIQ(formSubmit);
247 246
 
248
-        }, function(error) {
247
+        }, error => {
249 248
             GlobalOnErrorHandler.callErrorHandler(error);
250 249
             logger.error('Error getting room configuration form: ', error);
251 250
         });
@@ -277,8 +276,8 @@ export default class ChatRoom extends Listenable {
277 276
         parser.packet2JSON(pres, nodes);
278 277
         this.lastPresences[from] = nodes;
279 278
         let jibri = null;
280
-        // process nodes to extract data needed for MUC_JOINED and MUC_MEMBER_JOINED
281
-        // events
279
+        // process nodes to extract data needed for MUC_JOINED and
280
+        // MUC_MEMBER_JOINED events
282 281
         for(let i = 0; i < nodes.length; i++) {
283 282
             const node = nodes[i];
284 283
             switch(node.tagName) {
@@ -623,34 +622,31 @@ export default class ChatRoom extends Listenable {
623 622
 
624 623
         this.connection.sendIQ(
625 624
             kickIQ,
626
-            function(result) {
627
-                logger.log('Kick participant with jid: ', jid, result);
628
-            },
629
-            function(error) {
630
-                logger.log('Kick participant error: ', error);
631
-            });
625
+            result => logger.log('Kick participant with jid: ', jid, result),
626
+            error => logger.log('Kick participant error: ', error));
632 627
     }
633 628
 
634 629
     lockRoom(key, onSuccess, onError, onNotSupported) {
635 630
         // http://xmpp.org/extensions/xep-0045.html#roomconfig
636
-        const ob = this;
637
-        this.connection.sendIQ($iq({to: this.roomjid, type: 'get'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'}),
638
-            function(res) {
631
+        this.connection.sendIQ(
632
+            $iq({to: this.roomjid, type: 'get'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'}),
633
+            res => {
639 634
                 if ($(res).find('>query>x[xmlns="jabber:x:data"]>field[var="muc#roomconfig_roomsecret"]').length) {
640
-                    const formsubmit = $iq({to: ob.roomjid, type: 'set'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
635
+                    const formsubmit
636
+                        = $iq({to: this.roomjid, type: 'set'})
637
+                            .c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
641 638
                     formsubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
642 639
                     formsubmit.c('field', {'var': 'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
643 640
                     formsubmit.c('field', {'var': 'muc#roomconfig_roomsecret'}).c('value').t(key).up().up();
644 641
                     // Fixes a bug in prosody 0.9.+ https://code.google.com/p/lxmppd/issues/detail?id=373
645 642
                     formsubmit.c('field', {'var': 'muc#roomconfig_whois'}).c('value').t('anyone').up().up();
646 643
                     // FIXME: is muc#roomconfig_passwordprotectedroom required?
647
-                    ob.connection.sendIQ(formsubmit,
648
-                        onSuccess,
649
-                        onError);
644
+                    this.connection.sendIQ(formsubmit, onSuccess, onError);
650 645
                 } else {
651 646
                     onNotSupported();
652 647
                 }
653
-            }, onError);
648
+            },
649
+            onError);
654 650
     }
655 651
 
656 652
     addToPresence(key, values) {
@@ -660,9 +656,7 @@ export default class ChatRoom extends Listenable {
660 656
     }
661 657
 
662 658
     removeFromPresence(key) {
663
-        const nodes = this.presMap.nodes.filter(function(node) {
664
-            return key !== node.tagName;
665
-        });
659
+        const nodes = this.presMap.nodes.filter(node => key !== node.tagName);
666 660
         this.presMap.nodes = nodes;
667 661
     }
668 662
 
@@ -688,7 +682,6 @@ export default class ChatRoom extends Listenable {
688 682
             return member.isFocus;
689 683
         }
690 684
         return null;
691
-
692 685
     }
693 686
 
694 687
     isModerator() {
@@ -888,12 +881,8 @@ export default class ChatRoom extends Listenable {
888 881
 
889 882
         this.connection.sendIQ(
890 883
             iqToFocus,
891
-            function(result) {
892
-                logger.log('set mute', result);
893
-            },
894
-            function(error) {
895
-                logger.log('set mute error', error);
896
-            });
884
+            result => logger.log('set mute', result),
885
+            error => logger.log('set mute error', error));
897 886
     }
898 887
 
899 888
     onMute(iq) {

+ 25
- 27
modules/xmpp/JingleSessionPC.js ファイルの表示

@@ -267,9 +267,7 @@ export default class JingleSessionPC extends JingleSession {
267 267
 
268 268
         const localSDP = new SDP(this.peerconnection.localDescription.sdp);
269 269
         for (let mid = 0; mid < localSDP.media.length; mid++) {
270
-            const cands = candidates.filter(function(el) {
271
-                return el.sdpMLineIndex == mid;
272
-            });
270
+            const cands = candidates.filter(el => el.sdpMLineIndex == mid);
273 271
             const mline
274 272
                 = SDPUtil.parse_mline(localSDP.media[mid].split('\r\n')[0]);
275 273
             if (cands.length > 0) {
@@ -315,7 +313,7 @@ export default class JingleSessionPC extends JingleSession {
315 313
         // a lot later. See webrtc issue #2340
316 314
         // logger.log('was this the last candidate', this.lasticecandidate);
317 315
         this.connection.sendIQ(
318
-            cand, null, this.newJingleErrorHandler(cand, function(error) {
316
+            cand, null, this.newJingleErrorHandler(cand, error => {
319 317
                 GlobalOnErrorHandler.callErrorHandler(
320 318
                     new Error(`Jingle error: ${JSON.stringify(error)}`));
321 319
             }), IQ_TIMEOUT);
@@ -640,7 +638,7 @@ export default class JingleSessionPC extends JingleSession {
640 638
      */
641 639
     _parseSsrcInfoFromSourceAdd(sourceAddElem, currentRemoteSdp) {
642 640
         const addSsrcInfo = [];
643
-        $(sourceAddElem).each(function(idx, content) {
641
+        $(sourceAddElem).each((idx, content) => {
644 642
             const name = $(content).attr('name');
645 643
             let lines = '';
646 644
             $(content)
@@ -676,7 +674,7 @@ export default class JingleSessionPC extends JingleSession {
676 674
                     lines += '\r\n';
677 675
                 });
678 676
             });
679
-            currentRemoteSdp.media.forEach(function(media, idx) {
677
+            currentRemoteSdp.media.forEach((media, idx) => {
680 678
                 if (!SDPUtil.find_line(media, `a=mid:${name}`)) {
681 679
                     return;
682 680
                 }
@@ -818,10 +816,10 @@ export default class JingleSessionPC extends JingleSession {
818 816
      */
819 817
     _processRemoteRemoveSource(removeSsrcInfo) {
820 818
         const remoteSdp = new SDP(this.peerconnection.remoteDescription.sdp);
821
-        removeSsrcInfo.forEach(function(lines, idx) {
819
+        removeSsrcInfo.forEach((lines, idx) => {
822 820
             lines = lines.split('\r\n');
823 821
             lines.pop(); // remove empty last element;
824
-            lines.forEach(function(line) {
822
+            lines.forEach(line => {
825 823
                 remoteSdp.media[idx]
826 824
                     = remoteSdp.media[idx].replace(`${line}\r\n`, '');
827 825
             });
@@ -840,7 +838,7 @@ export default class JingleSessionPC extends JingleSession {
840 838
      */
841 839
     _processRemoteAddSource(addSsrcInfo) {
842 840
         const remoteSdp = new SDP(this.peerconnection.remoteDescription.sdp);
843
-        addSsrcInfo.forEach(function(lines, idx) {
841
+        addSsrcInfo.forEach((lines, idx) => {
844 842
             remoteSdp.media[idx] += lines;
845 843
         });
846 844
         remoteSdp.raw = remoteSdp.session + remoteSdp.media.join('');
@@ -1015,7 +1013,7 @@ export default class JingleSessionPC extends JingleSession {
1015 1013
      */
1016 1014
     _parseSsrcInfoFromSourceRemove(sourceRemoveElem, currentRemoteSdp) {
1017 1015
         const removeSsrcInfo = [];
1018
-        $(sourceRemoveElem).each(function(idx, content) {
1016
+        $(sourceRemoveElem).each((idx, content) => {
1019 1017
             const name = $(content).attr('name');
1020 1018
             let lines = '';
1021 1019
             $(content)
@@ -1041,14 +1039,14 @@ export default class JingleSessionPC extends JingleSession {
1041 1039
                 const ssrc = $(this).attr('ssrc');
1042 1040
                 ssrcs.push(ssrc);
1043 1041
             });
1044
-            currentRemoteSdp.media.forEach(function(media, idx) {
1042
+            currentRemoteSdp.media.forEach((media, idx) => {
1045 1043
                 if (!SDPUtil.find_line(media, `a=mid:${name}`)) {
1046 1044
                     return;
1047 1045
                 }
1048 1046
                 if (!removeSsrcInfo[idx]) {
1049 1047
                     removeSsrcInfo[idx] = '';
1050 1048
                 }
1051
-                ssrcs.forEach(function(ssrc) {
1049
+                ssrcs.forEach(ssrc => {
1052 1050
                     const ssrcLines
1053 1051
                         = SDPUtil.find_lines(media, `a=ssrc:${ssrc}`);
1054 1052
                     if (ssrcLines.length) {
@@ -1160,7 +1158,7 @@ export default class JingleSessionPC extends JingleSession {
1160 1158
         }
1161 1159
 
1162 1160
         // Find the right sender (for audio or video)
1163
-        this.peerconnection.peerconnection.getSenders().some(function(s) {
1161
+        this.peerconnection.peerconnection.getSenders().some(s => {
1164 1162
             if (s.track === track) {
1165 1163
                 sender = s;
1166 1164
                 return true;
@@ -1274,7 +1272,7 @@ export default class JingleSessionPC extends JingleSession {
1274 1272
             logger.info('Sending source-remove', remove.tree());
1275 1273
             this.connection.sendIQ(
1276 1274
                 remove, null,
1277
-                this.newJingleErrorHandler(remove, function(error) {
1275
+                this.newJingleErrorHandler(remove, error => {
1278 1276
                     GlobalOnErrorHandler.callErrorHandler(
1279 1277
                         new Error(`Jingle error: ${JSON.stringify(error)}`));
1280 1278
                 }), IQ_TIMEOUT);
@@ -1299,7 +1297,7 @@ export default class JingleSessionPC extends JingleSession {
1299 1297
         if (added && add) {
1300 1298
             logger.info('Sending source-add', add.tree());
1301 1299
             this.connection.sendIQ(
1302
-                add, null, this.newJingleErrorHandler(add, function(error) {
1300
+                add, null, this.newJingleErrorHandler(add, error => {
1303 1301
                     GlobalOnErrorHandler.callErrorHandler(
1304 1302
                         new Error(`Jingle error: ${JSON.stringify(error)}`));
1305 1303
                 }), IQ_TIMEOUT);
@@ -1447,18 +1445,18 @@ export default class JingleSessionPC extends JingleSession {
1447 1445
         let ssrcs = this.modifiedSSRCs.unmute;
1448 1446
         this.modifiedSSRCs.unmute = [];
1449 1447
         if (ssrcs && ssrcs.length) {
1450
-            ssrcs.forEach(function(ssrcObj) {
1448
+            ssrcs.forEach(ssrcObj => {
1451 1449
                 const desc
1452 1450
                     = $(jingle.tree()).find(
1453 1451
                         `>jingle>content[name="${ssrcObj.mtype}"]>description`);
1454 1452
                 if (!desc || !desc.length) {
1455 1453
                     return;
1456 1454
                 }
1457
-                ssrcObj.ssrcs.forEach(function(ssrc) {
1455
+                ssrcObj.ssrcs.forEach(ssrc => {
1458 1456
                     const sourceNode = desc.find(`>source[ssrc="${ssrc}"]`);
1459 1457
                     sourceNode.remove();
1460 1458
                 });
1461
-                ssrcObj.groups.forEach(function(group) {
1459
+                ssrcObj.groups.forEach(group => {
1462 1460
                     const groupNode = desc.find(`>ssrc-group[semantics="${
1463 1461
                          group.semantics}"]:has(source[ssrc="${
1464 1462
                          group.ssrcs[0]}"])`);
@@ -1470,12 +1468,12 @@ export default class JingleSessionPC extends JingleSession {
1470 1468
         ssrcs = this.modifiedSSRCs.addMuted;
1471 1469
         this.modifiedSSRCs.addMuted = [];
1472 1470
         if (ssrcs && ssrcs.length) {
1473
-            ssrcs.forEach(function(ssrcObj) {
1471
+            ssrcs.forEach(ssrcObj => {
1474 1472
                 const desc
1475 1473
                     = JingleSessionPC.createDescriptionNode(
1476 1474
                         jingle, ssrcObj.mtype);
1477 1475
                 const cname = Math.random().toString(36).substring(2);
1478
-                ssrcObj.ssrcs.forEach(function(ssrc) {
1476
+                ssrcObj.ssrcs.forEach(ssrc => {
1479 1477
                     const sourceNode
1480 1478
                         = desc.find(`>source[ssrc="${ssrc}"]`);
1481 1479
                     sourceNode.remove();
@@ -1489,7 +1487,7 @@ export default class JingleSessionPC extends JingleSession {
1489 1487
                         + '</source>';
1490 1488
                     desc.append(sourceXML);
1491 1489
                 });
1492
-                ssrcObj.groups.forEach(function(group) {
1490
+                ssrcObj.groups.forEach(group => {
1493 1491
                     const groupNode
1494 1492
                         = desc.find(
1495 1493
                             `>ssrc-group[semantics="${group.semantics
@@ -1515,15 +1513,15 @@ export default class JingleSessionPC extends JingleSession {
1515 1513
         let ssrcs = this.modifiedSSRCs.mute;
1516 1514
         this.modifiedSSRCs.mute = [];
1517 1515
         if (ssrcs && ssrcs.length) {
1518
-            ssrcs.forEach(function(ssrcObj) {
1519
-                ssrcObj.ssrcs.forEach(function(ssrc) {
1516
+            ssrcs.forEach(ssrcObj => {
1517
+                ssrcObj.ssrcs.forEach(ssrc => {
1520 1518
                     const sourceNode
1521 1519
                         = $(jingle.tree()).find(
1522 1520
                             `>jingle>content[name="${ssrcObj.mtype
1523 1521
                                 }"]>description>source[ssrc="${ssrc}"]`);
1524 1522
                     sourceNode.remove();
1525 1523
                 });
1526
-                ssrcObj.groups.forEach(function(group) {
1524
+                ssrcObj.groups.forEach(group => {
1527 1525
                     const groupNode
1528 1526
                         = $(jingle.tree()).find(
1529 1527
                             `>jingle>content[name="${ssrcObj.mtype
@@ -1538,11 +1536,11 @@ export default class JingleSessionPC extends JingleSession {
1538 1536
         ssrcs = this.modifiedSSRCs.remove;
1539 1537
         this.modifiedSSRCs.remove = [];
1540 1538
         if (ssrcs && ssrcs.length) {
1541
-            ssrcs.forEach(function(ssrcObj) {
1539
+            ssrcs.forEach(ssrcObj => {
1542 1540
                 const desc
1543 1541
                     = JingleSessionPC.createDescriptionNode(
1544 1542
                         jingle, ssrcObj.mtype);
1545
-                ssrcObj.ssrcs.forEach(function(ssrc) {
1543
+                ssrcObj.ssrcs.forEach(ssrc => {
1546 1544
                     const sourceNode
1547 1545
                         = desc.find(`>source[ssrc="${ssrc}"]`);
1548 1546
                     if (!sourceNode || !sourceNode.length) {
@@ -1552,7 +1550,7 @@ export default class JingleSessionPC extends JingleSession {
1552 1550
                                 + `ssrc="${ssrc}"></source>`);
1553 1551
                     }
1554 1552
                 });
1555
-                ssrcObj.groups.forEach(function(group) {
1553
+                ssrcObj.groups.forEach(group => {
1556 1554
                     const groupNode
1557 1555
                         = desc.find(`>ssrc-group[semantics="${
1558 1556
                              group.semantics}"]:has(source[ssrc="${

+ 7
- 7
modules/xmpp/RtxModifier.spec.js ファイルの表示

@@ -66,15 +66,15 @@ function getVideoGroups(parsedSdp, groupSemantics) {
66 66
     .filter(g => g.semantics === groupSemantics);
67 67
 }
68 68
 
69
-describe('RtxModifier', function() {
69
+describe('RtxModifier', () => {
70 70
     beforeEach(function() {
71 71
         this.rtxModifier = new RtxModifier();
72 72
         this.transform = transform;
73 73
         this.SDPUtil = SDPUtil;
74 74
     });
75 75
 
76
-    describe('modifyRtxSsrcs', function() {
77
-        describe('when given an sdp with a single video ssrc', function() {
76
+    describe('modifyRtxSsrcs', () => {
77
+        describe('when given an sdp with a single video ssrc', () => {
78 78
             beforeEach(function() {
79 79
                 this.singleVideoSdp = SampleSdpStrings.plainVideoSdp;
80 80
                 this.primaryVideoSsrc = getPrimaryVideoSsrc(this.singleVideoSdp);
@@ -152,7 +152,7 @@ describe('RtxModifier', function() {
152 152
             });
153 153
         });
154 154
 
155
-        describe('when given an sdp with multiple video ssrcs', function() {
155
+        describe('when given an sdp with multiple video ssrcs', () => {
156 156
             beforeEach(function() {
157 157
                 this.multipleVideoSdp = SampleSdpStrings.simulcastSdp;
158 158
                 this.primaryVideoSsrcs = getPrimaryVideoSsrcs(this.multipleVideoSdp);
@@ -261,7 +261,7 @@ describe('RtxModifier', function() {
261 261
             });
262 262
         });
263 263
 
264
-        describe('(corner cases)', function() {
264
+        describe('(corner cases)', () => {
265 265
             it('should handle a recvonly video mline', function() {
266 266
                 const sdp = SampleSdpStrings.plainVideoSdp;
267 267
                 const videoMLine = sdp.media.find(m => m.type === 'video');
@@ -288,8 +288,8 @@ describe('RtxModifier', function() {
288 288
         });
289 289
     });
290 290
 
291
-    describe('stripRtx', function() {
292
-        beforeEach(function() { }); // eslint-disable-line no-empty-function
291
+    describe('stripRtx', () => {
292
+        beforeEach(() => { }); // eslint-disable-line no-empty-function
293 293
         it('should strip all rtx streams from an sdp with rtx', function() {
294 294
             const sdpStr = transform.write(SampleSdpStrings.rtxVideoSdp);
295 295
             const newSdpStr = this.rtxModifier.stripRtx(sdpStr);

+ 17
- 23
modules/xmpp/SDP.js ファイルの表示

@@ -56,7 +56,7 @@ SDP.prototype.getMediaSsrcMap = function() {
56 56
             ssrcGroups: []
57 57
         };
58 58
         media_ssrcs[mediaindex] = media;
59
-        tmp.forEach(function(line) {
59
+        tmp.forEach(line => {
60 60
             const linessrc = line.substring(7).split(' ')[0];
61 61
             // allocate new ChannelSsrc
62 62
             if(!media.ssrcs[linessrc]) {
@@ -68,7 +68,7 @@ SDP.prototype.getMediaSsrcMap = function() {
68 68
             media.ssrcs[linessrc].lines.push(line);
69 69
         });
70 70
         tmp = SDPUtil.find_lines(self.media[mediaindex], 'a=ssrc-group:');
71
-        tmp.forEach(function(line) {
71
+        tmp.forEach(line => {
72 72
             const idx = line.indexOf(' ');
73 73
             const semantics = line.substr(0, idx).substr(13);
74 74
             const ssrcs = line.substr(14 + semantics.length).split(' ');
@@ -91,7 +91,7 @@ SDP.prototype.containsSSRC = function(ssrc) {
91 91
     // FIXME this code is really strange - improve it if you can
92 92
     const medias = this.getMediaSsrcMap();
93 93
     let result = false;
94
-    Object.keys(medias).forEach(function(mediaindex) {
94
+    Object.keys(medias).forEach(mediaindex => {
95 95
         if (result) {
96 96
             return;
97 97
         }
@@ -133,7 +133,7 @@ SDP.prototype.mangle = function() {
133 133
 SDP.prototype.removeSessionLines = function(prefix) {
134 134
     const self = this;
135 135
     const lines = SDPUtil.find_lines(this.session, prefix);
136
-    lines.forEach(function(line) {
136
+    lines.forEach(line => {
137 137
         self.session = self.session.replace(`${line}\r\n`, '');
138 138
     });
139 139
     this.raw = this.session + this.media.join('');
@@ -144,8 +144,9 @@ SDP.prototype.removeSessionLines = function(prefix) {
144 144
 SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
145 145
     const self = this;
146 146
     const lines = SDPUtil.find_lines(this.media[mediaindex], prefix);
147
-    lines.forEach(function(line) {
148
-        self.media[mediaindex] = self.media[mediaindex].replace(`${line}\r\n`, '');
147
+    lines.forEach(line => {
148
+        self.media[mediaindex]
149
+            = self.media[mediaindex].replace(`${line}\r\n`, '');
149 150
     });
150 151
     this.raw = this.session + this.media.join('');
151 152
     return lines;
@@ -214,9 +215,8 @@ SDP.prototype.toJingle = function(elem, thecreator) {
214 215
             const crypto = SDPUtil.find_lines(this.media[i], 'a=crypto:', this.session);
215 216
             if (crypto.length) {
216 217
                 elem.c('encryption', {required: 1});
217
-                crypto.forEach(function(line) {
218
-                    elem.c('crypto', SDPUtil.parse_crypto(line)).up();
219
-                });
218
+                crypto.forEach(
219
+                    line => elem.c('crypto', SDPUtil.parse_crypto(line)).up());
220 220
                 elem.up(); // end of encryption
221 221
             }
222 222
 
@@ -226,7 +226,7 @@ SDP.prototype.toJingle = function(elem, thecreator) {
226 226
                 // FIXME: group by ssrc and support multiple different ssrcs
227 227
                 const ssrclines = SDPUtil.find_lines(this.media[i], 'a=ssrc:');
228 228
                 if(ssrclines.length > 0) {
229
-                    ssrclines.forEach(function(line) {
229
+                    ssrclines.forEach(line => {
230 230
                         const idx = line.indexOf(' ');
231 231
                         const linessrc = line.substr(0, idx).substr(7);
232 232
                         if (linessrc != ssrc) {
@@ -280,16 +280,13 @@ SDP.prototype.toJingle = function(elem, thecreator) {
280 280
 
281 281
                 // XEP-0339 handle ssrc-group attributes
282 282
                 const ssrc_group_lines = SDPUtil.find_lines(this.media[i], 'a=ssrc-group:');
283
-                ssrc_group_lines.forEach(function(line) {
283
+                ssrc_group_lines.forEach(line => {
284 284
                     const idx = line.indexOf(' ');
285 285
                     const semantics = line.substr(0, idx).substr(13);
286 286
                     const ssrcs = line.substr(14 + semantics.length).split(' ');
287 287
                     if (ssrcs.length) {
288 288
                         elem.c('ssrc-group', { semantics, xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
289
-                        ssrcs.forEach(function(ssrc) {
290
-                            elem.c('source', { ssrc })
291
-                                .up();
292
-                        });
289
+                        ssrcs.forEach(ssrc => elem.c('source', { ssrc }).up());
293 290
                         elem.up();
294 291
                     }
295 292
                 });
@@ -379,7 +376,7 @@ SDP.prototype.transportToJingle = function(mediaindex, elem) {
379 376
     // XEP-0320
380 377
     const fingerprints
381 378
         = SDPUtil.find_lines(this.media[mediaindex], 'a=fingerprint:', this.session);
382
-    fingerprints.forEach(function(line) {
379
+    fingerprints.forEach(line => {
383 380
         tmp = SDPUtil.parse_fingerprint(line);
384 381
         tmp.xmlns = 'urn:xmpp:jingle:apps:dtls:0';
385 382
         elem.c('fingerprint').t(tmp.fingerprint);
@@ -398,7 +395,7 @@ SDP.prototype.transportToJingle = function(mediaindex, elem) {
398 395
         // XEP-0176
399 396
         if (SDPUtil.find_line(this.media[mediaindex], 'a=candidate:', this.session)) { // add any a=candidate lines
400 397
             const lines = SDPUtil.find_lines(this.media[mediaindex], 'a=candidate:', this.session);
401
-            lines.forEach(function(line) {
398
+            lines.forEach(line => {
402 399
                 const candidate = SDPUtil.candidateToJingle(line);
403 400
                 if (self.failICE) {
404 401
                     candidate.ip = '1.1.1.1';
@@ -420,7 +417,7 @@ SDP.prototype.transportToJingle = function(mediaindex, elem) {
420 417
 
421 418
 SDP.prototype.rtcpFbToJingle = function(mediaindex, elem, payloadtype) { // XEP-0293
422 419
     const lines = SDPUtil.find_lines(this.media[mediaindex], `a=rtcp-fb:${payloadtype}`);
423
-    lines.forEach(function(line) {
420
+    lines.forEach(line => {
424 421
         const tmp = SDPUtil.parse_rtcpfb(line);
425 422
         if (tmp.type == 'trr-int') {
426 423
             elem.c('rtcp-fb-trr-int', {xmlns: 'urn:xmpp:jingle:apps:rtp:rtcp-fb:0', value: tmp.params[0]});
@@ -467,10 +464,8 @@ SDP.prototype.fromJingle = function(jingle) {
467 464
         + 't=0 0\r\n';
468 465
     // http://tools.ietf.org/html/draft-ietf-mmusic-sdp-bundle-negotiation-04#section-8
469 466
     if ($(jingle).find('>group[xmlns="urn:xmpp:jingle:apps:grouping:0"]').length) {
470
-        $(jingle).find('>group[xmlns="urn:xmpp:jingle:apps:grouping:0"]').each(function(idx, group) {
471
-            const contents = $(group).find('>content').map(function(idx, content) {
472
-                return content.getAttribute('name');
473
-            }).get();
467
+        $(jingle).find('>group[xmlns="urn:xmpp:jingle:apps:grouping:0"]').each((idx, group) => {
468
+            const contents = $(group).find('>content').map((idx, content) => content.getAttribute('name')).get();
474 469
             if (contents.length > 0) {
475 470
                 self.raw += `a=group:${group.getAttribute('semantics') || group.getAttribute('type')} ${contents.join(' ')}\r\n`;
476 471
             }
@@ -658,5 +653,4 @@ SDP.prototype.jingle2media = function(content) {
658 653
     return media;
659 654
 };
660 655
 
661
-
662 656
 module.exports = SDP;

+ 8
- 8
modules/xmpp/SDPDiffer.js ファイルの表示

@@ -42,7 +42,7 @@ SDPDiffer.prototype.getNewMedia = function() {
42 42
     const myMedias = this.mySDP.getMediaSsrcMap();
43 43
     const othersMedias = this.otherSDP.getMediaSsrcMap();
44 44
     const newMedia = {};
45
-    Object.keys(othersMedias).forEach(function(othersMediaIdx) {
45
+    Object.keys(othersMedias).forEach(othersMediaIdx => {
46 46
         const myMedia = myMedias[othersMediaIdx];
47 47
         const othersMedia = othersMedias[othersMediaIdx];
48 48
         if(!myMedia && othersMedia) {
@@ -51,7 +51,7 @@ SDPDiffer.prototype.getNewMedia = function() {
51 51
             return;
52 52
         }
53 53
         // Look for new ssrcs across the channel
54
-        Object.keys(othersMedia.ssrcs).forEach(function(ssrc) {
54
+        Object.keys(othersMedia.ssrcs).forEach(ssrc => {
55 55
             if(Object.keys(myMedia.ssrcs).indexOf(ssrc) === -1) {
56 56
                 // Allocate channel if we've found ssrc that doesn't exist in
57 57
                 // our channel
@@ -68,7 +68,7 @@ SDPDiffer.prototype.getNewMedia = function() {
68 68
         });
69 69
 
70 70
         // Look for new ssrc groups across the channels
71
-        othersMedia.ssrcGroups.forEach(function(otherSsrcGroup) {
71
+        othersMedia.ssrcGroups.forEach(otherSsrcGroup => {
72 72
 
73 73
             // try to match the other ssrc-group with an ssrc-group of ours
74 74
             let matched = false;
@@ -109,7 +109,7 @@ SDPDiffer.prototype.toJingle = function(modify) {
109 109
     const sdpMediaSsrcs = this.getNewMedia();
110 110
 
111 111
     let modified = false;
112
-    Object.keys(sdpMediaSsrcs).forEach(function(mediaindex) {
112
+    Object.keys(sdpMediaSsrcs).forEach(mediaindex => {
113 113
         modified = true;
114 114
         const media = sdpMediaSsrcs[mediaindex];
115 115
         modify.c('content', {name: media.mid});
@@ -119,12 +119,12 @@ SDPDiffer.prototype.toJingle = function(modify) {
119 119
         // FIXME: not completely sure this operates on blocks and / or handles
120 120
         // different ssrcs correctly
121 121
         // generate sources from lines
122
-        Object.keys(media.ssrcs).forEach(function(ssrcNum) {
122
+        Object.keys(media.ssrcs).forEach(ssrcNum => {
123 123
             const mediaSsrc = media.ssrcs[ssrcNum];
124 124
             modify.c('source', { xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0' });
125 125
             modify.attrs({ssrc: mediaSsrc.ssrc});
126 126
             // iterate over ssrc lines
127
-            mediaSsrc.lines.forEach(function(line) {
127
+            mediaSsrc.lines.forEach(line => {
128 128
                 const idx = line.indexOf(' ');
129 129
                 const kv = line.substr(idx + 1);
130 130
                 modify.c('parameter');
@@ -143,7 +143,7 @@ SDPDiffer.prototype.toJingle = function(modify) {
143 143
         });
144 144
 
145 145
         // generate source groups from lines
146
-        media.ssrcGroups.forEach(function(ssrcGroup) {
146
+        media.ssrcGroups.forEach(ssrcGroup => {
147 147
             if (ssrcGroup.ssrcs.length) {
148 148
 
149 149
                 modify.c('ssrc-group', {
@@ -151,7 +151,7 @@ SDPDiffer.prototype.toJingle = function(modify) {
151 151
                     xmlns: 'urn:xmpp:jingle:apps:rtp:ssma:0'
152 152
                 });
153 153
 
154
-                ssrcGroup.ssrcs.forEach(function(ssrc) {
154
+                ssrcGroup.ssrcs.forEach(ssrc => {
155 155
                     modify.c('source', { ssrc })
156 156
                         .up(); // end of source
157 157
                 });

+ 4
- 4
modules/xmpp/SDPUtil.spec.js ファイルの表示

@@ -1,16 +1,16 @@
1 1
 import * as SDPUtil from './SDPUtil';
2 2
 import * as SampleSdpStrings from './SampleSdpStrings.js';
3 3
 
4
-describe('SDPUtil', function() {
5
-    it('should parse an ice ufrag correctly', function() {
4
+describe('SDPUtil', () => {
5
+    it('should parse an ice ufrag correctly', () => {
6 6
         const line = 'a=ice-ufrag:3jlcc1b3j1rqt6';
7 7
         const parsed = SDPUtil.parse_iceufrag(line);
8 8
 
9 9
         expect(parsed).toEqual('3jlcc1b3j1rqt6');
10 10
     });
11 11
 
12
-    describe('preferVideoCodec', function() {
13
-        it('should move a preferred codec to the front', function() {
12
+    describe('preferVideoCodec', () => {
13
+        it('should move a preferred codec to the front', () => {
14 14
             const sdp = SampleSdpStrings.multiCodecVideoSdp;
15 15
             const videoMLine = sdp.media.find(m => m.type === 'video');
16 16
             SDPUtil.preferVideoCodec(videoMLine, 'H264');

+ 3
- 3
modules/xmpp/moderator.js ファイルの表示

@@ -434,7 +434,7 @@ Moderator.prototype._getLoginUrl = function(popup, urlCb, failureCb) {
434 434
     }
435 435
     this.connection.sendIQ(
436 436
         iq,
437
-        function(result) {
437
+        result => {
438 438
             let url = $(result).find('login-url').attr('url');
439 439
             url = decodeURIComponent(url);
440 440
             if (url) {
@@ -465,7 +465,7 @@ Moderator.prototype.logout = function(callback) {
465 465
     });
466 466
     this.connection.sendIQ(
467 467
         iq,
468
-        function(result) {
468
+        result => {
469 469
             let logoutUrl = $(result).find('logout').attr('logout-url');
470 470
             if (logoutUrl) {
471 471
                 logoutUrl = decodeURIComponent(logoutUrl);
@@ -474,7 +474,7 @@ Moderator.prototype.logout = function(callback) {
474 474
             Settings.clearSessionId();
475 475
             callback(logoutUrl);
476 476
         },
477
-        function(error) {
477
+        error => {
478 478
             const errmsg = 'Logout error';
479 479
             GlobalOnErrorHandler.callErrorHandler(new Error(errmsg));
480 480
             logger.error(errmsg, error);

+ 13
- 12
modules/xmpp/recording.js ファイルの表示

@@ -106,12 +106,12 @@ Recording.prototype.setRecordingJibri
106 106
         logger.log(iq.nodeTree);
107 107
         this.connection.sendIQ(
108 108
         iq,
109
-        function(result) {
109
+        result => {
110 110
             logger.log('Result', result);
111 111
             callback($(result).find('jibri').attr('state'),
112 112
             $(result).find('jibri').attr('url'));
113 113
         },
114
-        function(error) {
114
+        error => {
115 115
             logger.log('Failed to start recording, error: ', error);
116 116
             errCallback(error);
117 117
         });
@@ -138,7 +138,7 @@ Recording.prototype.setRecordingJirecon
138 138
         const self = this;
139 139
         this.connection.sendIQ(
140 140
         iq,
141
-        function(result) {
141
+        result => {
142 142
             // TODO wait for an IQ with the real status, since this is
143 143
             // provisional?
144 144
             self.jireconRid = $(result).find('recording').attr('rid');
@@ -153,7 +153,7 @@ Recording.prototype.setRecordingJirecon
153 153
 
154 154
             callback(state);
155 155
         },
156
-        function(error) {
156
+        error => {
157 157
             logger.log('Failed to start recording, error: ', error);
158 158
             errCallback(error);
159 159
         });
@@ -172,7 +172,7 @@ Recording.prototype.setRecordingColibri
172 172
 
173 173
     const self = this;
174 174
     this.connection.sendIQ(elem,
175
-        function(result) {
175
+        result => {
176 176
             logger.log('Set recording "', state, '". Result:', result);
177 177
             const recordingElem = $(result).find('>conference>recording');
178 178
             const newState = recordingElem.attr('state');
@@ -181,7 +181,7 @@ Recording.prototype.setRecordingColibri
181 181
             callback(newState);
182 182
 
183 183
             if (newState === 'pending') {
184
-                self.connection.addHandler(function(iq) {
184
+                self.connection.addHandler(iq => {
185 185
                     const state = $(iq).find('recording').attr('state');
186 186
                     if (state) {
187 187
                         self.state = newState;
@@ -190,7 +190,7 @@ Recording.prototype.setRecordingColibri
190 190
                 }, 'http://jitsi.org/protocol/colibri', 'iq', null, null, null);
191 191
             }
192 192
         },
193
-        function(error) {
193
+        error => {
194 194
             logger.warn(error);
195 195
             errCallback(error);
196 196
         }
@@ -256,8 +256,9 @@ Recording.prototype.toggleRecording = function(options, statusChangeHandler) {
256 256
 
257 257
     const self = this;
258 258
     logger.log('Toggle recording (old state, new state): ', oldState, newState);
259
-    this.setRecording(newState,
260
-        function(state, url) {
259
+    this.setRecording(
260
+        newState,
261
+        (state, url) => {
261 262
             // If the state is undefined we're going to wait for presence
262 263
             // update.
263 264
             if (state && state !== oldState) {
@@ -265,9 +266,9 @@ Recording.prototype.toggleRecording = function(options, statusChangeHandler) {
265 266
                 self.url = url;
266 267
                 statusChangeHandler(state);
267 268
             }
268
-        }, function(error) {
269
-            statusChangeHandler(Recording.status.FAILED, error);
270
-        }, options);
269
+        },
270
+        error => statusChangeHandler(Recording.status.FAILED, error),
271
+        options);
271 272
 };
272 273
 
273 274
 /**

+ 2
- 2
modules/xmpp/xmpp.js ファイルの表示

@@ -121,13 +121,13 @@ export default class XMPP extends Listenable {
121 121
             const pingJid = this.connection.domain;
122 122
             this.connection.ping.hasPingSupport(
123 123
                 pingJid,
124
-                function(hasPing) {
124
+                hasPing => {
125 125
                     if (hasPing) {
126 126
                         this.connection.ping.startInterval(pingJid);
127 127
                     } else {
128 128
                         logger.warn(`Ping NOT supported by ${pingJid}`);
129 129
                     }
130
-                }.bind(this));
130
+                });
131 131
 
132 132
             if (password) {
133 133
                 this.authenticatedUser = true;

読み込み中…
キャンセル
保存