瀏覽代碼

Removes document bind events between modules.

j8
hristoterezov 10 年之前
父節點
當前提交
c7e2331284

+ 2
- 2
index.html 查看文件

28
     <script src="service/UI/UIEvents.js?v=1"></script>
28
     <script src="service/UI/UIEvents.js?v=1"></script>
29
     <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
29
     <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
30
     <script src="libs/modules/connectionquality.bundle.js?v=3"></script>
30
     <script src="libs/modules/connectionquality.bundle.js?v=3"></script>
31
-    <script src="libs/modules/UI.bundle.js?v=13"></script>
31
+    <script src="libs/modules/UI.bundle.js?v=14"></script>
32
     <script src="libs/modules/statistics.bundle.js?v=5"></script>
32
     <script src="libs/modules/statistics.bundle.js?v=5"></script>
33
-    <script src="libs/modules/RTC.bundle.js?v=8"></script>
33
+    <script src="libs/modules/RTC.bundle.js?v=9"></script>
34
     <script src="libs/modules/simulcast.bundle.js?v=6"></script>
34
     <script src="libs/modules/simulcast.bundle.js?v=6"></script>
35
     <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
35
     <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
36
     <script src="libs/modules/xmpp.bundle.js?v=8"></script>
36
     <script src="libs/modules/xmpp.bundle.js?v=8"></script>

+ 8
- 10
libs/modules/RTC.bundle.js 查看文件

178
          var msgData = event.data;
178
          var msgData = event.data;
179
          console.info("Got My Data Channel Message:", msgData, dataChannel);
179
          console.info("Got My Data Channel Message:", msgData, dataChannel);
180
          };*/
180
          };*/
181
-    }
181
+    },
182
+    handleSelectedEndpointEvent: onSelectedEndpointChanged,
183
+    handlePinnedEndpointEvent: onPinnedEndpointChanged
182
 
184
 
183
-}
185
+};
184
 
186
 
185
 function onSelectedEndpointChanged(userResource)
187
 function onSelectedEndpointChanged(userResource)
186
 {
188
 {
203
     }
205
     }
204
 }
206
 }
205
 
207
 
206
-$(document).bind("selectedendpointchanged", function(event, userResource) {
207
-    onSelectedEndpointChanged(userResource);
208
-});
209
-
210
 function onPinnedEndpointChanged(userResource)
208
 function onPinnedEndpointChanged(userResource)
211
 {
209
 {
212
     console.log('pinned endpoint changed: ', userResource);
210
     console.log('pinned endpoint changed: ', userResource);
228
     }
226
     }
229
 }
227
 }
230
 
228
 
231
-$(document).bind("pinnedendpointchanged", function(event, userResource) {
232
-    onPinnedEndpointChanged(userResource);
233
-});
234
-
235
 module.exports = DataChannels;
229
 module.exports = DataChannels;
236
 
230
 
237
 
231
 
513
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function(event) {
507
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function(event) {
514
             DataChannels.init(event.peerconnection, eventEmitter);
508
             DataChannels.init(event.peerconnection, eventEmitter);
515
         });
509
         });
510
+        UI.addListener(UIEvents.SELECTED_ENDPOINT,
511
+            DataChannels.handleSelectedEndpointEvent);
512
+        UI.addListener(UIEvents.PINNED_ENDPOINT,
513
+            DataChannels.handlePinnedEndpointEvent);
516
         this.rtcUtils = new RTCUtils(this);
514
         this.rtcUtils = new RTCUtils(this);
517
         this.rtcUtils.obtainAudioAndVideoPermissions();
515
         this.rtcUtils.obtainAudioAndVideoPermissions();
518
     },
516
     },

+ 12
- 8
libs/modules/UI.bundle.js 查看文件

97
         function (endpointSimulcastLayers) {
97
         function (endpointSimulcastLayers) {
98
             VideoLayout.onSimulcastLayersChanging(endpointSimulcastLayers);
98
             VideoLayout.onSimulcastLayersChanging(endpointSimulcastLayers);
99
         });
99
         });
