jiti-meet/react/features/base/connection/actions.web.ts

50 lines
1.4 KiB
TypeScript
Raw Normal View History

import { IStore } from '../../app/types';
import { configureInitialDevices } from '../devices/actions';
import { getBackendSafeRoomName } from '../util/uri';
2017-02-03 18:50:06 +00:00
declare const APP: any;
export {
connectionDisconnected,
connectionEstablished,
connectionFailed,
setLocationURL
} from './actions.native';
import logger from './logger';
export * from './actions.any';
2016-12-12 21:13:17 +00:00
/**
* Opens new connection.
*
* @returns {Promise<JitsiConnection>}
*/
export function connect() {
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
2019-10-04 07:31:22 +00:00
const room = getBackendSafeRoomName(getState()['features/base/conference'].room);
2016-12-12 21:13:17 +00:00
// XXX For web based version we use conference initialization logic
// from the old app (at the moment of writing).
return dispatch(configureInitialDevices()).then(
() => APP.conference.init({
roomName: room
}).catch((error: Error) => {
APP.API.notifyConferenceLeft(APP.conference.roomName);
logger.error(error);
}));
2016-12-12 21:13:17 +00:00
};
}
/**
* Closes connection.
*
* @param {boolean} [requestFeedback] - Whether or not to attempt showing a
* request for call feedback.
2016-12-12 21:13:17 +00:00
* @returns {Function}
*/
export function disconnect(requestFeedback = false) {
// XXX For web based version we use conference hanging up logic from the old
// app.
return () => APP.conference.hangup(requestFeedback);
2016-12-12 21:13:17 +00:00
}