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.
This commit is contained in:
paweldomas 2018-04-25 18:10:13 -05:00 committed by Saúl Ibarra Corretgé
parent 91a65735f9
commit 82f5eb894b
1 changed files with 27 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import {
isRoomValid
} from '../../base/conference';
import { LOAD_CONFIG_ERROR } from '../../base/config';
import { CONNECTION_FAILED } from '../../base/connection';
import { MiddlewareRegistry } from '../../base/redux';
import { toURLString } from '../../base/util';
import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
@ -56,6 +57,10 @@ MiddlewareRegistry.register(store => next => action => {
_sendConferenceEvent(store, action);
break;
case CONNECTION_FAILED:
_sendConferenceFailedOnConnectionError(store, action);
break;
case ENTER_PICTURE_IN_PICTURE:
_sendEvent(store, _getSymbolDescription(action.type), /* data */ {});
break;
@ -175,6 +180,28 @@ function _sendConferenceEvent(
|| _sendEvent(store, _getSymbolDescription(type), data);
}
/**
* Sends {@link CONFERENCE_FAILED} event when the {@link CONNECTION_FAILED}
* occurs. Otherwise the external API will not emit such event, because at this
* point conference has not been created yet and the base/conference feature
* will not emit it.
*
* @param {Store} store - The redux store.
* @param {Action} action - The redux action.
* @returns {void}
*/
function _sendConferenceFailedOnConnectionError(store, action) {
const { locationURL } = store.getState()['features/base/connection'];
locationURL && _sendEvent(
store,
_getSymbolDescription(CONFERENCE_FAILED),
/* data */ {
url: toURLString(locationURL),
error: action.error.name
});
}
/**
* Sends a specific event to the native counterpart of the External API. Native
* apps may listen to such events via the mechanisms provided by the (native)