100
-    VideoLayout.init();
100
+    VideoLayout.init(eventEmitter);
101
 
101
 
102
     statistics.addAudioLevelListener(function(jid, audioLevel)
102
     statistics.addAudioLevelListener(function(jid, audioLevel)
103
     {
103
     {
4806
     updateInProgress: false,
4806
     updateInProgress: false,
4807
     newSrc: ''
4807
     newSrc: ''
4808
 };
4808
 };
4809
+
4810
+var eventEmitter = null;
4811
+
4809
 /**
4812
 /**
4810
  * Currently focused video "src"(displayed in large video).
4813
  * Currently focused video "src"(displayed in large video).
4811
  * @type {String}
4814
  * @type {String}
5284
     my.getVideoSize = getCameraVideoSize;
5287
     my.getVideoSize = getCameraVideoSize;
5285
     my.getVideoPosition = getCameraVideoPosition;
5288
     my.getVideoPosition = getCameraVideoPosition;
5286
 
5289
 
5287
-    my.init = function () {
5290
+    my.init = function (emitter) {
5288
         // Listen for large video size updates
5291
         // Listen for large video size updates
5289
         document.getElementById('largeVideo')
5292
         document.getElementById('largeVideo')
5290
             .addEventListener('loadedmetadata', function (e) {
5293
             .addEventListener('loadedmetadata', function (e) {
5292
                 currentVideoHeight = this.videoHeight;
5295
                 currentVideoHeight = this.videoHeight;
5293
                 VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
5296
                 VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
5294
             });
5297
             });
5298
+        eventEmitter = emitter;
5295
     };
5299
     };
5296
 
5300
 
5297
     my.isInLastN = function(resource) {
5301
     my.isInLastN = function(resource) {
5518
                 userChanged = true;
5522
                 userChanged = true;
5519
                 // we want the notification to trigger even if userJid is undefined,
5523
                 // we want the notification to trigger even if userJid is undefined,
5520
                 // or null.
5524
                 // or null.
5521
-                $(document).trigger("selectedendpointchanged", [largeVideoState.userResourceJid]);
5525
+                eventEmitter.emit(UIEvents.SELECTED_ENDPOINT,
5526
+                    largeVideoState.userResourceJid);
5522
             }
5527
             }
5523
 
5528
 
5524
             if (!largeVideoState.updateInProgress) {
5529
             if (!largeVideoState.updateInProgress) {
5662
             }
5667
             }
5663
 
5668
 
5664
             if (!noPinnedEndpointChangedEvent) {
5669
             if (!noPinnedEndpointChangedEvent) {
5665
-                $(document).trigger("pinnedendpointchanged");
5670
+                eventEmitter.emit(UIEvents.PINNED_ENDPOINT);
5666
             }
5671
             }
5667
             return;
5672
             return;
5668
         }
5673
         }
5680
             container.addClass("videoContainerFocused");
5685
             container.addClass("videoContainerFocused");
5681
 
5686
 
5682
             if (!noPinnedEndpointChangedEvent) {
5687
             if (!noPinnedEndpointChangedEvent) {
5683
-                $(document).trigger("pinnedendpointchanged", [resourceJid]);
5688
+                eventEmitter.emit(UIEvents.PINNED_ENDPOINT, resourceJid);
5684
             }
5689
             }
5685
         }
5690
         }
5686
 
5691
 
6481
                     // picked up later by the lastN changed event handler.
6486
                     // picked up later by the lastN changed event handler.
6482
 
6487
 
6483
                     lastNPickupJid = jid;
6488
                     lastNPickupJid = jid;
6484
-                    $(document).trigger("pinnedendpointchanged", [Strophe.getResourceFromJid(jid)]);
6489
+                    eventEmitter.emit(UIEvents.PINNED_ENDPOINT,
6490
+                        Strophe.getResourceFromJid(jid));
6485
                 }
6491
                 }
6486
             } else if (jid == xmpp.myJid()) {
6492
             } else if (jid == xmpp.myJid()) {
6487
                 $("#localVideoContainer").click();
6493
                 $("#localVideoContainer").click();
6778
 
6784
 
6779
                 console.info([esl, primarySSRC, msid, sid, electedStream]);
6785
                 console.info([esl, primarySSRC, msid, sid, electedStream]);
6780
 
6786
 
6781
-                var msidParts = msid.split(' ');
6782
-
6783
                 var preload = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC)) == largeVideoState.userResourceJid);
6787
                 var preload = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC)) == largeVideoState.userResourceJid);
6784
 
6788
 
6785
                 if (preload) {
6789
                 if (preload) {

+ 4
- 10
modules/RTC/DataChannels.js 查看文件

177
          var msgData = event.data;
177
          var msgData = event.data;
178
          console.info("Got My Data Channel Message:", msgData, dataChannel);
178
          console.info("Got My Data Channel Message:", msgData, dataChannel);
179
          };*/
179
          };*/
180
-    }
180
+    },
181
+    handleSelectedEndpointEvent: onSelectedEndpointChanged,
182
+    handlePinnedEndpointEvent: onPinnedEndpointChanged
181
 
