Pārlūkot izejas kodu

properly generate room name

master
isymchych 10 gadus atpakaļ
vecāks
revīzija
586988f327

+ 56
- 21
app.js Parādīt failu

2
 /* application specific logic */
2
 /* application specific logic */
3
 
3
 
4
 import "babel-polyfill";
4
 import "babel-polyfill";
5
-require("jquery");
6
-require("jquery-ui");
7
-require("strophe");
8
-require("strophe-disco");
9
-require("strophe-caps");
10
-require("tooltip");
11
-require("popover");
5
+import "jquery";
6
+import "jquery-ui";
7
+import "strophe";
8
+import "strophe-disco";
9
+import "strophe-caps";
10
+import "tooltip";
11
+import "popover";
12
+import "jQuery-Impromptu";
13
+import "autosize";
12
 window.toastr = require("toastr");
14
 window.toastr = require("toastr");
13
-require("jQuery-Impromptu");
14
-require("autosize");
15
 
15
 
16
-var CQEvents = require('./service/connectionquality/CQEvents');
17
-var UIEvents = require('./service/UI/UIEvents');
16
+import RoomnameGenerator from './modules/util/RoomnameGenerator';
17
+import CQEvents from './service/connectionquality/CQEvents';
18
+import UIEvents from './service/UI/UIEvents';
18
 
19
 
19
-var Commands = {
20
+const Commands = {
20
     CONNECTION_QUALITY: "connectionQuality",
21
     CONNECTION_QUALITY: "connectionQuality",
21
     EMAIL: "email"
22
     EMAIL: "email"
22
 };
23
 };
23
 
24
 
