Explorar el Código

do not use members module

master
isymchych hace 9 años
padre
commit
09aa9482c0

+ 177
- 206
app.js Ver fichero

@@ -1,5 +1,4 @@
1
-/* jshint -W117 */
2
-/* global JitsiMeetJS */
1
+/* global $, JitsiMeetJS, config, Promise */
3 2
 /* application specific logic */
4 3
 
5 4
 require("jquery");
@@ -13,66 +12,41 @@ window.toastr = require("toastr");
13 12
 require("jQuery-Impromptu");
14 13
 require("autosize");
15 14
 
15
+var CQEvents = require('./service/connectionquality/CQEvents');
16
+var UIEvents = require('./service/UI/UIEvents');
17
+
16 18
 var Commands = {
17 19
     CONNECTION_QUALITY: "connectionQuality",
18 20
     EMAIL: "email"
19 21
 };
20 22
 
21
-function createConference(connection, room) {
22
-    var localTracks = [];
23
-    var remoteTracks = {};
24
-
25
-    return {
26
-        muteAudio: function (mute) {
27
-
28
-        },
29
-
30
-        muteVideo: function (mute) {
31
-
32
-        },
33
-
34
-        toggleAudioMuted: function () {
35
-            APP.UI.setAudioMuted(muted);
36
-        },
37
-
38
-        toggleVideoMuted: function () {
39
-            APP.UI.setVideoMuted(muted);
40
-        },
41
-
42
-        setNickname: function (nickname) {
43
-            APP.settings.setDisplayName(nickname);
44
-            room.setDisplayName(nickname);
45
-        },
46
-
47
-        setStartMuted: function (audio, video) {
48
-            // FIXME room.setStartMuted
49
-        },
50
-
51
-        sendMessage: function (message) {
52
-            room.sendTextMessage(message);
53
-        },
54
-
55
-        isModerator: function () {
56
-            return false;
57
-        },
58
-
59
-        localId: function () {
60
-            return room.myUserId();
61
-        },
62
-
63
-        isLocalId: function (id) {
64
-            return id === this.localId();
65
-        }
66
-    };
67
-}
68
-
69 23
 var APP = {
70
-    JitsiMeetJS: JitsiMeetJS,
71
-
72 24
     init: function () {
73
-        this.JitsiMeetJS.init();
74
-        this.JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
75
-        this.conference = null;
25
+        JitsiMeetJS.init();
26
+        JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
27
+
28
+        this.conference = {
29
+            localId: undefined,
30
+            isModerator: false,
31
+            membersCount: 0,
32
+            audioMuted: false,
33
+            videoMuted: false,
34
+            isLocalId: function (id) {
35
+                return this.localId === id;
36
+            },
37
+            muteAudio: function (mute) {
38
+                APP.UI.eventEmitter.emit(UIEvents.AUDIO_MUTED, mute);
39
+            },
40
+            toggleAudioMuted: function () {
41
+                this.muteAudio(!this.audioMuted);
42
+            },
43
+            muteVideo: function (mute) {
44
+                APP.UI.eventEmitter.emit(UIEvents.VIDEO_MUTED, mute);
45
+            },
46
+            toggleVideoMuted: function () {
47
+                this.muteVideo(!this.videoMuted);
48
+            }
49
+        };
76 50
 
77 51
         this.UI = require("./modules/UI/UI");
78 52
         this.API = require("./modules/API/API");
@@ -85,145 +59,143 @@ var APP = {
85 59
             require("./modules/keyboardshortcut/keyboardshortcut");
86 60
         this.translation = require("./modules/translation/translation");
87 61
         this.settings = require("./modules/settings/Settings");
88
-        //this.DTMF = require("./modules/DTMF/DTMF");
89
-        this.members = require("./modules/members/MemberList");
90 62
         this.configFetch = require("./modules/config/HttpConfigFetch");
91 63
     }
92 64
 };
93 65
 
66
+
67
+var ConnectionEvents = JitsiMeetJS.events.connection;
68
+var ConnectionErrors = JitsiMeetJS.errors.connection;
94 69
 function connect() {
95
-    var connection = new APP.JitsiMeetJS.JitsiConnection(null, null, {
70
+    var connection = new JitsiMeetJS.JitsiConnection(null, null, {
96 71
         hosts: config.hosts,
97 72
         bosh: config.bosh,
98 73
         clientNode: config.clientNode
99 74
     });
100 75
 
101
-    var events = APP.JitsiMeetJS.events.connection;
102
-
103 76
     return new Promise(function (resolve, reject) {
104
-        var onConnectionSuccess = function () {
77
+        var handlers = {};
78
+
79
+        var unsubscribe = function () {
80
+            Object.keys(handlers).forEach(function (event) {
81
+                connection.removeEventListener(event, handlers[event]);
82
+            });
83
+        };
84
+
85
+        handlers[ConnectionEvents.CONNECTION_ESTABLISHED] = function () {
105 86
             console.log('CONNECTED');
87
+            unsubscribe();
106 88
             resolve(connection);
107 89
         };
108 90
 
109
-        var onConnectionFailed = function () {
110
-            console.error('CONNECTION FAILED');
111
-            reject();
91
+        var listenForFailure = function (event) {
92
+            handlers[event] = function () {
93
+                // convert arguments to array
94
+                var args = Array.prototype.slice.call(arguments);
95
+                args.unshift(event);
96
+                // [event, ...params]
97
+                console.error('CONNECTION FAILED:', args);
98
+
99
+                unsubscribe();
100
+                reject(args);
101
+            };
112 102
         };
113 103
 
114
-        var onDisconnect = function () {
115
-            console.log('DISCONNECT');
116
-            connection.removeEventListener(
117
-                events.CONNECTION_ESTABLISHED, onConnectionSuccess
118
-            );
119
-            connection.removeEventListener(
120
-                events.CONNECTION_FAILED, onConnectionFailed
121
-            );
122
-            connection.removeEventListener(
123
-                events.CONNECTION_DISCONNECTED, onDisconnect
124
-            );
125
-        };
104
+        listenForFailure(ConnectionEvents.CONNECTION_FAILED);
105
+        listenForFailure(ConnectionErrors.PASSWORD_REQUIRED);
106
+        listenForFailure(ConnectionErrors.CONNECTION_ERROR);
107
+        listenForFailure(ConnectionErrors.OTHER_ERRORS);
126 108
 
127
-        connection.addEventListener(
128
-            events.CONNECTION_ESTABLISHED, onConnectionSuccess
129
-        );
130
-        connection.addEventListener(
131
-            events.CONNECTION_FAILED, onConnectionFailed
132
-        );
133
-        connection.addEventListener(
134
-            events.CONNECTION_DISCONNECTED, onDisconnect
135
-        );
109
+        // install event listeners
110
+        Object.keys(handlers).forEach(function (event) {
111
+            connection.addEventListener(event, handlers[event]);
112
+        });
136 113
 
137 114
         connection.connect();
138
-    }).catch(function (errType, msg) {
139
-        // TODO handle OTHER_ERROR only
140
-        APP.UI.notifyConnectionFailed(msg);
115
+    }).catch(function (err) {
116
+        if (err[0] === ConnectionErrors.PASSWORD_REQUIRED) {
117
+            // FIXME ask for password and try again
118
+            return connect();
119
+        }
120
+        console.error('FAILED TO CONNECT', err);
121
+        APP.UI.notifyConnectionFailed(err[1]);
141 122
 
142
-        // rethrow
143
-        throw new Error(errType);
123
+        throw new Error(err[0]);
144 124
     });
145 125
 }
146 126
 
147
-var ConferenceEvents = APP.JitsiMeetJS.events.conference;
148
-var ConferenceErrors = APP.JitsiMeetJS.errors.conference;
127
+var ConferenceEvents = JitsiMeetJS.events.conference;
128
+var ConferenceErrors = JitsiMeetJS.errors.conference;
149 129
 function initConference(connection, roomName) {
150 130
     var room = connection.initJitsiConference(roomName, {
151 131
         openSctp: config.openSctp,
152 132
         disableAudioLevels: config.disableAudioLevels
153 133
     });
154 134
 
155
-    var conf =  createConference(connection, room);
135
+    var users = {};
136
+    var localTracks = [];
156 137
 
157
-    room.on(ConferenceEvents.IN_LAST_N_CHANGED, function (inLastN) {
158
-        if (config.muteLocalVideoIfNotInLastN) {
159
-            // TODO mute or unmute if required
160
-            // mark video on UI
161
-            // APP.UI.markVideoMuted(true/false);
138
+    APP.conference.localId = room.myUserId();
139
+    Object.defineProperty(APP.conference, "membersCount", {
140
+        get: function () {
141
+            return Object.keys(users).length; // FIXME maybe +1?
162 142
         }
163 143
     });
164 144
 
165
-    room.on(
166
-        ConferenceEvents.ACTIVE_SPEAKER_CHANGED,
167
-        function (id) {
168
-            APP.UI.markDominantSpiker(id);
169
-        }
170
-    );
171
-    room.on(
172
-        ConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
173
-        function (ids) {
174
-            APP.UI.handleLastNEndpoints(ids);
175
-        }
176
-    );
145
+    room.on(ConferenceEvents.USER_JOINED, function (id) {
146
+        users[id] = {
147
+            displayName: undefined,
148
+            tracks: []
149
+        };
150
+        // FIXME email???
151
+        APP.UI.addUser(id);
152
+    });
153
+    room.on(ConferenceEvents.USER_LEFT, function (id) {
154
+        delete users[id];
155
+        APP.UI.removeUser(id);
156
+    });
177 157
 
178
-    room.on(
179
-        ConferenceEvents.DISPLAY_NAME_CHANGED,
180
-        function (id, displayName) {
181
-            APP.UI.changeDisplayName(id, displayName);
182
-        }
183
-    );
184 158
 
185
-    room.on(
186
-        ConferenceEvents.USER_JOINED,
187
-        function (id) {
188
-            // FIXME email???
189
-            APP.UI.addUser(id);
190
-        }
191
-    );
159
+    room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
160
+        // FIXME handle mute
161
+    });
162
+    room.on(ConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED, function (id, lvl) {
163
+        APP.UI.setAudioLevel(id, lvl);
164
+    });
165
+    APP.UI.addListener(UIEvents.AUDIO_MUTED, function (muted) {
166
+        // FIXME mute or unmute
167
+        APP.UI.setAudioMuted(muted);
168
+        APP.conference.audioMuted = muted;
169
+    });
170
+    APP.UI.addListener(UIEvents.VIDEO_MUTED, function (muted) {
171
+        // FIXME mute or unmute
172
+        APP.UI.setVideoMuted(muted);
173
+        APP.conference.videoMuted = muted;
174
+    });
192 175
 
193
-    room.on(
194
-        ConferenceEvents.USER_LEFT,
195
-        function (id) {
196
-            APP.UI.removeUser(id);
197
-        }
198
-    );
199 176
 
200
-    room.on(
201
-        ConferenceEvents.TRACK_MUTE_CHANGED,
202
-        function (track) {
203
-            // FIXME handle mute
177
+    room.on(ConferenceEvents.IN_LAST_N_CHANGED, function (inLastN) {
178
+        if (config.muteLocalVideoIfNotInLastN) {
179
+            // TODO mute or unmute if required
180
+            // mark video on UI
181
+            // APP.UI.markVideoMuted(true/false);
204 182
         }
205
-    );
183
+    });
184
+    room.on(ConferenceEvents.LAST_N_ENDPOINTS_CHANGED, function (ids) {
185
+        APP.UI.handleLastNEndpoints(ids);
186
+    });
187
+    room.on(ConferenceEvents.ACTIVE_SPEAKER_CHANGED, function (id) {
188
+        APP.UI.markDominantSpiker(id);
189
+    });
206 190
 
207
-    room.on(
208
-        ConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED,
209
-        function (id, lvl) {
210
-            APP.UI.setAudioLevel(id, lvl);
211
-        }
212
-    );
213 191
 
214
-    room.on(
215
-        ConferenceEvents.CONNECTION_INTERRUPTED,
216
-        function () {
217
-            APP.UI.markVideoInterrupted(true);
218
-        }
219
-    );
192
+    room.on(ConferenceEvents.CONNECTION_INTERRUPTED, function () {
193
+        APP.UI.markVideoInterrupted(true);
194
+    });
195
+    room.on(ConferenceEvents.CONNECTION_RESTORED, function () {
196
+        APP.UI.markVideoInterrupted(false);
197
+    });
220 198
 
221
-    room.on(
222
-        ConferenceEvents.CONNECTION_RESTORED,
223
-        function () {
224
-            APP.UI.markVideoInterrupted(false);
225
-        }
226
-    );
227 199
 
228 200
     APP.connectionquality.addListener(
229 201
         CQEvents.LOCALSTATS_UPDATED,
@@ -239,20 +211,14 @@ function initConference(connection, roomName) {
239 211
             });
240 212
         }
241 213
     );
242
-
243
-    APP.connectionquality.addListener(
244
-        CQEvents.STOP,
245
-        function () {
246
-            APP.UI.hideStats();
247
-            room.removeCommand(Commands.CONNECTION_QUALITY);
248
-        }
249
-    );
250
-
214
+    APP.connectionquality.addListener(CQEvents.STOP, function () {
215
+        APP.UI.hideStats();
216
+        room.removeCommand(Commands.CONNECTION_QUALITY);
217
+    });
251 218
     // listen to remote stats
252 219
     room.addCommandListener(Commands.CONNECTION_QUALITY, function (data) {
253 220
         APP.connectionquality.updateRemoteStats(data.attributes.id, data.value);
254 221
     });
255
-
256 222
     APP.connectionquality.addListener(
257 223
         CQEvents.REMOTESTATS_UPDATED,
258 224
         function (id, percent, stats) {
@@ -260,7 +226,8 @@ function initConference(connection, roomName) {
260 226
         }
261 227
     );
262 228
 
263
-     // share email with other users
229
+
230
+    // share email with other users
264 231
     function sendEmail(email) {
265 232
         room.sendCommand(Commands.EMAIL, {
266 233
             value: email,
@@ -270,38 +237,51 @@ function initConference(connection, roomName) {
270 237
         });
271 238
     }
272 239
 
240
+    var email = APP.settings.getEmail();
241
+    email && sendEmail(email);
273 242
     APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
274 243
         APP.settings.setEmail(email);
275
-        APP.UI.setUserAvatar(room.myUserId(), data.value);
244
+        APP.UI.setUserAvatar(room.myUserId(), email);
276 245
         sendEmail(email);
277 246
     });
278
-    var email = APP.settings.getEmail();
279
-    if (email) {
280
-        sendEmail(APP.settings.getEmail());
281
-    }
282 247
     room.addCommandListener(Commands.EMAIL, function (data) {
283 248
         APP.UI.setUserAvatar(data.attributes.id, data.value);
284 249
     });
285 250
 
251
+
252
+    room.on(ConferenceEvents.DISPLAY_NAME_CHANGED, function (id, displayName) {
253
+        APP.UI.changeDisplayName(id, displayName);
254
+    });
255
+    APP.UI.addListener(UIEvents.NICKNAME_CHANGED, function (nickname) {
256
+        APP.settings.setDisplayName(nickname);
257
+        room.setDisplayName(nickname);
258
+    });
259
+
260
+
261
+    APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
262
+        room.sendTextMessage(message);
263
+    });
264
+
265
+
266
+    room.on(ConferenceErrors.PASSWORD_REQUIRED, function () {
267
+        // FIXME handle
268
+    });
269
+    room.on(ConferenceErrors.CONNECTION_ERROR, function () {
270
+        // FIXME handle
271
+    });
272
+
273
+    APP.UI.addListener(
274
+        UIEvents.START_MUTED_CHANGED,
275
+        function (startAudioMuted, startVideoMuted) {
276
+            // FIXME start muted
277
+        }
278
+    );
279
+
286 280
     return new Promise(function (resolve, reject) {
287 281
         room.on(
288 282
             ConferenceEvents.CONFERENCE_JOINED,
289 283
             function () {
290
-                resolve(conf);
291
-            }
292
-        );
293
-        room.on(
294
-            ConferenceErrors.PASSWORD_REQUIRED,
295
-            function () {
296
-                // FIXME handle
297
-                reject();
298
-            }
299
-        );
300
-        room.on(
301
-            ConferenceErrors.CONNECTION_ERROR,
302
-            function () {
303
-                // FIXME handle
304
-                reject();
284
+                resolve();
305 285
             }
306 286
         );
307 287
         APP.UI.closeAuthenticationDialog();
@@ -310,45 +290,35 @@ function initConference(connection, roomName) {
310 290
             var nick = APP.UI.askForNickname();
311 291
         }
312 292
         room.join();
293
+    }).catch(function (err) {
294
+        if (err[0] === ConferenceErrors.PASSWORD_REQUIRED) {
295
+            // FIXME ask for password and try again
296
+            return initConference(connection, roomName);
297
+        }
298
+
299
+        // FIXME else notify that we cannot conenct to the room
300
+
301
+        throw new Error(err[0]);
313 302
     });
314 303
 }
315 304
 
316 305
 function init() {
317 306
     connect().then(function (connection) {
318 307
         return initConference(connection, APP.UI.generateRoomName());
319
-    }).then(function (conference) {
320
-        APP.conference = conference;
321
-
308
+    }).then(function () {
322 309
         APP.UI.start();
323 310
 
324
-        // FIXME find own jid
325
-        APP.UI.initConference("asdfasdf");
326
-
327
-        APP.UI.addListener(UIEvents.NICKNAME_CHANGED, function (nickname) {
328
-            APP.conference.setNickname(nickname);
329
-        });
330
-
331
-        APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
332
-            APP.conference.sendMessage(message);
333
-        });
311
+        APP.UI.initConference();
334 312
 
335 313
         APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
336 314
             APP.translation.setLanguage(language);
337 315
             APP.settings.setLanguage(language);
338 316
         });
339 317
 
340
-        APP.UI.addListener(
341
-            UIEvents.START_MUTED_CHANGED,
342
-            function (startAudioMuted, startVideoMuted) {
343
-                APP.conference.setStartMuted(startAudioMuted, startVideoMuted);
344
-            }
345
-        );
346
-
347 318
         APP.desktopsharing.init();
348 319
         APP.statistics.start();
349 320
         APP.connectionquality.init();
350 321
         APP.keyboardshortcut.init();
351
-        APP.members.start();
352 322
     });