183
 
182
-}
184
+};
183
 
185
 
184
 function onSelectedEndpointChanged(userResource)
186
 function onSelectedEndpointChanged(userResource)
185
 {
187
 {
202
     }
204
     }
203
 }
205
 }
204
 
206
 
205
-$(document).bind("selectedendpointchanged", function(event, userResource) {
206
-    onSelectedEndpointChanged(userResource);
207
-});
208
-
209
 function onPinnedEndpointChanged(userResource)
207
 function onPinnedEndpointChanged(userResource)
210
 {
208
 {
211
     console.log('pinned endpoint changed: ', userResource);
209
     console.log('pinned endpoint changed: ', userResource);
227
     }
225
     }
228
 }
226
 }
229
 
227
 
230
-$(document).bind("pinnedendpointchanged", function(event, userResource) {
231
-    onPinnedEndpointChanged(userResource);
232
-});
233
-
234
 module.exports = DataChannels;
228
 module.exports = DataChannels;
235
 
229
 

+ 4
- 0
modules/RTC/RTC.js 查看文件

126
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function(event) {
126
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function(event) {
127
             DataChannels.init(event.peerconnection, eventEmitter);
127
             DataChannels.init(event.peerconnection, eventEmitter);
128
         });
128
         });
129
+        UI.addListener(UIEvents.SELECTED_ENDPOINT,
130
+            DataChannels.handleSelectedEndpointEvent);
131
+        UI.addListener(UIEvents.PINNED_ENDPOINT,
132
+            DataChannels.handlePinnedEndpointEvent);
129
         this.rtcUtils = new RTCUtils(this);
133
         this.rtcUtils = new RTCUtils(this);
130
         this.rtcUtils.obtainAudioAndVideoPermissions();
134
         this.rtcUtils.obtainAudioAndVideoPermissions();
131
     },
135
     },

+ 1
- 1
modules/UI/UI.js 查看文件

96
         function (endpointSimulcastLayers) {
96
         function (endpointSimulcastLayers) {
97
             VideoLayout.onSimulcastLayersChanging(endpointSimulcastLayers);
97
             VideoLayout.onSimulcastLayersChanging(endpointSimulcastLayers);
98
         });
98
         });
99
-    VideoLayout.init();
99
+    VideoLayout.init(eventEmitter);
100
 
100
 
