mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 23:47:47 +00:00
The current implementation doesn't use the API and Transport modules. This is due to the fact that they are too tied to APP at the moment, which is web only. Once API is refactored and moved into the Redux store this will be adjusted, though it's unlikely that the lowest level React Native module (ExternalAPI) changes drastically. This commit also introduces a stopgap limitation of only allowing a single instance for JitsiMeetView objects on both Android and iOS. React Native doesn't really play well with having multiple instances of the same modules on the same bridge, since they behave a bit like singletons. Even if we were to use multiple bridges, some features depend on system-level global state, such as the AVAudioSession mode or Android's immersive mode. Further attempts will be made at lifting this limitation in the future, though.
76 lines
1.9 KiB
JavaScript
76 lines
1.9 KiB
JavaScript
/* @flow */
|
|
|
|
import { NativeModules } from 'react-native';
|
|
|
|
import { getInviteURL } from '../../base/connection';
|
|
import {
|
|
CONFERENCE_FAILED,
|
|
CONFERENCE_JOINED,
|
|
CONFERENCE_LEFT,
|
|
CONFERENCE_WILL_JOIN,
|
|
CONFERENCE_WILL_LEAVE
|
|
} from '../../base/conference';
|
|
import { MiddlewareRegistry } from '../../base/redux';
|
|
|
|
|
|
/**
|
|
* Middleware that captures Redux actions and uses the ExternalAPI module to
|
|
* turn them into native events so the application knows about them.
|
|
*
|
|
* @param {Store} store - Redux store.
|
|
* @returns {Function}
|
|
*/
|
|
MiddlewareRegistry.register(store => next => action => {
|
|
const eventData = {};
|
|
|
|
switch (action.type) {
|
|
case CONFERENCE_FAILED: {
|
|
eventData.error = action.error;
|
|
eventData.url = getInviteURL(store.getState());
|
|
_sendEvent('CONFERENCE_FAILED', eventData);
|
|
break;
|
|
}
|
|
|
|
case CONFERENCE_JOINED: {
|
|
eventData.url = getInviteURL(store.getState());
|
|
_sendEvent('CONFERENCE_JOINED', eventData);
|
|
break;
|
|
}
|
|
|
|
case CONFERENCE_LEFT: {
|
|
eventData.url = getInviteURL(store.getState());
|
|
_sendEvent('CONFERENCE_LEFT', eventData);
|
|
break;
|
|
}
|
|
|
|
case CONFERENCE_WILL_JOIN: {
|
|
eventData.url = getInviteURL(store.getState());
|
|
_sendEvent('CONFERENCE_WILL_JOIN', eventData);
|
|
break;
|
|
}
|
|
|
|
case CONFERENCE_WILL_LEAVE: {
|
|
eventData.url = getInviteURL(store.getState());
|
|
_sendEvent('CONFERENCE_WILL_LEAVE', eventData);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
return next(action);
|
|
});
|
|
|
|
/**
|
|
* Sends the given event to the native side of the application. Applications can
|
|
* then listen to the events using the mechanisms provided by the Jitsi Meet
|
|
* SDK.
|
|
*
|
|
* @param {string} name - Event name.
|
|
* @param {Object} data - Ancillary data for the event.
|
|
* @private
|
|
* @returns {void}
|
|
*/
|
|
function _sendEvent(name: string, data: Object) {
|
|
NativeModules.ExternalAPI.sendEvent(name, data);
|
|
}
|