Browse Source

feat(base/conference): CONFERENCE_FAILED on CONNECTION_FAILED

Emits CONFERENCE_FAILED in response to CONNECTION_FAILED event
which then triggers JitsiConference.leave() through the middleware
processing. Also base/conference state will be adjusted. It is to have
a consistent redux state in which both connection and conference are
failed. It could happen that in a buggy environment the XMPP connection
is dropped, but the media is still flowing which would result in weird
user experience.
j8
paweldomas 6 years ago
parent
commit
57b302da3e

+ 2
- 1
react/features/base/conference/actions.js View File

@@ -199,7 +199,8 @@ export function conferenceFailed(conference: Object, error: string) {
199 199
         // Make the error resemble an Error instance (to the extent that
200 200
         // jitsi-meet needs it).
201 201
         error: {
202
-            name: error
202
+            name: error,
203
+            recoverable: undefined
203 204
         }
204 205
     };
205 206
 }

+ 61
- 1
react/features/base/conference/middleware.js View File

@@ -7,7 +7,7 @@ import {
7 7
     createPinnedEvent,
8 8
     sendAnalytics
9 9
 } from '../../analytics';
10
-import { CONNECTION_ESTABLISHED } from '../connection';
10
+import { CONNECTION_ESTABLISHED, CONNECTION_FAILED } from '../connection';
11 11
 import { setVideoMuted, VIDEO_MUTISM_AUTHORITY } from '../media';
12 12
 import {
13 13
     getLocalParticipant,
@@ -20,6 +20,7 @@ import UIEvents from '../../../../service/UI/UIEvents';
20 20
 import { TRACK_ADDED, TRACK_REMOVED } from '../tracks';
21 21
 
22 22
 import {
23
+    conferenceFailed,
23 24
     conferenceLeft,
24 25
     createConference,
25 26
     setLastN,
@@ -62,6 +63,9 @@ MiddlewareRegistry.register(store => next => action => {
62 63
     case CONNECTION_ESTABLISHED:
63 64
         return _connectionEstablished(store, next, action);
64 65
 
66
+    case CONNECTION_FAILED:
67
+        return _connectionFailed(store, next, action);
68
+
65 69
     case DATA_CHANNEL_OPENED:
66 70
         return _syncReceiveVideoQuality(store, next, action);
67 71
 
@@ -168,6 +172,62 @@ function _connectionEstablished({ dispatch }, next, action) {
168 172
     return result;
169 173
 }
170 174
 
175
+/**
176
+ * Notifies the feature base/conference that the action
177
+ * {@code CONNECTION_FAILED} is being dispatched within a specific redux
178
+ * store.
179
+ *
180
+ * @param {Store} store - The redux store in which the specified {@code action}
181
+ * is being dispatched.
182
+ * @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
183
+ * specified {@code action} to the specified {@code store}.
184
+ * @param {Action} action - The redux action {@code CONNECTION_FAILED} which is
185
+ * being dispatched in the specified {@code store}.
186
+ * @private
187
+ * @returns {Object} The value returned by {@code next(action)}.
188
+ */
189
+function _connectionFailed({ dispatch, getState }, next, action) {
190
+    const result = next(action);
191
+
192
+    // FIXME: Workaround for the web version. Currently, the creation of the
193
+    // conference is handled by /conference.js and appropriate failure handlers
194
+    // are set there.
195
+    if (typeof APP === 'undefined') {
196
+        const { connection } = action;
197
+        const { error } = action;
198
+
199
+        forEachConference(getState, conference => {
200
+            // It feels that it would make things easier if JitsiConference
201
+            // in lib-jitsi-meet would monitor it's connection and emit
202
+            // CONFERENCE_FAILED when it's dropped. It has more knowledge on
203
+            // whether it can recover or not. But because the reload screen
204
+            // and the retry logic is implemented in the app maybe it can be
205
+            // left this way for now.
206
+            if (conference.getConnection() === connection) {
207
+                // XXX Note that on mobile the error type passed to
208
+                // connectionFailed is always an object with .name property.
209
+                // This fact needs to be checked prior to enabling this logic on
210
+                // web.
211
+                const conferenceAction
212
+                    = conferenceFailed(conference, error.name);
213
+
214
+                // Copy the recoverable flag if set on the CONNECTION_FAILED
215
+                // action to not emit recoverable action caused by
216
+                // a non-recoverable one.
217
+                if (typeof error.recoverable !== 'undefined') {
218
+                    conferenceAction.error.recoverable = error.recoverable;
219
+                }
220
+
221
+                dispatch(conferenceAction);
222
+            }
223
+
224
+            return true;
225
+        });
226
+    }
227
+
228
+    return result;
229
+}
230
+
171 231
 /**
172 232
  * Notifies the feature base/conference that the action {@code PIN_PARTICIPANT}
173 233
  * is being dispatched within a specific redux store. Pins the specified remote

Loading…
Cancel
Save