-
Notifications
You must be signed in to change notification settings - Fork 17
/
MeetingContainer.js
61 lines (55 loc) · 1.45 KB
/
MeetingContainer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import {
useMeeting,
ReactNativeForegroundService,
} from "@videosdk.live/react-native-sdk";
import { useEffect, useState } from "react";
import OneToOneMeetingViewer from "./OneToOne";
import ConferenceMeetingViewer from "./Conference/ConferenceMeetingViewer";
import ParticipantLimitViewer from "./OneToOne/ParticipantLimitViewer";
import WaitingToJoinView from "./Components/WaitingToJoinView";
import React from "react";
export default function MeetingContainer({ webcamEnabled, meetingType }) {
const [isJoined, setJoined] = useState(false);
const [participantLimit, setParticipantLimit] = useState(false);
const { join, participants, leave } = useMeeting({
onMeetingJoined: () => {
setTimeout(() => {
setJoined(true);
}, 500);
},
onParticipantLeft: () => {
if (participants.size < 2) {
setParticipantLimit(false);
}
},
});
useEffect(() => {
if (isJoined) {
if (participants.size > 2) {
setParticipantLimit(true);
}
}
}, [isJoined]);
useEffect(() => {
setTimeout(() => {
if (!isJoined) {
join();
}
}, 1000);
return () => {
leave();
ReactNativeForegroundService.stopAll();
};
}, []);
return isJoined ? (
meetingType === "GROUP" ? (
<ConferenceMeetingViewer />
) : participantLimit ? (
<ParticipantLimitViewer />
) : (
<OneToOneMeetingViewer />
)
) : (
<WaitingToJoinView />
);
}