101
     statistics.addAudioLevelListener(function(jid, audioLevel)
101
     statistics.addAudioLevelListener(function(jid, audioLevel)
102
     {
102
     {

+ 13
- 5
modules/UI/videolayout/VideoLayout.js 查看文件

16
     updateInProgress: false,
16
     updateInProgress: false,
17
     newSrc: ''
17
     newSrc: ''
18
 };
18
 };
19
+
20
+var eventEmitter = null;
21
+
19
 /**
22
 /**
20
  * Currently focused video "src"(displayed in large video).
23
  * Currently focused video "src"(displayed in large video).
21
  * @type {String}
24
  * @type {String}
494
     my.getVideoSize = getCameraVideoSize;
497
     my.getVideoSize = getCameraVideoSize;
495
     my.getVideoPosition = getCameraVideoPosition;
498
     my.getVideoPosition = getCameraVideoPosition;
496
 
499
 
497
-    my.init = function () {
500
+    my.init = function (emitter) {
498
         // Listen for large video size updates
501
         // Listen for large video size updates
499
         document.getElementById('largeVideo')
502
         document.getElementById('largeVideo')
500
             .addEventListener('loadedmetadata', function (e) {
503
             .addEventListener('loadedmetadata', function (e) {
502
                 currentVideoHeight = this.videoHeight;
505
                 currentVideoHeight = this.videoHeight;
503
                 VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
506
                 VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
504
             });
507
             });
508
+        eventEmitter = emitter;
505
     };
509
     };
506
 
510
 
507
     my.isInLastN = function(resource) {
511
     my.isInLastN = function(resource) {
728
                 userChanged = true;
732
                 userChanged = true;
729
                 // we want the notification to trigger even if userJid is undefined,
733
                 // we want the notification to trigger even if userJid is undefined,
730
                 // or null.
734
                 // or null.
731
-                $(document).trigger("selectedendpointchanged", [largeVideoState.userResourceJid]);
735
+                eventEmitter.emit(UIEvents.SELECTED_ENDPOINT,
736
+                    largeVideoState.userResourceJid);
732
             }
737
             }
733
 
738
 
734
             if (!largeVideoState.updateInProgress) {
739
             if (!largeVideoState.updateInProgress) {
872
             }
877
             }
873
 
878
 
874
             if (!noPinnedEndpointChangedEvent) {
879
             if (!noPinnedEndpointChangedEvent) {
875
-                $(document).trigger("pinnedendpointchanged");
880
+                eventEmitter.emit(UIEvents.PINNED_ENDPOINT);
876
             }
881
             }
877
             return;
882
             return;
878
         }
883
         }
890
             container.addClass("videoContainerFocused");
895
             container.addClass("videoContainerFocused");
891
 
896
 
892
             if (!noPinnedEndpointChangedEvent) {
897
             if (!noPinnedEndpointChangedEvent) {
893
-                $(document).trigger("pinnedendpointchanged", [resourceJid]);
898
+                eventEmitter.emit(UIEvents.PINNED_ENDPOINT, resourceJid);
894
             }
899
             }
895
         }
900
         }
896
 
901
 
1509
 
1514
 
1510
         $('.userAvatar').css('left', (width - height) / 2);
1515
         $('.userAvatar').css('left', (width - height) / 2);
1511
 
1516
 
1517
+
1518
+
1512
         $(document).trigger("remotevideo.resized", [width, height]);
1519
         $(document).trigger("remotevideo.resized", [width, height]);
1513
     };
1520
     };
1514
 
1521
 
1691
                     // picked up later by the lastN changed event handler.
1698
                     // picked up later by the lastN changed event handler.
1692
 
1699
 
1693
                     lastNPickupJid = jid;
1700
                     lastNPickupJid = jid;
1694
-                    $(document).trigger("pinnedendpointchanged", [Strophe.getResourceFromJid(jid)]);
1701
+                    eventEmitter.emit(UIEvents.PINNED_ENDPOINT,
1702
+                        Strophe.getResourceFromJid(jid));
1695
                 }
1703
                 }
1696
             } else if (jid == xmpp.myJid()) {
1704
             } else if (jid == xmpp.myJid()) {
1697
                 $("#localVideoContainer").click();
1705
                 $("#localVideoContainer").click();

+ 3
- 1
service/UI/UIEvents.js 查看文件

1
 var UIEvents = {
1
 var UIEvents = {
2
-    NICKNAME_CHANGED: "UI.nickname_changed"
2
+    NICKNAME_CHANGED: "UI.nickname_changed",
3
+    SELECTED_ENDPOINT: "UI.selected_endpoint",
4
+    PINNED_ENDPOINT: "UI.pinned_endpoint"
3
 };
5
 };
4
 //module.exports = UIEvents;
6
 //module.exports = UIEvents;

Loading…
取消
儲存