ソースを参照

[RN] Load config.js with ?room=

In order to load the configuration from the shard that will actually
host the conference, it's imperative that we add the room= query
parameter:

https://meet.jit.si/config.js?room=example

This implies a departure from our current model, where the config is
discarded if the domain for the next conference is different, but kept
otherwise.
master
Lyubo Marinov 8年前
コミット
ec9c05e401
2個のファイルの変更22行の追加45行の削除
  1. 18
    40
      react/features/app/actions.js
  2. 4
    5
      react/features/base/lib-jitsi-meet/functions.js

+ 18
- 40
react/features/app/actions.js ファイルの表示

@@ -39,22 +39,11 @@ export function appNavigate(uri: ?string) {
39 39
 function _appNavigateToMandatoryLocation(
40 40
         dispatch: Dispatch<*>, getState: Function,
41 41
         newLocation: Object) {
42
-    const oldLocationURL = getState()['features/base/connection'].locationURL;
43
-    const oldHost = oldLocationURL ? oldLocationURL.host : undefined;
44
-    const newHost = newLocation.host;
45
-
46
-    if (oldHost === newHost) {
47
-        dispatchSetLocationURL()
48
-            .then(dispatchSetRoom);
49
-    } else {
50
-        // If the host has changed, we need to load the config of the new host
51
-        // and set it, and only after that we can navigate to a different route.
52
-        _loadConfig(newLocation)
53
-            .then(
54
-                config => configLoaded(/* err */ undefined, config),
55
-                err => configLoaded(err, /* config */ undefined))
56
-            .then(dispatchSetRoom);
57
-    }
42
+    _loadConfig(newLocation)
43
+        .then(
44
+            config => configLoaded(/* err */ undefined, config),
45
+            err => configLoaded(err, /* config */ undefined))
46
+        .then(() => dispatch(setRoom(newLocation.room)));
58 47
 
59 48
     /**
60 49
      * Notifies that an attempt to load a config(uration) has completed. Due to
@@ -83,27 +72,9 @@ function _appNavigateToMandatoryLocation(
83 72
         }
84 73
 
85 74
         return (
86
-            dispatchSetLocationURL()
75
+            dispatch(setLocationURL(new URL(newLocation.toString())))
87 76
                 .then(() => dispatch(setConfig(config))));
88 77
     }
89
-
90
-    /**
91
-     * Dispatches {@link setLocationURL} in the redux store.
92
-     *
93
-     * @returns {void}
94
-     */
95
-    function dispatchSetLocationURL() {
96
-        return dispatch(setLocationURL(new URL(newLocation.toString())));
97
-    }
98
-
99
-    /**
100
-     * Dispatches {@link _setRoomAndNavigate} in the redux store.
101
-     *
102
-     * @returns {void}
103
-     */
104
-    function dispatchSetRoom() {
105
-        return dispatch(setRoom(newLocation.room));
106
-    }
107 78
 }
108 79
 
109 80
 /**
@@ -196,8 +167,10 @@ export function appWillUnmount(app) {
196 167
  * @private
197 168
  * @returns {Promise<Object>}
198 169
  */
199
-function _loadConfig(location: Object) {
200
-    let protocol = location.protocol.toLowerCase();
170
+function _loadConfig({ contextRoot, host, protocol, room }) {
171
+    /* eslint-disable no-param-reassign */
172
+
173
+    protocol = protocol.toLowerCase();
201 174
 
202 175
     // The React Native app supports an app-specific scheme which is sure to not
203 176
     // be supported by fetch (or whatever loadConfig utilizes).
@@ -205,7 +178,12 @@ function _loadConfig(location: Object) {
205 178
 
206 179
     // TDOO userinfo
207 180
 
208
-    return (
209
-        loadConfig(
210
-            `${protocol}//${location.host}${location.contextRoot || '/'}`));
181
+    let url = `${protocol}//${host}${contextRoot || '/'}config.js`;
182
+
183
+    // XXX In order to support multiple shards, tell the room to the deployment.
184
+    room && (url += `?room=${room.toLowerCase()}`);
185
+
186
+    /* eslint-enable no-param-reassign */
187
+
188
+    return loadConfig(url);
211 189
 }

+ 4
- 5
react/features/base/lib-jitsi-meet/functions.js ファイルの表示

@@ -54,16 +54,15 @@ export function isFatalJitsiConnectionError(error: string) {
54 54
 /**
55 55
  * Loads config.js from a specific remote server.
56 56
  *
57
- * @param {string} host - Host where config.js is hosted.
58
- * @param {string} path='config.js' - Relative pah to config.js file.
57
+ * @param {string} url - The URL to load.
59 58
  * @returns {Promise<Object>}
60 59
  */
61
-export function loadConfig(host: string, path: string = 'config.js') {
60
+export function loadConfig(url: string) {
62 61
     let promise;
63 62
 
64 63
     if (typeof APP === 'undefined') {
65 64
         promise
66
-            = loadScript(new URL(path, host).toString())
65
+            = loadScript(url)
67 66
                 .then(() => {
68 67
                     const { config } = window;
69 68
 
@@ -77,7 +76,7 @@ export function loadConfig(host: string, path: string = 'config.js') {
77 76
                     return config;
78 77
                 })
79 78
                 .catch(err => {
80
-                    console.error(`Failed to load ${path} from ${host}`, err);
79
+                    console.error(`Failed to load config from ${url}`, err);
81 80
 
82 81
                     throw err;
83 82
                 });

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