Browse Source

ref(external API): emit CONFERENCE_FAILED on CONNECTION_FAILED

It seems that the external API will not send any event to let the sdk
consumer know that the conference has failed if the problem occurs at
the establishing of XMPP connection stage. That's because the config was
loaded successfully, but the conference instance does not exist yet, so
neither base/config nor base/conference will emit any failure.
master
paweldomas 7 years ago
parent
commit
82f5eb894b
1 changed files with 27 additions and 0 deletions
  1. 27
    0
      react/features/mobile/external-api/middleware.js

+ 27
- 0
react/features/mobile/external-api/middleware.js View File

13
     isRoomValid
13
     isRoomValid
14
 } from '../../base/conference';
14
 } from '../../base/conference';
15
 import { LOAD_CONFIG_ERROR } from '../../base/config';
15
 import { LOAD_CONFIG_ERROR } from '../../base/config';
16
+import { CONNECTION_FAILED } from '../../base/connection';
16
 import { MiddlewareRegistry } from '../../base/redux';
17
 import { MiddlewareRegistry } from '../../base/redux';
17
 import { toURLString } from '../../base/util';
18
 import { toURLString } from '../../base/util';
18
 import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
19
 import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
56
         _sendConferenceEvent(store, action);
57
         _sendConferenceEvent(store, action);
57
         break;
58
         break;
58
 
59
 
60
+    case CONNECTION_FAILED:
61
+        _sendConferenceFailedOnConnectionError(store, action);
62
+        break;
63
+
59
     case ENTER_PICTURE_IN_PICTURE:
64
     case ENTER_PICTURE_IN_PICTURE:
60
         _sendEvent(store, _getSymbolDescription(action.type), /* data */ {});
65
         _sendEvent(store, _getSymbolDescription(action.type), /* data */ {});
61
         break;
66
         break;
175
         || _sendEvent(store, _getSymbolDescription(type), data);
180
         || _sendEvent(store, _getSymbolDescription(type), data);
176
 }
181
 }
177
 
182
 
183
+/**
184
+ * Sends {@link CONFERENCE_FAILED} event when the {@link CONNECTION_FAILED}
185
+ * occurs. Otherwise the external API will not emit such event, because at this
186
+ * point conference has not been created yet and the base/conference feature
187
+ * will not emit it.
188
+ *
189
+ * @param {Store} store - The redux store.
190
+ * @param {Action} action - The redux action.
191
+ * @returns {void}
192
+ */
193
+function _sendConferenceFailedOnConnectionError(store, action) {
194
+    const { locationURL } = store.getState()['features/base/connection'];
195
+
196
+    locationURL && _sendEvent(
197
+        store,
198
+        _getSymbolDescription(CONFERENCE_FAILED),
199
+        /* data */ {
200
+            url: toURLString(locationURL),
201
+            error: action.error.name
202
+        });
203
+}
204
+
178
 /**
205
 /**
179
  * Sends a specific event to the native counterpart of the External API. Native
206
  * Sends a specific event to the native counterpart of the External API. Native
180
  * apps may listen to such events via the mechanisms provided by the (native)
207
  * apps may listen to such events via the mechanisms provided by the (native)

Loading…
Cancel
Save