24
-var APP = {
25
-    init: function () {
25
+function buildRoomName () {
26
+    let path = window.location.pathname;
27
+    let roomName;
28
+
29
+    // determinde the room node from the url
30
+    // TODO: just the roomnode or the whole bare jid?
31
+    if (config.getroomnode && typeof config.getroomnode === 'function') {
32
+        // custom function might be responsible for doing the pushstate
33
+        roomName = config.getroomnode(path);
34
+    } else {
35
+        /* fall back to default strategy
36
+         * this is making assumptions about how the URL->room mapping happens.
37
+         * It currently assumes deployment at root, with a rewrite like the
38
+         * following one (for nginx):
39
+         location ~ ^/([a-zA-Z0-9]+)$ {
40
+         rewrite ^/(.*)$ / break;
41
+         }
42
+         */
43
+        if (path.length > 1) {
44
+            roomName = path.substr(1).toLowerCase();
45
+        } else {
46
+            let word = RoomnameGenerator.generateRoomWithoutSeparator();
47
+            roomName = word.toLowerCase();
48
+            window.history.pushState(
49
+                'VideoChat', 'Room: ' + word, window.location.pathname + word
50
+            );
51
+        }
52
+    }
53
+
54
+    return roomName;
55
+}
56
+
57
+const APP = {
58
+    init () {
26
         JitsiMeetJS.init();
59
         JitsiMeetJS.init();
27
         JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
60
         JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
28
 
61
 
62
+        let roomName = buildRoomName();
29
         this.conference = {
63
         this.conference = {
64
+            roomName,
30
             localId: undefined,
65
             localId: undefined,
31
             isModerator: false,
66
             isModerator: false,
32
             membersCount: 0,
67
             membersCount: 0,
33
             audioMuted: false,
68
             audioMuted: false,
34
             videoMuted: false,
69
             videoMuted: false,
35
-            isLocalId: function (id) {
70
+            isLocalId (id) {
36
                 return this.localId === id;
71
                 return this.localId === id;
37
             },
72
             },
38
-            muteAudio: function (mute) {
73
+            muteAudio (mute) {
39
                 APP.UI.eventEmitter.emit(UIEvents.AUDIO_MUTED, mute);
74
                 APP.UI.eventEmitter.emit(UIEvents.AUDIO_MUTED, mute);
40
             },
75
             },
41
-            toggleAudioMuted: function () {
76
+            toggleAudioMuted () {
42
                 this.muteAudio(!this.audioMuted);
77
                 this.muteAudio(!this.audioMuted);
43
             },
78
             },
44
-            muteVideo: function (mute) {
79
+            muteVideo (mute) {
45
                 APP.UI.eventEmitter.emit(UIEvents.VIDEO_MUTED, mute);
80
                 APP.UI.eventEmitter.emit(UIEvents.VIDEO_MUTED, mute);
46
             },
81
             },
47
-            toggleVideoMuted: function () {
82
+            toggleVideoMuted () {
48
                 this.muteVideo(!this.videoMuted);
83
                 this.muteVideo(!this.videoMuted);
49
             }
84
             }
50
         };
85
         };
315
 
350
 
316
 function init() {
351
 function init() {
317
     connect().then(function (connection) {
352
     connect().then(function (connection) {
318
-        return initConference(connection, APP.UI.generateRoomName());
353
+        return initConference(connection, APP.conference.roomName);
319
     }).then(function () {
354
     }).then(function () {
320
         APP.UI.start();
355
         APP.UI.start();
321
 
356
 
342
  * will be displayed to the user.
377
  * will be displayed to the user.
343
  */
378
  */
344
 function obtainConfigAndInit() {
379
 function obtainConfigAndInit() {
345
-    var roomName = APP.UI.getRoomNode();
380
+    let roomName = APP.conference.roomName;
346
 
381
 
347
     if (config.configLocation) {
382
     if (config.configLocation) {
348
         APP.configFetch.obtainConfig(
383
         APP.configFetch.obtainConfig(

+ 1
- 49
modules/UI/UI.js Parādīt failu

16
 var SettingsMenu = require("./side_pannels/settings/SettingsMenu");
16
 var SettingsMenu = require("./side_pannels/settings/SettingsMenu");
17
 var Settings = require("./../settings/Settings");
17
 var Settings = require("./../settings/Settings");
18
 var PanelToggler = require("./side_pannels/SidePanelToggler");
18
 var PanelToggler = require("./side_pannels/SidePanelToggler");
19
-var RoomnameGenerator = require("../util/RoomnameGenerator");
20
 UI.messageHandler = require("./util/MessageHandler");
19
 UI.messageHandler = require("./util/MessageHandler");
21
 var messageHandler = UI.messageHandler;
20
 var messageHandler = UI.messageHandler;
22
 var Authentication  = require("./authentication/Authentication");
21
 var Authentication  = require("./authentication/Authentication");
31
 
30
 
32
 var eventEmitter = new EventEmitter();
31
 var eventEmitter = new EventEmitter();
33
 UI.eventEmitter = eventEmitter;
32
 UI.eventEmitter = eventEmitter;
34
-var roomNode = null;
35
-var roomName = null;
36
-
37
 
33
 
38
 function promptDisplayName() {
34
 function promptDisplayName() {
39
     var message = '<h2 data-i18n="dialog.displayNameRequired">';
35
     var message = '<h2 data-i18n="dialog.displayNameRequired">';
438
 
434
 
439
 UI.notifyAuthRequired = function (intervalCallback) {
435
 UI.notifyAuthRequired = function (intervalCallback) {
440
     Authentication.openAuthenticationDialog(
436
     Authentication.openAuthenticationDialog(
441
-        roomName, intervalCallback, function () {
437
+        APP.conference.roomName, intervalCallback, function () {
442
             Toolbar.authenticateClicked();
438
             Toolbar.authenticateClicked();
443
         }
439
         }
444
     );
440
     );
478
     return VideoLayout.getRemoteVideoType(jid);
474
     return VideoLayout.getRemoteVideoType(jid);
479
 };
475
 };
480
 
476
 
481
-UI.getRoomNode = function () {
482
-    if (roomNode)
483
-        return roomNode;
484
-    var path = window.location.pathname;
485
-
486
-    // determinde the room node from the url
487
-    // TODO: just the roomnode or the whole bare jid?
488
-    if (config.getroomnode && typeof config.getroomnode === 'function') {
489
-        // custom function might be responsible for doing the pushstate
490
-        roomNode = config.getroomnode(path);
491
-    } else {
492
-        /* fall back to default strategy
493
-         * this is making assumptions about how the URL->room mapping happens.
494
-         * It currently assumes deployment at root, with a rewrite like the
495
-         * following one (for nginx):
496
-         location ~ ^/([a-zA-Z0-9]+)$ {
497
-         rewrite ^/(.*)$ / break;
498
-         }
499
-         */
500
-        if (path.length > 1) {
501
-            roomNode = path.substr(1).toLowerCase();
502
-        } else {
503
-            var word = RoomnameGenerator.generateRoomWithoutSeparator();
504
-            roomNode = word.toLowerCase();
505
-            window.history.pushState('VideoChat',
506
-                'Room: ' + word, window.location.pathname + word);
507
-        }
508
-    }
509
-    return roomNode;
510
-};
511
-
512
-UI.generateRoomName = function () {
513
-    if (roomName)
514
-        return roomName;
515
-    var roomNode = UI.getRoomNode();
516
-    roomName = roomNode + '@' + config.hosts.muc;
517
-    return roomName;
518
-};
519
-
520
-
521
 UI.connectionIndicatorShowMore = function(jid) {
477
 UI.connectionIndicatorShowMore = function(jid) {
522
     return VideoLayout.showMore(jid);
478
     return VideoLayout.showMore(jid);
523
 };
479
 };
557
     return window.prompt('Your nickname (optional)');
513
     return window.prompt('Your nickname (optional)');
558
 };
514
 };
559
 
515
 
560
-UI.getRoomName = function () {
561
-    return roomName;
562
-};
563
-
564
 /**
516
 /**
565
  * Sets muted audio state for the local participant.
517
  * Sets muted audio state for the local participant.
566
  */
518
  */

+ 1
- 1
modules/UI/authentication/Authentication.js Parādīt failu

75
                     // the request.
75
                     // the request.
76
                     connection.disconnect();
76
                     connection.disconnect();
77
 
77
 
78
-                    var roomName = APP.UI.generateRoomName();
78
+                    var roomName = APP.conference.roomName;
79
                     Moderator.allocateConferenceFocus(roomName, function () {
79
                     Moderator.allocateConferenceFocus(roomName, function () {
80
                         // If it's not "on the fly" authentication now join
80
                         // If it's not "on the fly" authentication now join
81
                         // the conference room
81
                         // the conference room

+ 1
- 1
modules/UI/authentication/LoginDialog.js Parādīt failu

135
                         'connection.FETCH_SESSION_ID'));
135
                         'connection.FETCH_SESSION_ID'));
136
 
136
 
137
                 // Authenticate with Jicofo and obtain session-id
137
                 // Authenticate with Jicofo and obtain session-id
138
-                var roomName = APP.UI.generateRoomName();
138
+                var roomName = APP.conference.roomName;
139
 
139
 
140
                 // Jicofo will return new session-id when connected
140
                 // Jicofo will return new session-id when connected
141
                 // from authenticated domain
141
                 // from authenticated domain

+ 4
- 4
modules/UI/toolbars/Toolbar.js Parādīt failu

301
                 var numberInput = f.sipNumber;
301
                 var numberInput = f.sipNumber;
302
                 if (numberInput) {
302
                 if (numberInput) {
303
                     APP.xmpp.dial(
303
                     APP.xmpp.dial(
304
-                        numberInput, 'fromnumber', APP.UI.getRoomName(), sharedKey);
304
+                        numberInput, 'fromnumber', APP.conference.roomName, sharedKey);
305
                 }
305
                 }
306
             }
306
             }
307
         },
307
         },
355
         }
355
         }
356
         // Get authentication URL
356
         // Get authentication URL
357
         if (!APP.xmpp.isMUCJoined()) {
357
         if (!APP.xmpp.isMUCJoined()) {
358
-            APP.xmpp.getLoginUrl(APP.UI.getRoomName(), function (url) {
358
+            APP.xmpp.getLoginUrl(APP.conference.roomName, function (url) {
359
                 // If conference has not been started yet - redirect to login page
359
                 // If conference has not been started yet - redirect to login page
360
                 window.location.href = url;
360
                 window.location.href = url;
361
             });
361
             });
362
         } else {
362
         } else {
363
-            APP.xmpp.getPopupLoginUrl(APP.UI.getRoomName(), function (url) {
363
+            APP.xmpp.getPopupLoginUrl(APP.conference.roomName, function (url) {
364
                 // Otherwise - open popup with authentication URL
364
                 // Otherwise - open popup with authentication URL
365
                 var authenticationWindow = Authentication.createAuthenticationWindow(
365
                 var authenticationWindow = Authentication.createAuthenticationWindow(
366
                     function () {
366
                     function () {
367
                         // On popup closed - retry room allocation
367
                         // On popup closed - retry room allocation
368
                         APP.xmpp.allocateConferenceFocus(
368
                         APP.xmpp.allocateConferenceFocus(
369
-                            APP.UI.getRoomName(),
369
+                            APP.conference.roomName,
370
                             function () { console.info("AUTH DONE"); }
370
                             function () { console.info("AUTH DONE"); }
371
                         );
371
                         );
372
                     }, url);
372
                     }, url);

Notiek ielāde…
Atcelt
Saglabāt