agora-appbuilder-core 4.1.9 → 4.1.10-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +1 -3
- package/template/agora-rn-uikit/src/Contexts/RtcContext.tsx +1 -2
- package/template/agora-rn-uikit/src/Reducer/index.ts +0 -2
- package/template/agora-rn-uikit/src/Rtc/Join.tsx +11 -25
- package/template/agora-rn-uikit/src/RtcConfigure.tsx +1 -14
- package/template/bridge/rtc/webNg/RtcEngine.ts +2 -2
- package/template/bridge/rtm/web/index.ts +30 -0
- package/template/customization-api/typeDefinition.ts +1 -0
- package/template/defaultConfig.js +3 -2
- package/template/global.d.ts +1 -0
- package/template/src/AppRoutes.tsx +3 -3
- package/template/src/ai-agent/components/ControlButtons.tsx +1 -1
- package/template/src/assets/font-styles.css +36 -0
- package/template/src/assets/fonts/icomoon.ttf +0 -0
- package/template/src/assets/selection.json +1 -1
- package/template/src/atoms/CustomIcon.tsx +8 -0
- package/template/src/atoms/Dropdown.tsx +5 -0
- package/template/src/atoms/TertiaryButton.tsx +1 -1
- package/template/src/atoms/UserAvatar.tsx +1 -1
- package/template/src/components/ChatContext.ts +5 -3
- package/template/src/components/Controls.tsx +68 -22
- package/template/src/components/DeviceConfigure.tsx +1 -1
- package/template/src/components/EventsConfigure.tsx +22 -17
- package/template/src/components/Navbar.tsx +14 -11
- package/template/src/components/RTMConfigure.tsx +31 -1036
- package/template/src/components/UserGlobalPreferenceProvider.tsx +227 -0
- package/template/src/components/beauty-effect/useBeautyEffects.tsx +50 -13
- package/template/src/components/breakout-room/BreakoutRoomPanel.tsx +58 -0
- package/template/src/components/breakout-room/context/BreakoutRoomContext.tsx +2508 -0
- package/template/src/components/breakout-room/events/BreakoutRoomEventsConfigure.tsx +272 -0
- package/template/src/components/breakout-room/events/constants.ts +17 -0
- package/template/src/components/breakout-room/hoc/BreakoutRoomNameRenderer.tsx +68 -0
- package/template/src/components/breakout-room/hooks/useBreakoutRoomExit.ts +49 -0
- package/template/src/components/breakout-room/state/reducer.ts +522 -0
- package/template/src/components/breakout-room/state/types.ts +54 -0
- package/template/src/components/breakout-room/ui/BreakoutMeetingTitle.tsx +60 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomActionMenu.tsx +136 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomAnnouncementModal.tsx +135 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomGroupSettings.tsx +588 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomMainRoomUsers.tsx +142 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomMemberActionMenu.tsx +122 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomParticipants.tsx +124 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomRaiseHand.tsx +65 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomRenameModal.tsx +227 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomSettings.tsx +140 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomTransition.tsx +52 -0
- package/template/src/components/breakout-room/ui/BreakoutRoomView.tsx +193 -0
- package/template/src/components/breakout-room/ui/ExitBreakoutRoomIconButton.tsx +79 -0
- package/template/src/components/breakout-room/ui/ParticipantManualAssignmentModal.tsx +638 -0
- package/template/src/components/breakout-room/ui/SelectParticipantAssignmentStrategy.tsx +57 -0
- package/template/src/components/chat/chatConfigure.tsx +7 -1
- package/template/src/components/chat-messages/useChatMessages.tsx +43 -11
- package/template/src/components/common/Dividers.tsx +53 -0
- package/template/src/components/controls/toolbar-items/ExitBreakoutRoomToolbarItem.tsx +13 -0
- package/template/src/components/controls/useControlPermissionMatrix.tsx +32 -4
- package/template/src/components/participants/AllHostParticipants.tsx +10 -2
- package/template/src/components/participants/Participant.tsx +7 -1
- package/template/src/components/participants/UserActionMenuOptions.tsx +12 -2
- package/template/src/components/precall/joinWaitingRoomBtn.native.tsx +12 -8
- package/template/src/components/precall/joinWaitingRoomBtn.tsx +14 -10
- package/template/src/components/raise-hand/RaiseHandButton.tsx +50 -0
- package/template/src/components/raise-hand/RaiseHandProvider.tsx +308 -0
- package/template/src/components/raise-hand/index.ts +14 -0
- package/template/src/components/recordings/RecordingsDateTable.tsx +3 -2
- package/template/src/components/room-info/useCurrentRoomInfo.tsx +42 -0
- package/template/src/components/room-info/useSetBreakoutRoomInfo.tsx +64 -0
- package/template/src/components/useUserPreference.tsx +39 -12
- package/template/src/components/virtual-background/useVB.tsx +18 -0
- package/template/src/components/whiteboard/WhiteboardConfigure.tsx +27 -0
- package/template/src/language/default-labels/videoCallScreenLabels.ts +7 -0
- package/template/src/logger/AppBuilderLogger.tsx +11 -3
- package/template/src/pages/VideoCall.tsx +171 -518
- package/template/src/pages/video-call/BreakoutVideoCall.tsx +213 -0
- package/template/src/pages/video-call/SidePanelHeader.tsx +17 -0
- package/template/src/pages/video-call/VideoCallContent.tsx +211 -0
- package/template/src/pages/video-call/VideoCallScreen.tsx +18 -0
- package/template/src/pages/video-call/VideoCallScreenWrapper.tsx +0 -1
- package/template/src/pages/video-call/VideoCallStateWrapper.tsx +495 -0
- package/template/src/rtm/RTMConfigureBreakoutRoomProvider.tsx +882 -0
- package/template/src/rtm/RTMConfigureMainRoomProvider.tsx +757 -0
- package/template/src/rtm/RTMCoreProvider.tsx +419 -0
- package/template/src/rtm/RTMEngine.ts +188 -60
- package/template/src/rtm/RTMGlobalStateProvider.tsx +706 -0
- package/template/src/rtm/RTMStatusBanner.tsx +99 -0
- package/template/src/rtm/constants.ts +12 -0
- package/template/src/rtm/hooks/useMainRoomUserDisplayName.ts +45 -0
- package/template/src/rtm/rtm-presence-utils.ts +344 -0
- package/template/src/rtm/utils.ts +68 -1
- package/template/src/rtm-events/constants.ts +40 -1
- package/template/src/rtm-events-api/Events.ts +62 -19
- package/template/src/subComponents/ChatBubble.tsx +3 -3
- package/template/src/subComponents/ChatContainer.tsx +19 -9
- package/template/src/subComponents/LocalAudioMute.tsx +2 -2
- package/template/src/subComponents/LocalVideoMute.tsx +2 -2
- package/template/src/subComponents/SidePanelEnum.tsx +1 -0
- package/template/src/subComponents/caption/useCaption.tsx +1 -1
- package/template/src/subComponents/chat/ChatAnnouncementView.tsx +65 -0
- package/template/src/subComponents/chat/ChatSendButton.tsx +1 -0
- package/template/src/subComponents/screenshare/ScreenshareButton.tsx +16 -0
- package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +1 -1
- package/template/src/subComponents/waiting-rooms/WaitingRoomControls.tsx +7 -4
- package/template/src/utils/useDebouncedCallback.tsx +20 -0
- package/template/src/utils/useEndCall.ts +0 -2
- package/template/src/utils/useMuteToggleLocal.ts +14 -10
- package/template/agora-rn-uikit/src/Reducer/Spotlight.ts +0 -11
- package/template/agora-rn-uikit/src/Reducer/UserBanned.ts +0 -11
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
/*
|
|
2
|
+
********************************************
|
|
3
|
+
Copyright © 2021 Agora Lab, Inc., all rights reserved.
|
|
4
|
+
AppBuilder and all associated components, source code, APIs, services, and documentation
|
|
5
|
+
(the “Materials”) are owned by Agora Lab, Inc. and its licensors. The Materials may not be
|
|
6
|
+
accessed, used, modified, or distributed for any purpose without a license from Agora Lab, Inc.
|
|
7
|
+
Use without a license or in violation of any license terms and conditions (including use for
|
|
8
|
+
any purpose competitive to Agora Lab, Inc.’s business) is strictly prohibited. For more
|
|
9
|
+
information visit https://appbuilder.agora.io.
|
|
10
|
+
*********************************************
|
|
11
|
+
*/
|
|
12
|
+
import React, {useState, useContext, useEffect, useRef} from 'react';
|
|
13
|
+
import {View, StyleSheet, Text} from 'react-native';
|
|
14
|
+
import {useCustomization} from 'customization-implementation';
|
|
15
|
+
import {
|
|
16
|
+
ClientRoleType,
|
|
17
|
+
UidType,
|
|
18
|
+
CallbacksInterface,
|
|
19
|
+
} from '../../../agora-rn-uikit';
|
|
20
|
+
import styles from '../../components/styles';
|
|
21
|
+
import {ErrorContext} from '../../components/common/index';
|
|
22
|
+
import {useWakeLock} from '../../components/useWakeLock';
|
|
23
|
+
import {useParams, useHistory} from '../../components/Router';
|
|
24
|
+
import StorageContext from '../../components/StorageContext';
|
|
25
|
+
import {useSetRoomInfo} from '../../components/room-info/useSetRoomInfo';
|
|
26
|
+
import {SdkApiContext} from '../../components/SdkApiContext';
|
|
27
|
+
import {
|
|
28
|
+
useRoomInfo,
|
|
29
|
+
RoomInfoDefaultValue,
|
|
30
|
+
WaitingRoomStatus,
|
|
31
|
+
} from '../../components/room-info/useRoomInfo';
|
|
32
|
+
import {useIsRecordingBot} from '../../subComponents/recording/useIsRecordingBot';
|
|
33
|
+
import Logo from '../../subComponents/Logo';
|
|
34
|
+
import SDKEvents from '../../utils/SdkEvents';
|
|
35
|
+
import isSDK from '../../utils/isSDK';
|
|
36
|
+
import {useHasBrandLogo} from '../../utils/common';
|
|
37
|
+
import useJoinRoom from '../../utils/useJoinRoom';
|
|
38
|
+
import {useString} from '../../utils/useString';
|
|
39
|
+
import {AuthErrorCodes} from '../../utils/common';
|
|
40
|
+
import {
|
|
41
|
+
userBannedText,
|
|
42
|
+
videoRoomStartingCallText,
|
|
43
|
+
} from '../../language/default-labels/videoCallScreenLabels';
|
|
44
|
+
import {LogSource, logger} from '../../logger/AppBuilderLogger';
|
|
45
|
+
import Toast from '../../../react-native-toast-message';
|
|
46
|
+
import {RTMCoreProvider} from '../../rtm/RTMCoreProvider';
|
|
47
|
+
import {videoView} from '../../../theme.json';
|
|
48
|
+
import VideoCallContent from './VideoCallContent';
|
|
49
|
+
import RTMGlobalStateProvider from '../../rtm/RTMGlobalStateProvider';
|
|
50
|
+
import UserGlobalPreferenceProvider from '../../components/UserGlobalPreferenceProvider';
|
|
51
|
+
|
|
52
|
+
export enum RnEncryptionEnum {
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated
|
|
55
|
+
* 0: This mode is deprecated.
|
|
56
|
+
*/
|
|
57
|
+
None = 0,
|
|
58
|
+
/**
|
|
59
|
+
* 1: (Default) 128-bit AES encryption, XTS mode.
|
|
60
|
+
*/
|
|
61
|
+
AES128XTS = 1,
|
|
62
|
+
/**
|
|
63
|
+
* 2: 128-bit AES encryption, ECB mode.
|
|
64
|
+
*/
|
|
65
|
+
AES128ECB = 2,
|
|
66
|
+
/**
|
|
67
|
+
* 3: 256-bit AES encryption, XTS mode.
|
|
68
|
+
*/
|
|
69
|
+
AES256XTS = 3,
|
|
70
|
+
/**
|
|
71
|
+
* 4: 128-bit SM4 encryption, ECB mode.
|
|
72
|
+
*
|
|
73
|
+
* @since v3.1.2.
|
|
74
|
+
*/
|
|
75
|
+
SM4128ECB = 4,
|
|
76
|
+
/**
|
|
77
|
+
* 6: 256-bit AES encryption, GCM mode.
|
|
78
|
+
*
|
|
79
|
+
* @since v3.1.2.
|
|
80
|
+
*/
|
|
81
|
+
AES256GCM = 6,
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 7: 128-bit GCM encryption, GCM mode.
|
|
85
|
+
*
|
|
86
|
+
* @since v3.4.5
|
|
87
|
+
*/
|
|
88
|
+
AES128GCM2 = 7,
|
|
89
|
+
/**
|
|
90
|
+
* 8: 256-bit GCM encryption, GCM mode.
|
|
91
|
+
* @since v3.1.2.
|
|
92
|
+
* Compared to AES256GCM encryption mode, AES256GCM2 encryption mode is more secure and requires you to set the salt (encryptionKdfSalt).
|
|
93
|
+
*/
|
|
94
|
+
AES256GCM2 = 8,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const VideoCallStateWrapper = () => {
|
|
98
|
+
const hasBrandLogo = useHasBrandLogo();
|
|
99
|
+
const joiningLoaderLabel = useString(videoRoomStartingCallText)();
|
|
100
|
+
const {isRecordingBot} = useIsRecordingBot();
|
|
101
|
+
const {setRoomInfo} = useSetRoomInfo();
|
|
102
|
+
const {setGlobalErrorMessage} = useContext(ErrorContext);
|
|
103
|
+
const bannedUserText = useString(userBannedText)();
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Should we set the callscreen to active ??
|
|
107
|
+
* a) If Recording bot( i.e prop: recordingBot) is TRUE then it means,
|
|
108
|
+
* the recording bot is accessing the screen - so YES we should set
|
|
109
|
+
* the callActive as true and we need not check for whether
|
|
110
|
+
* $config.PRECALL is enabled or not.
|
|
111
|
+
* b) If Recording bot( i.e prop: recordingBot) is FALSE then we should set
|
|
112
|
+
* the callActive depending upon the value of magic variable - $config.PRECALL
|
|
113
|
+
*/
|
|
114
|
+
const shouldCallBeSetToActive = isRecordingBot
|
|
115
|
+
? true
|
|
116
|
+
: $config.PRECALL
|
|
117
|
+
? false
|
|
118
|
+
: true;
|
|
119
|
+
const [callActive, setCallActive] = useState(shouldCallBeSetToActive);
|
|
120
|
+
const [queryComplete, setQueryComplete] = useState(false);
|
|
121
|
+
const [waitingRoomAttendeeJoined, setWaitingRoomAttendeeJoined] =
|
|
122
|
+
useState(false);
|
|
123
|
+
const {isJoinDataFetched, data, isInWaitingRoom, waitingRoomStatus} =
|
|
124
|
+
useRoomInfo();
|
|
125
|
+
const {store} = useContext(StorageContext);
|
|
126
|
+
const {
|
|
127
|
+
join: SdkJoinState,
|
|
128
|
+
microphoneDevice: sdkMicrophoneDevice,
|
|
129
|
+
cameraDevice: sdkCameraDevice,
|
|
130
|
+
clearState,
|
|
131
|
+
} = useContext(SdkApiContext);
|
|
132
|
+
const useJoin = useJoinRoom();
|
|
133
|
+
|
|
134
|
+
const {phrase} = useParams<{phrase: string}>();
|
|
135
|
+
const history = useHistory();
|
|
136
|
+
const currentMeetingPhrase = useRef(history.location.pathname);
|
|
137
|
+
const {awake, release} = useWakeLock();
|
|
138
|
+
|
|
139
|
+
const [rtcProps, setRtcProps] = React.useState({
|
|
140
|
+
appId: $config.APP_ID,
|
|
141
|
+
channel: null,
|
|
142
|
+
uid: null,
|
|
143
|
+
token: null,
|
|
144
|
+
rtm: null,
|
|
145
|
+
screenShareUid: null,
|
|
146
|
+
screenShareToken: null,
|
|
147
|
+
profile: $config.PROFILE,
|
|
148
|
+
screenShareProfile: $config.SCREEN_SHARE_PROFILE,
|
|
149
|
+
dual: true,
|
|
150
|
+
encryption: $config.ENCRYPTION_ENABLED
|
|
151
|
+
? {key: null, mode: RnEncryptionEnum.AES128GCM2, screenKey: null}
|
|
152
|
+
: false,
|
|
153
|
+
role: ClientRoleType.ClientRoleBroadcaster,
|
|
154
|
+
geoFencing: $config.GEO_FENCING,
|
|
155
|
+
audioRoom: $config.AUDIO_ROOM,
|
|
156
|
+
activeSpeaker: $config.ACTIVE_SPEAKER,
|
|
157
|
+
preferredCameraId:
|
|
158
|
+
sdkCameraDevice.deviceId || store?.activeDeviceId?.videoinput || null,
|
|
159
|
+
preferredMicrophoneId:
|
|
160
|
+
sdkMicrophoneDevice.deviceId || store?.activeDeviceId?.audioinput || null,
|
|
161
|
+
recordingBot: isRecordingBot ? true : false,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
if (
|
|
166
|
+
//isJoinDataFetched === true && (!queryComplete || !isInWaitingRoom)
|
|
167
|
+
//non waiting room - host/attendee
|
|
168
|
+
(!$config.ENABLE_WAITING_ROOM &&
|
|
169
|
+
isJoinDataFetched === true &&
|
|
170
|
+
!queryComplete) ||
|
|
171
|
+
//waiting room - host
|
|
172
|
+
($config.ENABLE_WAITING_ROOM &&
|
|
173
|
+
isJoinDataFetched === true &&
|
|
174
|
+
data.isHost &&
|
|
175
|
+
!queryComplete) ||
|
|
176
|
+
//waiting room - attendee
|
|
177
|
+
($config.ENABLE_WAITING_ROOM &&
|
|
178
|
+
isJoinDataFetched === true &&
|
|
179
|
+
!data.isHost &&
|
|
180
|
+
(!queryComplete || !isInWaitingRoom) &&
|
|
181
|
+
!waitingRoomAttendeeJoined)
|
|
182
|
+
) {
|
|
183
|
+
setRtcProps(prevRtcProps => ({
|
|
184
|
+
...prevRtcProps,
|
|
185
|
+
channel: data.channel,
|
|
186
|
+
uid: data.uid,
|
|
187
|
+
token: data.token,
|
|
188
|
+
rtm: data.rtmToken,
|
|
189
|
+
encryption: $config.ENCRYPTION_ENABLED
|
|
190
|
+
? {
|
|
191
|
+
key: data.encryptionSecret,
|
|
192
|
+
mode: data.encryptionMode,
|
|
193
|
+
screenKey: data.encryptionSecret,
|
|
194
|
+
salt: data.encryptionSecretSalt,
|
|
195
|
+
}
|
|
196
|
+
: false,
|
|
197
|
+
screenShareUid: data.screenShareUid,
|
|
198
|
+
screenShareToken: data.screenShareToken,
|
|
199
|
+
role: data.isHost
|
|
200
|
+
? ClientRoleType.ClientRoleBroadcaster
|
|
201
|
+
: ClientRoleType.ClientRoleAudience,
|
|
202
|
+
preventJoin:
|
|
203
|
+
!$config.ENABLE_WAITING_ROOM ||
|
|
204
|
+
($config.ENABLE_WAITING_ROOM && data.isHost) ||
|
|
205
|
+
($config.ENABLE_WAITING_ROOM &&
|
|
206
|
+
!data.isHost &&
|
|
207
|
+
waitingRoomStatus === WaitingRoomStatus.APPROVED)
|
|
208
|
+
? false
|
|
209
|
+
: true,
|
|
210
|
+
}));
|
|
211
|
+
if (
|
|
212
|
+
$config.ENABLE_WAITING_ROOM &&
|
|
213
|
+
!data.isHost &&
|
|
214
|
+
waitingRoomStatus === WaitingRoomStatus.APPROVED
|
|
215
|
+
) {
|
|
216
|
+
setWaitingRoomAttendeeJoined(true);
|
|
217
|
+
}
|
|
218
|
+
// 1. Store the display name from API
|
|
219
|
+
// if (data.username) {
|
|
220
|
+
// setUsername(data.username);
|
|
221
|
+
// }
|
|
222
|
+
setQueryComplete(true);
|
|
223
|
+
}
|
|
224
|
+
}, [isJoinDataFetched, data, queryComplete]);
|
|
225
|
+
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (!isJoinDataFetched) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
logger.log(LogSource.Internals, 'SET_MEETING_DETAILS', 'Room details', {
|
|
231
|
+
user_id: data?.uid || '',
|
|
232
|
+
meeting_title: data?.meetingTitle || '',
|
|
233
|
+
channel_id: data?.channel,
|
|
234
|
+
host_id: data?.roomId?.host || '',
|
|
235
|
+
attendee_id: data?.roomId?.attendee || '',
|
|
236
|
+
});
|
|
237
|
+
}, [isJoinDataFetched, data, phrase]);
|
|
238
|
+
|
|
239
|
+
// SDK related code
|
|
240
|
+
useEffect(() => {
|
|
241
|
+
if (!isSDK() || !SdkJoinState.initialized) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const {
|
|
245
|
+
phrase: sdkMeetingPhrase,
|
|
246
|
+
meetingDetails: sdkMeetingDetails,
|
|
247
|
+
skipPrecall,
|
|
248
|
+
promise,
|
|
249
|
+
preference,
|
|
250
|
+
} = SdkJoinState;
|
|
251
|
+
|
|
252
|
+
const sdkMeetingPath = `/${sdkMeetingPhrase}`;
|
|
253
|
+
|
|
254
|
+
setCallActive(skipPrecall);
|
|
255
|
+
|
|
256
|
+
if (sdkMeetingDetails) {
|
|
257
|
+
setQueryComplete(false);
|
|
258
|
+
setRoomInfo(roomInfo => {
|
|
259
|
+
return {
|
|
260
|
+
...roomInfo,
|
|
261
|
+
isJoinDataFetched: true,
|
|
262
|
+
data: {
|
|
263
|
+
...roomInfo.data,
|
|
264
|
+
...sdkMeetingDetails,
|
|
265
|
+
},
|
|
266
|
+
roomPreference: preference,
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
} else if (sdkMeetingPhrase) {
|
|
270
|
+
setQueryComplete(false);
|
|
271
|
+
currentMeetingPhrase.current = sdkMeetingPath;
|
|
272
|
+
useJoin(sdkMeetingPhrase, preference)
|
|
273
|
+
.then(() => {
|
|
274
|
+
logger.log(
|
|
275
|
+
LogSource.Internals,
|
|
276
|
+
'JOIN_MEETING',
|
|
277
|
+
'Join channel success',
|
|
278
|
+
);
|
|
279
|
+
})
|
|
280
|
+
.catch(error => {
|
|
281
|
+
const errorCode = error?.code;
|
|
282
|
+
if (AuthErrorCodes.indexOf(errorCode) !== -1 && isSDK()) {
|
|
283
|
+
SDKEvents.emit('unauthorized', error);
|
|
284
|
+
}
|
|
285
|
+
logger.error(
|
|
286
|
+
LogSource.Internals,
|
|
287
|
+
'JOIN_MEETING',
|
|
288
|
+
'Join channel error',
|
|
289
|
+
JSON.stringify(error || {}),
|
|
290
|
+
);
|
|
291
|
+
setGlobalErrorMessage(error);
|
|
292
|
+
history.push('/');
|
|
293
|
+
currentMeetingPhrase.current = '';
|
|
294
|
+
promise.rej(error);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}, [SdkJoinState]);
|
|
298
|
+
|
|
299
|
+
useEffect(() => {
|
|
300
|
+
if (!SdkJoinState?.phrase) {
|
|
301
|
+
useJoin(phrase, RoomInfoDefaultValue.roomPreference)
|
|
302
|
+
.then(() => {
|
|
303
|
+
logger.log(
|
|
304
|
+
LogSource.Internals,
|
|
305
|
+
'JOIN_MEETING',
|
|
306
|
+
'Join channel success',
|
|
307
|
+
);
|
|
308
|
+
})
|
|
309
|
+
.catch(error => {
|
|
310
|
+
const errorCode = error?.code;
|
|
311
|
+
if (AuthErrorCodes.indexOf(errorCode) !== -1 && isSDK()) {
|
|
312
|
+
SDKEvents.emit('unauthorized', error);
|
|
313
|
+
}
|
|
314
|
+
logger.error(
|
|
315
|
+
LogSource.Internals,
|
|
316
|
+
'JOIN_MEETING',
|
|
317
|
+
'Join channel error',
|
|
318
|
+
JSON.stringify(error || {}),
|
|
319
|
+
);
|
|
320
|
+
setGlobalErrorMessage(error);
|
|
321
|
+
history.push('/');
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}, []);
|
|
325
|
+
|
|
326
|
+
React.useEffect(() => {
|
|
327
|
+
return () => {
|
|
328
|
+
logger.debug(
|
|
329
|
+
LogSource.Internals,
|
|
330
|
+
'VIDEO_CALL_ROOM',
|
|
331
|
+
'Videocall unmounted',
|
|
332
|
+
);
|
|
333
|
+
setRoomInfo(prevState => {
|
|
334
|
+
return {
|
|
335
|
+
...RoomInfoDefaultValue,
|
|
336
|
+
loginToken: prevState?.loginToken,
|
|
337
|
+
};
|
|
338
|
+
});
|
|
339
|
+
if (awake) {
|
|
340
|
+
release();
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
}, []);
|
|
344
|
+
|
|
345
|
+
// commented for v1 release
|
|
346
|
+
const afterEndCall = useCustomization(
|
|
347
|
+
data =>
|
|
348
|
+
data?.lifecycle?.useAfterEndCall && data?.lifecycle?.useAfterEndCall(),
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
const callbacks: CallbacksInterface = {
|
|
352
|
+
// RtcLeft: () => {},
|
|
353
|
+
// RtcJoined: () => {
|
|
354
|
+
// if (SdkJoinState.phrase && SdkJoinState.skipPrecall) {
|
|
355
|
+
// SdkJoinState.promise?.res();
|
|
356
|
+
// }
|
|
357
|
+
// },
|
|
358
|
+
EndCall: () => {
|
|
359
|
+
clearState('join');
|
|
360
|
+
setTimeout(() => {
|
|
361
|
+
// TODO: These callbacks are being called twice
|
|
362
|
+
SDKEvents.emit('leave');
|
|
363
|
+
if (afterEndCall) {
|
|
364
|
+
afterEndCall(data.isHost, history as unknown as History);
|
|
365
|
+
} else {
|
|
366
|
+
history.push('/');
|
|
367
|
+
}
|
|
368
|
+
}, 0);
|
|
369
|
+
},
|
|
370
|
+
// @ts-ignore
|
|
371
|
+
UserJoined: (uid: UidType) => {
|
|
372
|
+
console.log('UIKIT Callback: UserJoined', uid);
|
|
373
|
+
SDKEvents.emit('rtc-user-joined', uid);
|
|
374
|
+
},
|
|
375
|
+
// @ts-ignore
|
|
376
|
+
UserOffline: (uid: UidType) => {
|
|
377
|
+
console.log('UIKIT Callback: UserOffline', uid);
|
|
378
|
+
SDKEvents.emit('rtc-user-left', uid);
|
|
379
|
+
},
|
|
380
|
+
// @ts-ignore
|
|
381
|
+
RemoteAudioStateChanged: (uid: UidType, status: 0 | 2) => {
|
|
382
|
+
console.log('UIKIT Callback: RemoteAudioStateChanged', uid, status);
|
|
383
|
+
if (status === 0) {
|
|
384
|
+
SDKEvents.emit('rtc-user-unpublished', uid, 'audio');
|
|
385
|
+
} else {
|
|
386
|
+
SDKEvents.emit('rtc-user-published', uid, 'audio');
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
// @ts-ignore
|
|
390
|
+
RemoteVideoStateChanged: (uid: UidType, status: 0 | 2) => {
|
|
391
|
+
console.log('UIKIT Callback: RemoteVideoStateChanged', uid, status);
|
|
392
|
+
if (status === 0) {
|
|
393
|
+
SDKEvents.emit('rtc-user-unpublished', uid, 'video');
|
|
394
|
+
} else {
|
|
395
|
+
SDKEvents.emit('rtc-user-published', uid, 'video');
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
// @ts-ignore
|
|
399
|
+
UserBanned(isBanned) {
|
|
400
|
+
console.log('UIKIT Callback: UserBanned', isBanned);
|
|
401
|
+
Toast.show({
|
|
402
|
+
leadingIconName: 'alert',
|
|
403
|
+
type: 'error',
|
|
404
|
+
text1: bannedUserText,
|
|
405
|
+
visibilityTime: 3000,
|
|
406
|
+
});
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
return (
|
|
411
|
+
<>
|
|
412
|
+
{queryComplete ? (
|
|
413
|
+
queryComplete || !callActive ? (
|
|
414
|
+
<RTMCoreProvider
|
|
415
|
+
userInfo={{
|
|
416
|
+
localUid: rtcProps.uid,
|
|
417
|
+
screenShareUid: rtcProps.screenShareUid,
|
|
418
|
+
isHost: rtcProps.role === ClientRoleType.ClientRoleBroadcaster,
|
|
419
|
+
rtmToken: rtcProps.rtm,
|
|
420
|
+
}}>
|
|
421
|
+
<RTMGlobalStateProvider
|
|
422
|
+
rtmLoginInfo={{
|
|
423
|
+
uid: rtcProps.uid,
|
|
424
|
+
channel: rtcProps.channel,
|
|
425
|
+
}}>
|
|
426
|
+
<UserGlobalPreferenceProvider>
|
|
427
|
+
<VideoCallContent
|
|
428
|
+
callActive={callActive}
|
|
429
|
+
setCallActive={setCallActive}
|
|
430
|
+
rtcProps={rtcProps}
|
|
431
|
+
setRtcProps={setRtcProps}
|
|
432
|
+
styleProps={styleProps}
|
|
433
|
+
callbacks={callbacks}
|
|
434
|
+
/>
|
|
435
|
+
</UserGlobalPreferenceProvider>
|
|
436
|
+
</RTMGlobalStateProvider>
|
|
437
|
+
</RTMCoreProvider>
|
|
438
|
+
) : (
|
|
439
|
+
<View style={style.loader}>
|
|
440
|
+
<View style={style.loaderLogo}>{hasBrandLogo() && <Logo />}</View>
|
|
441
|
+
<Text style={style.loaderText}>{joiningLoaderLabel}</Text>
|
|
442
|
+
</View>
|
|
443
|
+
)
|
|
444
|
+
) : (
|
|
445
|
+
<></>
|
|
446
|
+
)}
|
|
447
|
+
</>
|
|
448
|
+
);
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const styleProps = {
|
|
452
|
+
maxViewStyles: styles.temp,
|
|
453
|
+
minViewStyles: styles.temp,
|
|
454
|
+
localBtnContainer: styles.bottomBar,
|
|
455
|
+
localBtnStyles: {
|
|
456
|
+
muteLocalAudio: styles.localButton,
|
|
457
|
+
muteLocalVideo: styles.localButton,
|
|
458
|
+
switchCamera: styles.localButton,
|
|
459
|
+
endCall: styles.endCall,
|
|
460
|
+
fullScreen: styles.localButton,
|
|
461
|
+
recording: styles.localButton,
|
|
462
|
+
screenshare: styles.localButton,
|
|
463
|
+
},
|
|
464
|
+
theme: $config.PRIMARY_ACTION_BRAND_COLOR,
|
|
465
|
+
remoteBtnStyles: {
|
|
466
|
+
muteRemoteAudio: styles.remoteButton,
|
|
467
|
+
muteRemoteVideo: styles.remoteButton,
|
|
468
|
+
remoteSwap: styles.remoteButton,
|
|
469
|
+
minCloseBtnStyles: styles.minCloseBtn,
|
|
470
|
+
liveStreamHostControlBtns: styles.liveStreamHostControlBtns,
|
|
471
|
+
},
|
|
472
|
+
BtnStyles: styles.remoteButton,
|
|
473
|
+
};
|
|
474
|
+
//change these to inline styles or sth
|
|
475
|
+
const style = StyleSheet.create({
|
|
476
|
+
full: {
|
|
477
|
+
flex: 1,
|
|
478
|
+
flexDirection: 'column',
|
|
479
|
+
overflow: 'hidden',
|
|
480
|
+
},
|
|
481
|
+
videoView: videoView,
|
|
482
|
+
loader: {
|
|
483
|
+
flex: 1,
|
|
484
|
+
alignSelf: 'center',
|
|
485
|
+
justifyContent: 'center',
|
|
486
|
+
},
|
|
487
|
+
loaderLogo: {
|
|
488
|
+
alignSelf: 'center',
|
|
489
|
+
justifyContent: 'center',
|
|
490
|
+
marginBottom: 30,
|
|
491
|
+
},
|
|
492
|
+
loaderText: {fontWeight: '500', color: $config.FONT_COLOR},
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
export default VideoCallStateWrapper;
|