Explorar el Código

chore: remove usage of `self`

This has become obsolete thanks to ES6 arrow functions
master
Philipp Hancke hace 5 años
padre
commit
509740734b

+ 3
- 6
modules/statistics/LocalStatsCollector.js Ver fichero

@@ -107,9 +107,6 @@ LocalStatsCollector.prototype.start = function() {
107 107
 
108 108
     source.connect(analyser);
109 109
 
110
-
111
-    const self = this;
112
-
113 110
     this.intervalId = setInterval(
114 111
         () => {
115 112
             const array = new Uint8Array(analyser.frequencyBinCount);
@@ -117,9 +114,9 @@ LocalStatsCollector.prototype.start = function() {
117 114
             analyser.getByteTimeDomainData(array);
118 115
             const audioLevel = timeDomainDataToAudioLevel(array);
119 116
 
120
-            if (audioLevel !== self.audioLevel) {
121
-                self.audioLevel = animateLevel(audioLevel, self.audioLevel);
122
-                self.callback(self.audioLevel);
117
+            if (audioLevel !== this.audioLevel) {
118
+                this.audioLevel = animateLevel(audioLevel, this.audioLevel);
119
+                this.callback(this.audioLevel);
123 120
             }
124 121
         },
125 122
         this.intervalMilis

+ 15
- 17
modules/statistics/RTPStatsCollector.js Ver fichero

@@ -290,13 +290,11 @@ StatsCollector.prototype.errorCallback = function(error) {
290 290
  * Starts stats updates.
291 291
  */
292 292
 StatsCollector.prototype.start = function(startAudioLevelStats) {
293
-    const self = this;
294
-
295 293
     if (startAudioLevelStats) {
296 294
         this.audioLevelsIntervalId = setInterval(
297 295
             () => {
298 296
                 // Interval updates
299
-                self.peerconnection.getStats(
297
+                this.peerconnection.getStats(
300 298
                     report => {
301 299
                         let results = null;
302 300
 
@@ -306,27 +304,27 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
306 304
                         } else {
307 305
                             results = report.result();
308 306
                         }
309
-                        self.currentAudioLevelsReport = results;
307
+                        this.currentAudioLevelsReport = results;
310 308
                         if (this._usesPromiseGetStats) {
311
-                            self.processNewAudioLevelReport();
309
+                            this.processNewAudioLevelReport();
312 310
                         } else {
313
-                            self.processAudioLevelReport();
311
+                            this.processAudioLevelReport();
314 312
                         }
315 313
 
316
-                        self.baselineAudioLevelsReport
317
-                            = self.currentAudioLevelsReport;
314
+                        this.baselineAudioLevelsReport
315
+                            = this.currentAudioLevelsReport;
318 316
                     },
319
-                    error => self.errorCallback(error)
317
+                    error => this.errorCallback(error)
320 318
                 );
321 319
             },
322
-            self.audioLevelsIntervalMilis
320
+            this.audioLevelsIntervalMilis
323 321
         );
324 322
     }
325 323
 
326 324
     this.statsIntervalId = setInterval(
327 325
         () => {
328 326
             // Interval updates
329
-            self.peerconnection.getStats(
327
+            this.peerconnection.getStats(
330 328
                 report => {
331 329
                     let results = null;
332 330
 
@@ -339,24 +337,24 @@ StatsCollector.prototype.start = function(startAudioLevelStats) {
339 337
                         results = report.result();
340 338
                     }
341 339
 
342
-                    self.currentStatsReport = results;
340
+                    this.currentStatsReport = results;
343 341
                     try {
344 342
                         if (this._usesPromiseGetStats) {
345
-                            self.processNewStatsReport();
343
+                            this.processNewStatsReport();
346 344
                         } else {
347
-                            self.processStatsReport();
345
+                            this.processStatsReport();
348 346
                         }
349 347
                     } catch (e) {
350 348
                         GlobalOnErrorHandler.callErrorHandler(e);
351 349
                         logger.error(`Unsupported key:${e}`, e);
352 350
                     }
353 351
 
354
-                    self.previousStatsReport = self.currentStatsReport;
352
+                    this.previousStatsReport = this.currentStatsReport;
355 353
                 },
356
-                error => self.errorCallback(error)
354
+                error => this.errorCallback(error)
357 355
             );
358 356
         },
359
-        self.statsIntervalMilis
357
+        this.statsIntervalMilis
360 358
     );
361 359
 };
362 360
 

+ 2
- 4
modules/xmpp/ChatRoom.js Ver fichero

@@ -328,8 +328,6 @@ export default class ChatRoom extends Listenable {
328 328
             .c('x', { xmlns: 'jabber:x:data',
329 329
                 type: 'submit' });
330 330
 
331
-        const self = this;
332
-
333 331
         this.connection.sendIQ(getForm, form => {
334 332
             if (!$(form).find(
335 333
                     '>query>x[xmlns="jabber:x:data"]'
@@ -342,7 +340,7 @@ export default class ChatRoom extends Listenable {
342 340
                 return;
343 341
             }
344 342
 
345
-            const formSubmit = $iq({ to: self.roomjid,
343
+            const formSubmit = $iq({ to: this.roomjid,
346 344
                 type: 'set' })
347 345
                 .c('query', { xmlns: 'http://jabber.org/protocol/muc#owner' });
348 346
 
@@ -356,7 +354,7 @@ export default class ChatRoom extends Listenable {
356 354
             formSubmit.c('field', { 'var': 'muc#roomconfig_whois' })
357 355
                 .c('value').t('anyone').up().up();
358 356
 
359
-            self.connection.sendIQ(formSubmit);
357
+            this.connection.sendIQ(formSubmit);
360 358
 
361 359
         }, error => {
362 360
             GlobalOnErrorHandler.callErrorHandler(error);

+ 18
- 22
modules/xmpp/SDP.js Ver fichero

@@ -49,15 +49,14 @@ SDP.prototype.removeUdpCandidates = false;
49 49
  * Returns map of MediaChannel mapped per channel idx.
50 50
  */
51 51
 SDP.prototype.getMediaSsrcMap = function() {
52
-    const self = this;
53 52
     const mediaSSRCs = {};
54 53
     let tmp;
55 54
 
56
-    for (let mediaindex = 0; mediaindex < self.media.length; mediaindex++) {
57
-        tmp = SDPUtil.findLines(self.media[mediaindex], 'a=ssrc:');
55
+    for (let mediaindex = 0; mediaindex < this.media.length; mediaindex++) {
56
+        tmp = SDPUtil.findLines(this.media[mediaindex], 'a=ssrc:');
58 57
         const mid
59 58
             = SDPUtil.parseMID(
60
-                SDPUtil.findLine(self.media[mediaindex], 'a=mid:'));
59
+                SDPUtil.findLine(this.media[mediaindex], 'a=mid:'));
61 60
         const media = {
62 61
             mediaindex,
63 62
             mid,
@@ -79,7 +78,7 @@ SDP.prototype.getMediaSsrcMap = function() {
79 78
             }
80 79
             media.ssrcs[linessrc].lines.push(line);
81 80
         });
82
-        tmp = SDPUtil.findLines(self.media[mediaindex], 'a=ssrc-group:');
81
+        tmp = SDPUtil.findLines(this.media[mediaindex], 'a=ssrc-group:');
83 82
         tmp.forEach(line => {
84 83
             const idx = line.indexOf(' ');
85 84
             const semantics = line.substr(0, idx).substr(13);
@@ -395,13 +394,12 @@ SDP.prototype.toJingle = function(elem, thecreator) {
395 394
 
396 395
 SDP.prototype.transportToJingle = function(mediaindex, elem) {
397 396
     let tmp;
398
-    const self = this;
399 397
 
400 398
     elem.c('transport');
401 399
 
402 400
     // XEP-0343 DTLS/SCTP
403 401
     const sctpmap
404
-        = SDPUtil.findLine(this.media[mediaindex], 'a=sctpmap:', self.session);
402
+        = SDPUtil.findLine(this.media[mediaindex], 'a=sctpmap:', this.session);
405 403
 
406 404
     if (sctpmap) {
407 405
         const sctpAttrs = SDPUtil.parseSCTPMap(sctpmap);
@@ -435,9 +433,9 @@ SDP.prototype.transportToJingle = function(mediaindex, elem) {
435 433
         // eslint-disable-next-line no-param-reassign
436 434
         line
437 435
             = SDPUtil.findLine(
438
-                self.media[mediaindex],
436
+                this.media[mediaindex],
439 437
                 'a=setup:',
440
-                self.session);
438
+                this.session);
441 439
         if (line) {
442 440
             tmp.setup = line.substr(8);
443 441
         }
@@ -460,7 +458,7 @@ SDP.prototype.transportToJingle = function(mediaindex, elem) {
460 458
             lines.forEach(line => {
461 459
                 const candidate = SDPUtil.candidateToJingle(line);
462 460
 
463
-                if (self.failICE) {
461
+                if (this.failICE) {
464 462
                     candidate.ip = '1.1.1.1';
465 463
                 }
466 464
                 const protocol
@@ -468,9 +466,9 @@ SDP.prototype.transportToJingle = function(mediaindex, elem) {
468 466
                         ? candidate.protocol.toLowerCase()
469 467
                         : '';
470 468
 
471
-                if ((self.removeTcpCandidates
469
+                if ((this.removeTcpCandidates
472 470
                         && (protocol === 'tcp' || protocol === 'ssltcp'))
473
-                    || (self.removeUdpCandidates && protocol === 'udp')) {
471
+                    || (this.removeUdpCandidates && protocol === 'udp')) {
474 472
                     return;
475 473
                 }
476 474
                 elem.c('candidate', candidate).up();
@@ -538,7 +536,6 @@ SDP.prototype.rtcpFbFromJingle = function(elem, payloadtype) { // XEP-0293
538 536
 
539 537
 // construct an SDP from a jingle stanza
540 538
 SDP.prototype.fromJingle = function(jingle) {
541
-    const self = this;
542 539
     const sessionId = Date.now();
543 540
 
544 541
     // Use a unique session id for every TPC.
@@ -561,7 +558,7 @@ SDP.prototype.fromJingle = function(jingle) {
561 558
                     .get();
562 559
 
563 560
             if (contents.length > 0) {
564
-                self.raw
561
+                this.raw
565 562
                     += `a=group:${
566 563
                         group.getAttribute('semantics')
567 564
                             || group.getAttribute('type')} ${
@@ -572,9 +569,9 @@ SDP.prototype.fromJingle = function(jingle) {
572 569
 
573 570
     this.session = this.raw;
574 571
     jingle.find('>content').each((_, content) => {
575
-        const m = self.jingle2media($(content));
572
+        const m = this.jingle2media($(content));
576 573
 
577
-        self.media.push(m);
574
+        this.media.push(m);
578 575
     });
579 576
 
580 577
     // reconstruct msid-semantic -- apparently not necessary
@@ -592,7 +589,6 @@ SDP.prototype.fromJingle = function(jingle) {
592 589
 SDP.prototype.jingle2media = function(content) {
593 590
     const desc = content.find('description');
594 591
     let media = '';
595
-    const self = this;
596 592
     const sctp = content.find(
597 593
         '>transport>sctpmap[xmlns="urn:xmpp:jingle:transports:dtls-sctp:1"]');
598 594
 
@@ -709,11 +705,11 @@ SDP.prototype.jingle2media = function(content) {
709 705
         }
710 706
 
711 707
         // xep-0293
712
-        media += self.rtcpFbFromJingle($(payloadType), payloadType.getAttribute('id'));
708
+        media += this.rtcpFbFromJingle($(payloadType), payloadType.getAttribute('id'));
713 709
     });
714 710
 
715 711
     // xep-0293
716
-    media += self.rtcpFbFromJingle(desc, '*');
712
+    media += this.rtcpFbFromJingle(desc, '*');
717 713
 
718 714
     // xep-0294
719 715
     tmp
@@ -735,11 +731,11 @@ SDP.prototype.jingle2media = function(content) {
735 731
             protocol
736 732
                 = typeof protocol === 'string' ? protocol.toLowerCase() : '';
737 733
 
738
-            if ((self.removeTcpCandidates
734
+            if ((this.removeTcpCandidates
739 735
                     && (protocol === 'tcp' || protocol === 'ssltcp'))
740
-                || (self.removeUdpCandidates && protocol === 'udp')) {
736
+                || (this.removeUdpCandidates && protocol === 'udp')) {
741 737
                 return;
742
-            } else if (self.failICE) {
738
+            } else if (this.failICE) {
743 739
                 transport.setAttribute('ip', '1.1.1.1');
744 740
             }
745 741
 

Loading…
Cancelar
Guardar