...
 
Commits (2)
......@@ -4,6 +4,11 @@ import api from './../../common/services/api.service';
* Gathering service
*/
class GatheringService {
keepAliveInterval = null;
get isActive() {
return this.keepAliveInterval !== null;
}
/**
* Start keep alive pooling
*/
......@@ -16,6 +21,7 @@ class GatheringService {
*/
stopKeepAlive() {
clearInterval(this.keepAliveInterval);
this.keepAliveInterval = null;
}
/**
......
import React from 'react';
import { View } from 'react-native';
import { View, BackHandler } from 'react-native';
import JitsiMeet, { JitsiMeetView } from 'react-native-jitsi-meet';
import { CommonStyle } from '../styles/Common';
import sessionService from '../common/services/session.service';
......@@ -13,34 +13,63 @@ class Gathering extends React.Component {
* Remove navigation header
*/
static navigationOptions = {
header: null
header: null,
};
/**
* Constructor
*/
constructor(props) {
super(props);
// we disable the back button until the video call is started
// to prevent an inconsistent behavior
this.backHandler = BackHandler.addEventListener(
'hardwareBackPress',
() => true,
);
}
/**
* Component did mount
*/
componentDidMount() {
const entity = this.props.navigation.getParam('entity');
setTimeout(async () => {
const url = await gatheringService.getRoomName(entity);
const user = sessionService.getUser();
const avatar = user.getAvatarSource().uri;
this.init();
}
JitsiMeet.callWithUserInfo(url, avatar, user.name, entity.name);
}, 1000);
/**
* Init gathering
*/
async init() {
if (!gatheringService.isActive) {
const entity = this.props.navigation.getParam('entity');
this.timer = setTimeout(async () => {
const url = await gatheringService.getRoomName(entity);
const user = sessionService.getUser();
const avatar = user.getAvatarSource().uri;
JitsiMeet.callWithUserInfo(url, avatar, user.name, entity.name);
}, 300);
}
}
/**
* Component will unmount
*/
componentWillUnmount() {
if (this.backHandler) {
this.backHandler.remove();
this.backHandler = null;
}
if (this.timer) {
clearTimeout(this.timer);
}
JitsiMeet.endCall();
}
/**
* On conference terminated
*/
onConferenceTerminated = nativeEvent => {
onConferenceTerminated = event => {
gatheringService.stopKeepAlive();
this.props.navigation.goBack();
};
......@@ -48,16 +77,26 @@ class Gathering extends React.Component {
/**
* On conference joined
*/
onConferenceJoined = nativeEvent => {
onConferenceJoined = event => {
gatheringService.startKeepAlive();
if (this.backHandler) {
this.backHandler.remove();
this.backHandler = null;
// the back button should end the call instead of return to previous screen
this.backHandler = BackHandler.addEventListener(
'hardwareBackPress',
() => {
JitsiMeet.endCall();
return true;
},
);
}
};
/**
* On conference will join
*/
onConferenceWillJoin = nativeEvent => {
/* Conference will join event */
};
onConferenceWillJoin = event => {};
/**
* Render
......