353 323
 }
354 324
 
@@ -397,7 +367,7 @@ $(document).ready(function () {
397 367
 
398 368
     APP.translation.init();
399 369
 
400
-    if(APP.API.isEnabled()) {
370
+    if (APP.API.isEnabled()) {
401 371
         APP.API.init();
402 372
     }
403 373
 
@@ -405,8 +375,9 @@ $(document).ready(function () {
405 375
 });
406 376
 
407 377
 $(window).bind('beforeunload', function () {
408
-    if(APP.API.isEnabled())
378
+    if (APP.API.isEnabled()) {
409 379
         APP.API.dispose();
380
+    }
410 381
 });
411 382
 
412 383
 module.exports = APP;

+ 917
- 1057
lib-jitsi-meet.js
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 16
- 16
modules/UI/UI.js Ver fichero

@@ -27,10 +27,10 @@ var DesktopSharingEventTypes
27 27
     = require("../../service/desktopsharing/DesktopSharingEventTypes");
28 28
 var StatisticsEvents = require("../../service/statistics/Events");
29 29
 var UIEvents = require("../../service/UI/UIEvents");
30
-var MemberEvents = require("../../service/members/Events");
31 30
 var Feedback = require("./Feedback");
32 31
 
33 32
 var eventEmitter = new EventEmitter();
33
+UI.eventEmitter = eventEmitter;
34 34
 var roomNode = null;
35 35
 var roomName = null;
36 36
 
@@ -94,7 +94,7 @@ function setupChat() {
94 94
 }
95 95
 
96 96
 function setupToolbars() {
97
-    Toolbar.init(UI);
97
+    Toolbar.init(eventEmitter);
98 98
     Toolbar.setupButtonsFromConfig();
99 99
     BottomToolbar.init(eventEmitter);
100 100
 }
@@ -135,7 +135,8 @@ UI.changeDisplayName = function (id, displayName) {
135 135
     VideoLayout.onDisplayNameChanged(id, displayName);
136 136
 };
137 137
 
138
-UI.initConference = function (id) {
138
+UI.initConference = function () {
139
+    var id = APP.conference.localId;
139 140
     Toolbar.updateRoomUrl(window.location.href);
140 141
     var meHTML = APP.translation.generateTranslationHTML("me");
141 142
     var settings = Settings.getSettings();
@@ -172,21 +173,20 @@ function registerListeners() {
172 173
     });
173 174
 
174 175
     UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
175
-        UI.setUserAvatar(APP.conference.localId(), email);
176
+        UI.setUserAvatar(APP.conference.localId, email);
176 177
     });
177 178
 }
178 179
 
179
-function onResize() {
180
-    Chat.resizeChat();
181
-    VideoLayout.resizeLargeVideoContainer();
182
-}
183
-
184 180
 function bindEvents() {
185
-    /**
186
-     * Resizes and repositions videos in full screen mode.
187
-     */
188
-    $(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange',
189
-        onResize);
181
+    function onResize() {
182
+        Chat.resizeChat();
183
+        VideoLayout.resizeLargeVideoContainer();
184
+    }
185
+
186
+    // Resize and reposition videos in full screen mode.
187
+    $(document).on(
188
+        'webkitfullscreenchange mozfullscreenchange fullscreenchange', onResize
189
+    );
190 190
 
191 191
     $(window).resize(onResize);
192 192
 }
@@ -386,7 +386,7 @@ UI.addUser = function (jid, id, displayName) {
386 386
     );
387 387
 
388 388
     if (!config.startAudioMuted ||
389
-        config.startAudioMuted > APP.members.size())
389
+        config.startAudioMuted > APP.conference.membersCount)
390 390
         UIUtil.playSoundNotification('userJoined');
