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

49 lines
1.3 KiB
JavaScript
Raw Normal View History

// @flow
2017-02-03 18:50:06 +00:00
import type { Dispatch } from 'redux';
2016-12-12 21:13:17 +00:00
2017-02-03 18:50:06 +00:00
declare var APP: Object;
2017-02-16 21:22:40 +00:00
declare var config: Object;
2017-02-03 18:50:06 +00:00
const logger = require('jitsi-meet-logger').getLogger(__filename);
2016-12-12 21:13:17 +00:00
export {
connectionEstablished,
connectionFailed,
setLocationURL
} from './actions.native';
2016-12-12 21:13:17 +00:00
/**
* Opens new connection.
*
* @returns {Promise<JitsiConnection>}
*/
export function connect() {
2017-02-03 18:50:06 +00:00
return (dispatch: Dispatch<*>, getState: Function) => {
2017-01-15 19:05:17 +00:00
// XXX Lib-jitsi-meet does not accept uppercase letters.
2018-07-12 03:57:44 +00:00
const room = getState()['features/base/conference'].room.toLowerCase();
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 APP.conference.init({
roomName: room
}).catch(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: boolean = 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
}