浏览代码

[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.
j8
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
 function _appNavigateToMandatoryLocation(
39
 function _appNavigateToMandatoryLocation(
40
         dispatch: Dispatch<*>, getState: Function,
40
         dispatch: Dispatch<*>, getState: Function,
41
         newLocation: Object) {
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
      * Notifies that an attempt to load a config(uration) has completed. Due to
49
      * Notifies that an attempt to load a config(uration) has completed. Due to
83
         }
72
         }
84
 
73
 
85
         return (
74
         return (
86
-            dispatchSetLocationURL()
75
+            dispatch(setLocationURL(new URL(newLocation.toString())))
87
                 .then(() => dispatch(setConfig(config))));
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
  * @private
167
  * @private
197
  * @returns {Promise<Object>}
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
     // The React Native app supports an app-specific scheme which is sure to not
175
     // The React Native app supports an app-specific scheme which is sure to not
203
     // be supported by fetch (or whatever loadConfig utilizes).
176
     // be supported by fetch (or whatever loadConfig utilizes).
205
 
178
 
206
     // TDOO userinfo
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
 /**
54
 /**
55
  * Loads config.js from a specific remote server.
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
  * @returns {Promise<Object>}
58
  * @returns {Promise<Object>}
60
  */
59
  */
61
-export function loadConfig(host: string, path: string = 'config.js') {
60
+export function loadConfig(url: string) {
62
     let promise;
61
     let promise;
63
 
62
 
64
     if (typeof APP === 'undefined') {
63
     if (typeof APP === 'undefined') {
65
         promise
64
         promise
66
-            = loadScript(new URL(path, host).toString())
65
+            = loadScript(url)
67
                 .then(() => {
66
                 .then(() => {
68
                     const { config } = window;
67
                     const { config } = window;
69
 
68
 
77
                     return config;
76
                     return config;
78
                 })
77
                 })
79
                 .catch(err => {
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
                     throw err;
81
                     throw err;
83
                 });
82
                 });

正在加载...
取消
保存