391 391
 
392 392
     // Configure avatar
@@ -404,7 +404,7 @@ UI.removeUser = function (jid) {
404 404
         'disconnected',
405 405
         'notify.disconnected');
406 406
     if (!config.startAudioMuted ||
407
-        config.startAudioMuted > APP.members.size()) {
407
+        config.startAudioMuted > APP.conference.membersCount) {
408 408
         UIUtil.playSoundNotification('userLeft');
409 409
     }
410 410
 

+ 3
- 5
modules/UI/audio_levels/AudioLevels.js Ver fichero

@@ -109,7 +109,7 @@ var AudioLevels = (function(my) {
109 109
         drawContext.drawImage(canvasCache, 0, 0);
110 110
 
111 111
         if(resourceJid === AudioLevels.LOCAL_LEVEL) {
112
-            resourceJid = APP.conference.localId();
112
+            resourceJid = APP.conference.localId;
113 113
             if (!resourceJid) {
114 114
                 return;
115 115
             }
@@ -223,11 +223,9 @@ var AudioLevels = (function(my) {
223 223
      */
224 224
     function getVideoSpanId(resourceJid) {
225 225
         var videoSpanId = null;
226
-        if (resourceJid === AudioLevels.LOCAL_LEVEL ||
227
-            (APP.conference.localId() && resourceJid === APP.conference.localId())) {
226
+        if (resourceJid === AudioLevels.LOCAL_LEVEL || APP.conference.isLocalId(resourceJid)) {
228 227
             videoSpanId = 'localVideoContainer';
229
-        }
230
-        else {
228
+        } else {
231 229
             videoSpanId = 'participant_' + resourceJid;
232 230
         }
233 231
 

+ 1
- 1
modules/UI/side_pannels/contactlist/ContactList.js Ver fichero

@@ -171,7 +171,7 @@ var ContactList = {
171 171
 
172 172
     onDisplayNameChange: function (id, displayName) {
173 173
         if (id === 'localVideoContainer') {
174
-            id = APP.conference.localId();
174
+            id = APP.conference.localId;
175 175
         }
176 176
         var contactName = $('#contacts #' + id + '>p');
177 177
 

+ 2
- 2
modules/UI/side_pannels/settings/SettingsMenu.js Ver fichero

@@ -36,7 +36,7 @@ var SettingsMenu = {
36 36
             }
37 37
         });
38 38
 
39
-        if (APP.conference.isModerator()) {
39
+        if (APP.conference.isModerator) {
40 40
             startMutedSelector.css("display", "block");
41 41
         } else {
42 42
             startMutedSelector.css("display", "none");
@@ -48,7 +48,7 @@ var SettingsMenu = {
48 48
     },
49 49
 
50 50
     onRoleChanged: function () {
51
-        if(APP.conference.isModerator()) {
51
+        if(APP.conference.isModerator) {
52 52
             $("#startMutedOptions").css("display", "block");
53 53
         }
54 54
         else {

+ 12
- 10
modules/UI/toolbars/Toolbar.js Ver fichero

@@ -1,5 +1,4 @@
1
-/* global APP, $, buttonClick, config, lockRoom, interfaceConfig, setSharedKey,
2
- Util */
1
+/* global APP, $, config, interfaceConfig */
3 2
 /* jshint -W101 */
4 3
 var messageHandler = require("../util/MessageHandler");
5 4
 var BottomToolbar = require("./BottomToolbar");
@@ -12,28 +11,31 @@ var AuthenticationEvents
12 11
     = require("../../../service/authentication/AuthenticationEvents");
13 12
 var AnalyticsAdapter = require("../../statistics/AnalyticsAdapter");
14 13
 var Feedback = require("../Feedback");
14
+var UIEvents = require("../../../service/UI/UIEvents");
15 15
 
16 16
 var roomUrl = null;
17 17
 var sharedKey = '';
18
-var UI = null;
19 18
 var recordingToaster = null;
19
+var emitter = null;
20 20
 
21 21
 var buttonHandlers = {
22 22
     "toolbar_button_mute": function () {
23 23
         if (APP.RTC.localAudio.isMuted()) {
24 24
             AnalyticsAdapter.sendEvent('toolbar.audio.unmuted');
25
+            emitter.emit(UIEvents.AUDIO_MUTED, false);
25 26
         } else {
26 27
             AnalyticsAdapter.sendEvent('toolbar.audio.muted');
28
+            emitter.emit(UIEvents.AUDIO_MUTED, true);
27 29
         }
28
-        return APP.conference.toggleAudioMuted();
29 30
     },
30 31
     "toolbar_button_camera": function () {
31 32
         if (APP.RTC.localVideo.isMuted()) {
32 33
             AnalyticsAdapter.sendEvent('toolbar.video.enabled');
34
+            emitter.emit(UIEvents.VIDEO_MUTED, false);
33 35
         } else {
34 36
             AnalyticsAdapter.sendEvent('toolbar.video.disabled');
37
+            emitter.emit(UIEvents.VIDEO_MUTED, true);
35 38
         }
36
-        return APP.conference.toggleVideoMuted();
37 39
     },
38 40
     /*"toolbar_button_authentication": function () {
39 41
         return Toolbar.authenticateClicked();
@@ -299,7 +301,7 @@ function callSipButtonClicked() {
299 301
                 var numberInput = f.sipNumber;
300 302
                 if (numberInput) {
301 303
                     APP.xmpp.dial(
302
-                        numberInput, 'fromnumber', UI.getRoomName(), sharedKey);
304
+                        numberInput, 'fromnumber', APP.UI.getRoomName(), sharedKey);
303 305
                 }
304 306
             }
305 307
         },
@@ -309,12 +311,12 @@ function callSipButtonClicked() {
309 311
 
310 312
 var Toolbar = (function (my) {
311 313
 
312
-    my.init = function (ui) {
314
+    my.init = function (eventEmitter) {
315
+        emitter = eventEmitter;
313 316
         UIUtil.hideDisabledButtons(defaultToolbarButtons);
314 317
 
315 318
         for(var k in buttonHandlers)
316 319
             $("#" + k).click(buttonHandlers[k]);
317
-        UI = ui;
318 320
         // Update login info
319 321
         APP.xmpp.addListener(
320 322
             AuthenticationEvents.IDENTITY_UPDATED,
@@ -353,12 +355,12 @@ var Toolbar = (function (my) {
353 355
         }
354 356
         // Get authentication URL
355 357
         if (!APP.xmpp.isMUCJoined()) {
356
-            APP.xmpp.getLoginUrl(UI.getRoomName(), function (url) {
358
+            APP.xmpp.getLoginUrl(APP.UI.getRoomName(), function (url) {
357 359
                 // If conference has not been started yet - redirect to login page
358 360
                 window.location.href = url;
359 361
             });
360 362
         } else {
361
-            APP.xmpp.getPopupLoginUrl(UI.getRoomName(), function (url) {
363
+            APP.xmpp.getPopupLoginUrl(APP.UI.getRoomName(), function (url) {
362 364
                 // Otherwise - open popup with authentication URL
363 365
                 var authenticationWindow = Authentication.createAuthenticationWindow(
364 366
                     function () {

+ 1
- 8
modules/UI/toolbars/ToolbarToggler.js Ver fichero

@@ -1,5 +1,4 @@
1
-/* global APP, config, $, interfaceConfig, Moderator,
2
- DesktopStreaming.showDesktopSharingButton */
1
+/* global APP, config, $, interfaceConfig */
3 2
 
4 3
 var toolbarTimeoutObject,
5 4
     toolbarTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT,
@@ -75,12 +74,6 @@ var ToolbarToggler = {
75 74
             toolbarTimeout = interfaceConfig.TOOLBAR_TIMEOUT;
76 75
         }
77 76
 
78
-        if (APP.conference.isModerator()) {
79
-//            TODO: Enable settings functionality.
80
-//                  Need to uncomment the settings button in index.html.
81
-//            $('#settingsButton').css({visibility:"visible"});
82
-        }
83
-
84 77
         // Show/hide desktop sharing button
85 78
         showDesktopSharingButton();
86 79
     },

+ 0
- 3
modules/UI/videolayout/VideoLayout.js Ver fichero

@@ -56,9 +56,6 @@ var VideoLayout = (function (my) {
56 56
     };
57 57
 
58 58
     my.changeLocalAudio = function(stream, isMuted) {
59
-        if (isMuted) { // FIXME remove this?
60
-            APP.conference.muteAudio(true);
61
-        }
62 59
         APP.RTC.attachMediaStream($('#localAudio'), stream.getOriginalStream());
63 60
         var localAudio = document.getElementById('localAudio');
64 61
         // Writing volume not allowed in IE

+ 2
- 6
modules/keyboardshortcut/keyboardshortcut.js Ver fichero

@@ -26,9 +26,7 @@ function initShortcutHandlers() {
26 26
         84: {
27 27
             character: "T",
28 28
             function: function() {
29
-                if(!APP.RTC.localAudio.isMuted()) {
30
-                    APP.conference.toggleAudioMuted();
31
-                }
29
+                APP.conference.muteAudio(true);
32 30
             }
33 31
         },
34 32
         86: {
@@ -67,9 +65,7 @@ var KeyboardShortcut = {
67 65
                 $(":focus").is("input[type=password]") ||
68 66
                 $(":focus").is("textarea"))) {
69 67
                 if(e.which === "T".charCodeAt(0)) {
70
-                    if(APP.RTC.localAudio.isMuted()) {
71
-                        APP.conference.toggleAudioMuted();
72
-                    }
68
+                    APP.conference.muteAudio(true);
73 69
                 }
74 70
             }
75 71
         };

+ 0
- 128
modules/members/MemberList.js Ver fichero

@@ -1,128 +0,0 @@
1
-/* global APP, require, $ */
2
-
3
-/**
4
- * This module is meant to (eventually) contain and manage all information
5
- * about members/participants of the conference, so that other modules don't
6
- * have to do it on their own, and so that other modules can access members'
7
- * information from a single place.
8
- *
9
- * Currently this module only manages information about the support of jingle
10
- * DTMF of the members. Other fields, as well as accessor methods are meant to
11
- * be added as needed.
12
- */
13
-
14
-var XMPPEvents = require("../../service/xmpp/XMPPEvents");
15
-var Events = require("../../service/members/Events");
16
-var EventEmitter = require("events");
17
-
18
-var eventEmitter = new EventEmitter();
19
-
20
-/**
21
- * The actual container.
22
- */
23
-var members = {};
24
-
25
-/**
26
- * There is at least one member that supports DTMF (i.e. is jigasi).
27
- */
28
-var atLeastOneDtmf = false;
29
-
30
-
31
-function registerListeners() {
32
-    APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_JOINED, onMucMemberJoined);
33
-    APP.xmpp.addListener(XMPPEvents.MUC_MEMBER_LEFT, onMucMemberLeft);
34
-}
35
-
36
-/**
37
- * Handles a new member joining the MUC.
38
- */
39
-function onMucMemberJoined(jid, id, displayName) {
40
-    var member = {
41
-        displayName: displayName
42
-    };
43
-
44
-    APP.xmpp.getConnection().disco.info(
45
-        jid, "" /* node */, function(iq) { onDiscoInfoReceived(jid, iq); });
46
-
47
-    members[jid] = member;
48
-}
49
-
50
-/**
51
- * Handles a member leaving the MUC.
52
- */
53
-function onMucMemberLeft(jid) {
54
-    delete members[jid];
55
-    updateAtLeastOneDtmf();
56
-}
57
-
58
-/**
59
- * Handles the reception of a disco#info packet from a particular JID.
60
- * @param jid the JID sending the packet.
61
- * @param iq the packet.
62
- */
63
-function onDiscoInfoReceived(jid, iq) {
64
-    if (!members[jid])
65
-        return;
66
-
67
-    var supportsDtmf
68
-        = $(iq).find('>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
69
-    updateDtmf(jid, supportsDtmf);
70
-}
71
-
72
-/**
73
- * Updates the 'supportsDtmf' field for a member.
74
- * @param jid the jid of the member.
75
- * @param newValue the new value for the 'supportsDtmf' field.
76
- */
77
-function updateDtmf(jid, newValue) {
78
-    var oldValue = members[jid].supportsDtmf;
79
-    members[jid].supportsDtmf = newValue;
80
-
81
-    if (newValue != oldValue) {
82
-        updateAtLeastOneDtmf();
83
-    }
84
-}
85
-
86
-/**
87
- * Checks each member's 'supportsDtmf' field and updates
88
- * 'atLastOneSupportsDtmf'.
89
- */
90
-function updateAtLeastOneDtmf() {
91
-    var newAtLeastOneDtmf = false;
92
-    for (var key in members) {
93
-        if (typeof members[key].supportsDtmf !== 'undefined'
94
-            && members[key].supportsDtmf) {
95
-            newAtLeastOneDtmf= true;
96
-            break;
97
-        }
98
-    }
99
-
100
-    if (atLeastOneDtmf != newAtLeastOneDtmf) {
101
-        atLeastOneDtmf = newAtLeastOneDtmf;
102
-        eventEmitter.emit(Events.DTMF_SUPPORT_CHANGED, atLeastOneDtmf);
103
-    }
104
-}
105
-
106
-
107
-/**
108
- * Exported interface.
109
- */
110
-var Members = {
111
-    start: function() {
112
-        registerListeners();
113
-    },
114
-    addListener: function(type, listener) {
115
-        eventEmitter.on(type, listener);
116
-    },
117
-    removeListener: function (type, listener) {
118
-        eventEmitter.removeListener(type, listener);
119
-    },
120
-    size: function () {
121
-        return Object.keys(members).length;
122
-    },
123
-    getMembers: function () {
124
-        return members;
125
-    }
126
-};
127
-
128
-module.exports = Members;

+ 2
- 0
service/UI/UIEvents.js Ver fichero

@@ -19,6 +19,8 @@ var UIEvents = {
19 19
      * Notifies that "start muted" settings changed.
20 20
      */
21 21
     START_MUTED_CHANGED: "UI.start_muted_changed",
22
+    AUDIO_MUTED: "UI.audio_muted",
23
+    VIDEO_MUTED: "UI.video_muted",
22 24
     /**
23 25
      * Notifies interested parties when the film strip (remote video's panel)
24 26
      * is hidden (toggled) or shown (un-toggled).

+ 0
- 5
service/members/Events.js Ver fichero

@@ -1,5 +0,0 @@
1
-var Events = {
2
-    DTMF_SUPPORT_CHANGED: "members.dtmf_support_changed"
3
-};
4
-
5
-module.exports = Events;

Loading…
Cancelar
Guardar