feat(rn,connection) enable XMPP WebSocket on mobile

Co-authored-by: Saúl Ibarra Corretgé <saghul@jitsi.org>
This commit is contained in:
paweldomas 2020-08-25 13:43:31 -05:00 committed by Saúl Ibarra Corretgé
parent 380ef3da0b
commit 663752be2c
3 changed files with 18 additions and 11 deletions

View File

@ -106,9 +106,7 @@ export async function connect(id, password, roomName) {
serviceUrl += `?room=${roomName}`;
// FIXME Remove deprecated 'bosh' option assignment at some point(LJM will be accepting only 'serviceUrl' option
// in future). It's included for the time being for Jitsi Meet and lib-jitsi-meet versions interoperability.
connectionConfig.serviceUrl = connectionConfig.bosh = serviceUrl;
connectionConfig.serviceUrl = serviceUrl;
if (connectionConfig.websocketKeepAliveUrl) {
connectionConfig.websocketKeepAliveUrl += `?room=${roomName}`;

View File

@ -181,7 +181,7 @@ export function initAnalytics({ getState }: { getState: Function }, handlers: Ar
permanentProperties.appName = getAppName();
// Report if user is using websocket
permanentProperties.websocket = navigator.product !== 'ReactNative' && typeof config.websocket === 'string';
permanentProperties.websocket = typeof config.websocket === 'string';
// Report if user is using the external API
permanentProperties.externalApi = typeof API_ID === 'number';

View File

@ -275,10 +275,11 @@ function _constructOptions(state) {
// redux store.
const options = _.cloneDeep(state['features/base/config']);
// Normalize the BOSH URL.
let { bosh } = options;
const { websocket } = options;
if (bosh) {
// Normalize the BOSH URL.
if (bosh && !websocket) {
const { locationURL } = state['features/base/connection'];
if (bosh.startsWith('//')) {
@ -295,14 +296,22 @@ function _constructOptions(state) {
// eslint-disable-next-line max-len
bosh = `${protocol}//${host}${contextRoot || '/'}${bosh.substr(1)}`;
}
}
// Append room to the URL's search.
const { room } = state['features/base/conference'];
// WebSocket is preferred over BOSH.
const serviceUrl = websocket || bosh;
room && (bosh += `?room=${getBackendSafeRoomName(room)}`);
// Append room to the URL's search.
const { room } = state['features/base/conference'];
// FIXME Remove deprecated 'bosh' option assignment at some point.
options.serviceUrl = options.bosh = bosh;
if (serviceUrl && room) {
const roomName = getBackendSafeRoomName(room);
options.serviceUrl = `${serviceUrl}?room=${roomName}`;
if (options.websocketKeepAliveUrl) {
options.websocketKeepAliveUrl += `?room=${roomName}`;
}
}
return options;