agora-appbuilder-core 2.3.0-beta.9 → 3.0.0

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.
Files changed (205) hide show
  1. package/Readme.md +11 -6
  2. package/package.json +1 -1
  3. package/template/Gulpfile.js +121 -83
  4. package/template/_gitignore +2 -2
  5. package/template/_package-lock.json +12959 -13248
  6. package/template/agora-rn-uikit/src/AgoraUIKit.tsx +2 -2
  7. package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +2 -0
  8. package/template/agora-rn-uikit/src/Contexts/RtcContext.tsx +3 -3
  9. package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +4 -5
  10. package/template/agora-rn-uikit/src/Controls/ImageIcon.tsx +3 -1
  11. package/template/agora-rn-uikit/src/Controls/LocalControls.tsx +2 -2
  12. package/template/agora-rn-uikit/src/Reducer/LocalMuteAudio.ts +1 -1
  13. package/template/agora-rn-uikit/src/Reducer/LocalMuteVideo.ts +1 -1
  14. package/template/agora-rn-uikit/src/Reducer/RemoteAudioStateChanged.ts +1 -1
  15. package/template/agora-rn-uikit/src/Reducer/RemoteVideoStateChanged.ts +1 -1
  16. package/template/agora-rn-uikit/src/Reducer/UpdateDualStreamMode.ts +4 -4
  17. package/template/agora-rn-uikit/src/Reducer/UserJoined.ts +7 -5
  18. package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteAudio.ts +1 -1
  19. package/template/agora-rn-uikit/src/Reducer/UserMuteRemoteVideo.ts +1 -1
  20. package/template/agora-rn-uikit/src/Reducer/UserOffline.ts +2 -2
  21. package/template/agora-rn-uikit/src/Rtc/Create.tsx +88 -43
  22. package/template/agora-rn-uikit/src/Rtc/Join.tsx +13 -4
  23. package/template/agora-rn-uikit/src/RtcConfigure.tsx +36 -19
  24. package/template/agora-rn-uikit/src/Utils/permission.ts +17 -6
  25. package/template/babel.config.js +9 -9
  26. package/template/bridge/rtc/webNg/RtcEngine.ts +51 -26
  27. package/template/customization-api/action-library.ts +22 -0
  28. package/template/{fpe-api/context.ts → customization-api/app-state.ts} +16 -14
  29. package/template/customization-api/customEvents.ts +9 -0
  30. package/template/{fpe-api/install.ts → customization-api/customize.ts} +27 -26
  31. package/template/{fpe-api → customization-api}/index.ts +11 -6
  32. package/template/{fpe-api/components.ts → customization-api/sub-components.ts} +22 -3
  33. package/template/{fpe-api → customization-api}/typeDefinition.ts +13 -14
  34. package/template/customization-api/utils.ts +30 -0
  35. package/template/{fpe-implementation → customization-implementation}/createHook.ts +0 -0
  36. package/template/{fpe-implementation/dummyFpe.ts → customization-implementation/dummyConfig.ts} +4 -4
  37. package/template/customization-implementation/index.ts +4 -0
  38. package/template/{fpe-api/useFpe.tsx → customization-implementation/useCustomization.tsx} +12 -12
  39. package/template/{fpe.config.js → customization.config.js} +11 -11
  40. package/template/electron/main/index.js +42 -35
  41. package/template/esbuild.rsdk.go +8 -17
  42. package/template/global.d.ts +4 -3
  43. package/template/index.rsdk.tsx +13 -5
  44. package/template/index.wsdk.tsx +21 -5
  45. package/template/package.json +3 -0
  46. package/template/react-native-toast-message/src/index.js +3 -7
  47. package/template/react-native-toast-message/src/{index.wsdk.js → index.sdk.tsx} +1 -1
  48. package/template/react-native-toast-message/src/styles.sdk.ts +17 -0
  49. package/template/src/App.tsx +8 -4
  50. package/template/src/AppWrapper.tsx +8 -6
  51. package/template/src/SDKAppWrapper.tsx +28 -21
  52. package/template/src/app-state/useLocalUserInfo.ts +8 -0
  53. package/template/src/app-state/useMessages.ts +52 -0
  54. package/template/src/atoms/PrimaryButton.tsx +2 -2
  55. package/template/src/atoms/SecondaryButton.tsx +12 -4
  56. package/template/src/atoms/TextInput.tsx +2 -2
  57. package/template/src/components/Chat.tsx +22 -11
  58. package/template/src/components/ChatContext.ts +10 -27
  59. package/template/src/components/Controls.native.tsx +13 -7
  60. package/template/src/components/Controls.tsx +15 -24
  61. package/template/src/components/DeviceConfigure.tsx +4 -3
  62. package/template/src/components/EventsConfigure.tsx +54 -0
  63. package/template/src/components/GridVideo.tsx +5 -6
  64. package/template/src/components/HostControlView.tsx +13 -19
  65. package/template/src/components/Navbar.tsx +54 -41
  66. package/template/src/components/NetworkQualityContext.tsx +4 -3
  67. package/template/src/components/ParticipantsView.tsx +7 -7
  68. package/template/src/components/PinnedVideo.tsx +3 -4
  69. package/template/src/components/Precall.native.tsx +3 -3
  70. package/template/src/components/Precall.tsx +14 -10
  71. package/template/src/components/RTMConfigure.tsx +61 -219
  72. package/template/src/components/SettingsView.tsx +6 -3
  73. package/template/src/components/Share.tsx +24 -18
  74. package/template/src/components/chat-messages/useChatMessages.tsx +397 -80
  75. package/template/src/components/chat-notification/useChatNotification.tsx +2 -2
  76. package/template/src/components/chat-ui/useChatUIControl.tsx +1 -1
  77. package/template/src/components/common/Logo.tsx +3 -2
  78. package/template/src/components/contexts/LiveStreamDataContext.tsx +3 -3
  79. package/template/src/components/contexts/ScreenShareContext.tsx +3 -1
  80. package/template/src/components/contexts/VideoMeetingDataContext.tsx +85 -0
  81. package/template/src/components/contexts/WhiteboardContext.tsx +8 -8
  82. package/template/src/components/livestream/LiveStreamContext.tsx +88 -74
  83. package/template/src/components/meeting-info/useMeetingInfo.tsx +23 -19
  84. package/template/src/components/meeting-info/useSetMeetingInfo.tsx +1 -1
  85. package/template/src/components/participants/AllAudienceParticipants.tsx +2 -2
  86. package/template/src/components/participants/AllHostParticipants.tsx +4 -4
  87. package/template/src/components/participants/MeParticipant.tsx +5 -3
  88. package/template/src/components/participants/ParticipantName.tsx +2 -2
  89. package/template/src/components/participants/RemoteParticipants.tsx +9 -7
  90. package/template/src/components/precall/LocalMute.native.tsx +14 -10
  91. package/template/src/components/precall/LocalMute.tsx +7 -5
  92. package/template/src/components/precall/VideoPreview.native.tsx +6 -6
  93. package/template/src/components/precall/VideoPreview.tsx +3 -3
  94. package/template/src/components/precall/joinCallBtn.tsx +3 -3
  95. package/template/src/components/precall/meetingTitle.tsx +3 -1
  96. package/template/src/components/precall/selectDevice.tsx +2 -2
  97. package/template/src/components/precall/usePreCall.tsx +1 -1
  98. package/template/src/components/styles.ts +3 -3
  99. package/template/src/components/useShareLink.tsx +69 -29
  100. package/template/src/components/useUserPreference.tsx +16 -15
  101. package/template/src/components/useWakeLock.tsx +3 -3
  102. package/template/src/language/i18nTypes.ts +1 -1
  103. package/template/src/language/index.ts +2 -2
  104. package/template/src/language/useLanguage.tsx +2 -3
  105. package/template/src/pages/Authenticate.tsx +3 -2
  106. package/template/src/pages/Create.tsx +18 -20
  107. package/template/src/pages/Join.tsx +6 -7
  108. package/template/src/pages/VideoCall.tsx +74 -66
  109. package/template/src/pages/create/useCreate.tsx +1 -1
  110. package/template/src/pages/video-call/CustomUserContextHolder.tsx +14 -6
  111. package/template/src/pages/video-call/DefaultLayouts.ts +8 -8
  112. package/template/src/pages/video-call/{NameWithMicStatus.tsx → NameWithMicIcon.tsx} +8 -1
  113. package/template/src/pages/video-call/RenderComponent.tsx +7 -10
  114. package/template/src/pages/video-call/VideoCallScreen.tsx +31 -22
  115. package/template/src/pages/video-call/VideoComponent.tsx +13 -15
  116. package/template/src/pages/video-call/VideoRenderer.tsx +6 -6
  117. package/template/src/pages/video-call/useLayoutsData.ts +23 -0
  118. package/template/src/rtm/RTMEngine.ts +13 -0
  119. package/template/src/rtm-events/EventUtils.ts +20 -20
  120. package/template/src/rtm-events/EventsQueue.ts +9 -3
  121. package/template/src/rtm-events/constants.ts +5 -0
  122. package/template/src/rtm-events/index.tsx +1 -3
  123. package/template/src/{custom-events/CustomEvents.ts → rtm-events-api/Events.ts} +67 -61
  124. package/template/src/rtm-events-api/index.tsx +6 -0
  125. package/template/src/rtm-events-api/types.ts +22 -0
  126. package/template/src/subComponents/ChatBubble.tsx +24 -8
  127. package/template/src/subComponents/ChatContainer.tsx +24 -15
  128. package/template/src/subComponents/ChatInput.tsx +56 -42
  129. package/template/src/subComponents/LanguageSelector.tsx +2 -2
  130. package/template/src/subComponents/LayoutIconDropdown.native.tsx +5 -5
  131. package/template/src/subComponents/LayoutIconDropdown.tsx +7 -7
  132. package/template/src/subComponents/LocalAudioMute.tsx +3 -4
  133. package/template/src/subComponents/LocalEndCall.tsx +3 -6
  134. package/template/src/subComponents/LocalSwitchCamera.tsx +3 -4
  135. package/template/src/subComponents/LocalVideoMute.tsx +3 -3
  136. package/template/src/subComponents/NetworkQualityPill.tsx +8 -9
  137. package/template/src/subComponents/OpenInNativeButton.tsx +2 -3
  138. package/template/src/subComponents/RemoteAudioMute.tsx +5 -11
  139. package/template/src/subComponents/RemoteEndCall.tsx +3 -10
  140. package/template/src/subComponents/RemoteVideoMute.tsx +3 -10
  141. package/template/src/subComponents/SelectDevice.tsx +1 -1
  142. package/template/src/subComponents/SelectOAuth.tsx +3 -2
  143. package/template/src/subComponents/SidePanelButtons.ts +6 -5
  144. package/template/src/subComponents/TextWithTooltip.tsx +6 -2
  145. package/template/src/subComponents/{toastConfig.tsx → ToastConfig.tsx} +2 -2
  146. package/template/src/subComponents/chat/ChatParticipants.tsx +6 -5
  147. package/template/src/subComponents/livestream/CurrentLiveStreamRequestsView.tsx +2 -2
  148. package/template/src/subComponents/livestream/controls/RemoteLiveStreamApprovedRequestRecall.tsx +4 -3
  149. package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestApprove.tsx +2 -2
  150. package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestReject.tsx +2 -4
  151. package/template/src/subComponents/livestream/index.ts +2 -2
  152. package/template/src/subComponents/recording/useRecording.tsx +44 -23
  153. package/template/src/subComponents/recording/useRecordingLayoutQuery.tsx +11 -5
  154. package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +46 -34
  155. package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +97 -38
  156. package/template/src/subComponents/screenshare/useScreenshare.tsx +1 -1
  157. package/template/src/utils/SdkEvents.ts +9 -46
  158. package/template/src/utils/common.tsx +25 -9
  159. package/template/src/utils/getUniqueID.ts +5 -0
  160. package/template/src/utils/isMobileOrTablet.native.ts +2 -2
  161. package/template/src/utils/isMobileOrTablet.ts +21 -8
  162. package/template/src/utils/useButtonTemplate.tsx +1 -1
  163. package/template/src/utils/useCreateMeeting.ts +21 -10
  164. package/template/src/utils/useGetMeetingPhrase.ts +11 -8
  165. package/template/src/utils/{IsAttendeeUser.ts → useIsAttendee.ts} +3 -1
  166. package/template/src/utils/{isAudioEnabled.ts → useIsAudioEnabled.ts} +4 -4
  167. package/template/src/utils/{isHostUser.ts → useIsHost.ts} +13 -16
  168. package/template/src/utils/{isPSTNUser.ts → useIsPSTN.ts} +2 -2
  169. package/template/src/utils/{isScreenShareUser.ts → useIsScreenShare.ts} +0 -0
  170. package/template/src/utils/{isVideoEnabled.ts → useIsVideoEnabled.ts} +5 -6
  171. package/template/src/utils/useJoinMeeting.ts +8 -6
  172. package/template/src/utils/useLayout.tsx +5 -5
  173. package/template/src/utils/useMutePSTN.ts +5 -3
  174. package/template/src/utils/useMuteToggleLocal.ts +3 -4
  175. package/template/src/utils/useRemoteEndCall.ts +11 -10
  176. package/template/src/utils/useRemoteMute.ts +42 -20
  177. package/template/src/utils/useSidePanel.tsx +1 -1
  178. package/template/src/utils/useString.ts +2 -2
  179. package/template/src/utils/useUserName.ts +11 -0
  180. package/template/tsconfig_fpeApi.json +8 -9
  181. package/template/tsconfig_rsdk_index.json +8 -9
  182. package/template/tsconfig_wsdk_index.json +8 -9
  183. package/template/webpack.commons.js +9 -9
  184. package/template/webpack.rsdk.config.js +4 -2
  185. package/template/webpack.ts.config.js +6 -6
  186. package/template/webpack.wsdk.config.js +2 -1
  187. package/template/fpe-api/fpeEvents.ts +0 -9
  188. package/template/fpe-api/utils.ts +0 -61
  189. package/template/fpe-implementation/index.ts +0 -1
  190. package/template/fpe-todo.txt +0 -14
  191. package/template/src/components/RTMEvents.tsx +0 -84
  192. package/template/src/custom-events/index.tsx +0 -4
  193. package/template/src/custom-events/types.ts +0 -51
  194. package/template/src/pages/video-call/CustomLayout.ts +0 -17
  195. package/template/src/rtm-events/types.ts +0 -7
  196. package/template/src/utils/getMeetingInvite.ts +0 -53
  197. package/template/src/utils/useGroupMessages.ts +0 -24
  198. package/template/src/utils/useNavParams.ts +0 -6
  199. package/template/src/utils/useNavigateTo.ts +0 -8
  200. package/template/src/utils/usePrivateMessages.ts +0 -33
  201. package/template/src/utils/useSendControlMessage.ts +0 -51
  202. package/template/src/utils/useSendMessage.ts +0 -40
  203. package/template/src/utils/useSetUnreadMessageCount.ts +0 -43
  204. package/template/src/utils/useUnreadMessageCount.ts +0 -50
  205. package/template/src/utils/useUserList.ts +0 -26
@@ -11,69 +11,47 @@
11
11
  */
12
12
  // @ts-nocheck
13
13
  import React, {useState, useContext, useEffect, useRef} from 'react';
14
- import RtmEngine, {RtmAttribute} from 'agora-react-native-rtm';
14
+ import RtmEngine from 'agora-react-native-rtm';
15
15
  import {PropsContext, useLocalUid} from '../../agora-rn-uikit';
16
- import ChatContext, {controlMessageEnum} from './ChatContext';
16
+ import ChatContext from './ChatContext';
17
17
  import {RtcContext} from '../../agora-rn-uikit';
18
- import {messageSourceType, messageActionType} from './ChatContext';
19
18
  import {Platform} from 'react-native';
20
19
  import {backOff} from 'exponential-backoff';
21
20
  import {useString} from '../utils/useString';
22
- import {isAndroid, isWeb} from '../utils/common';
23
- import StorageContext from './StorageContext';
24
- import {useRenderContext} from 'fpe-api';
21
+ import {isAndroid, isWebInternal} from '../utils/common';
22
+ import {useRender, useRtc} from 'customization-api';
25
23
  import {
26
24
  safeJsonParse,
27
25
  timeNow,
28
26
  hasJsonStructure,
29
27
  getMessageTime,
30
28
  get32BitUid,
31
- adjustUID,
32
29
  } from '../rtm/utils';
33
- import {EventUtils, EventsQueue, eventMessageType} from '../rtm-events';
30
+ import {EventUtils, EventsQueue} from '../rtm-events';
31
+ import {EventPersistLevel} from '../rtm-events-api';
34
32
  import RTMEngine from '../rtm/RTMEngine';
35
33
  import {filterObject} from '../utils';
36
- import CustomEvents, {EventLevel} from '../custom-events';
37
- import {EventNames} from '../rtm-events';
38
- import useLocalScreenShareUid from '../utils/useLocalShareScreenUid';
39
34
 
40
35
  export enum UserType {
41
36
  ScreenShare = 'screenshare',
42
37
  }
43
38
 
44
- const stringifyPayload = (
45
- source: messageSourceType,
46
- type: messageActionType,
47
- msg: string,
48
- ) => {
49
- return JSON.stringify({
50
- source,
51
- type,
52
- msg,
53
- });
54
- };
55
-
56
- const parsePayload = (data: string) => {
57
- return JSON.parse(data);
58
- };
59
-
60
39
  const RtmConfigure = (props: any) => {
61
40
  const localUid = useLocalUid();
62
- const screenShareUid = useLocalScreenShareUid();
63
41
  const {callActive} = props;
64
42
  const {rtcProps} = useContext(PropsContext);
65
- const {RtcEngine, dispatch} = useContext(RtcContext);
66
- const {renderList, renderPosition} = useRenderContext();
43
+ const {RtcEngine, dispatch} = useRtc();
44
+ const {renderList, activeUids} = useRender();
67
45
  const renderListRef = useRef({renderList: renderList});
68
- const renderPositionRef = useRef({renderPosition: renderPosition});
46
+ const activeUidsRef = useRef({activeUids: activeUids});
69
47
 
70
48
  /**
71
49
  * inside event callback state won't have latest value.
72
50
  * so creating ref to access the state
73
51
  */
74
52
  useEffect(() => {
75
- renderPositionRef.current.renderPosition = renderPosition;
76
- }, [renderPosition]);
53
+ activeUidsRef.current.activeUids = activeUids;
54
+ }, [activeUids]);
77
55
 
78
56
  useEffect(() => {
79
57
  renderListRef.current.renderList = renderList;
@@ -108,7 +86,7 @@ const RtmConfigure = (props: any) => {
108
86
  engine.current.leaveChannel(rtcProps.channel);
109
87
  };
110
88
 
111
- if (!isWeb) return;
89
+ if (!isWebInternal()) return;
112
90
  window.addEventListener('beforeunload', handBrowserClose);
113
91
  // cleanup this component
114
92
  return () => {
@@ -139,7 +117,9 @@ const RtmConfigure = (props: any) => {
139
117
  try {
140
118
  await engine.current.setLocalUserAttributes(rtmAttributes);
141
119
  timerValueRef.current = 5;
142
- joinChannel();
120
+ await joinChannel();
121
+ setHasUserJoinedRTM(true);
122
+ await runQueuedEvents();
143
123
  } catch (error) {
144
124
  setTimeout(async () => {
145
125
  timerValueRef.current = timerValueRef.current + timerValueRef.current;
@@ -153,8 +133,6 @@ const RtmConfigure = (props: any) => {
153
133
  await engine.current.joinChannel(rtcProps.channel);
154
134
  timerValueRef.current = 5;
155
135
  await getMembers();
156
- setHasUserJoinedRTM(true);
157
- await runQueuedCustomEvents();
158
136
  } catch (error) {
159
137
  setTimeout(async () => {
160
138
  timerValueRef.current = timerValueRef.current + timerValueRef.current;
@@ -233,18 +211,11 @@ const RtmConfigure = (props: any) => {
233
211
  // isActive to identify all active screenshare users in the call
234
212
  for (const [key, value] of Object.entries(attr?.attributes)) {
235
213
  if (hasJsonStructure(value as string)) {
236
- const [err, result] = safeJsonParse(value as string);
237
- const payloadValue = result?.value || '';
238
- const payloadAction = result?.action || '';
239
214
  const data = {
240
215
  evt: key,
241
- payload: {
242
- ...result,
243
- value: payloadValue,
244
- action: payloadAction,
245
- },
216
+ value: value,
246
217
  };
247
- // Todo:EVENTSUP Add the data to queue, dont add same mulitple events, use set so as to not repeat events
218
+ // TODOSUP: Add the data to queue, dont add same mulitple events, use set so as to not repeat events
248
219
  EventsQueue.enqueue({
249
220
  data: data,
250
221
  uid: member.uid,
@@ -337,225 +308,100 @@ const RtmConfigure = (props: any) => {
337
308
  // Chat of left user becomes undefined. So don't cleanup
338
309
  const uid = data?.uid ? parseInt(data?.uid) : undefined;
339
310
  if (!uid) return;
340
- //updating the rtc data
311
+ // updating the rtc data
341
312
  updateRenderListState(uid, {
342
313
  offline: true,
343
314
  });
344
315
  });
345
316
 
346
317
  engine.current.on('messageReceived', (evt: any) => {
318
+ console.log('CUSTOM_EVENT_API messageReceived: ', evt);
347
319
  const {peerId, ts, text} = evt;
348
- const textObj = parsePayload(text);
349
- const {type, msg} = textObj;
320
+ const [err, msg] = safeJsonParse(text);
321
+ if (err) {
322
+ console.log(
323
+ 'CUSTOM_EVENT_API: JSON payload incorrect, Error while parsing the payload',
324
+ );
325
+ }
350
326
 
351
327
  const timestamp = getMessageTime(ts);
352
328
 
353
- const sender = isAndroid ? get32BitUid(peerId) : peerId;
354
-
355
- if (type === messageActionType.Control) {
356
- switch (msg) {
357
- case controlMessageEnum.muteVideo:
358
- RtcEngine.muteLocalVideoStream(true);
359
- dispatch({
360
- type: 'LocalMuteVideo',
361
- value: [0],
362
- });
363
- break;
364
- case controlMessageEnum.muteAudio:
365
- RtcEngine.muteLocalAudioStream(true);
366
- dispatch({
367
- type: 'LocalMuteAudio',
368
- value: [0],
369
- });
370
- break;
371
- case controlMessageEnum.kickUser:
372
- dispatch({
373
- type: 'EndCall',
374
- value: [],
375
- });
376
- break;
377
- default:
378
- break;
379
- }
380
- } else if (type === eventMessageType.CUSTOM_EVENT) {
381
- console.log('CUSTOM_EVENT_API: inside custom event type ', evt);
382
- try {
383
- customEventDispatcher(msg, sender, timestamp);
384
- } catch (error) {
385
- console.log('error while dispacthing', error);
386
- }
329
+ const sender = isAndroid() ? get32BitUid(peerId) : parseInt(peerId);
330
+
331
+ try {
332
+ eventDispatcher(msg, sender, timestamp);
333
+ } catch (error) {
334
+ console.log('error while dispacthing', error);
387
335
  }
388
336
  });
389
337
 
390
338
  engine.current.on('channelMessageReceived', (evt) => {
339
+ console.log('CUSTOM_EVENT_API channelMessageReceived: ', evt);
340
+
391
341
  const {uid, channelId, text, ts} = evt;
392
- const textObj = parsePayload(text);
393
- const [err, result] = safeJsonParse(text);
394
- const {type, msg} = textObj;
342
+ const [err, msg] = safeJsonParse(text);
343
+ if (err) {
344
+ console.log(
345
+ 'CUSTOM_EVENT_API: JSON payload incorrect, Error while parsing the payload',
346
+ );
347
+ }
395
348
 
396
349
  const timestamp = getMessageTime(ts);
397
350
 
398
- const sender = Platform.OS ? get32BitUid(uid) : uid;
351
+ const sender = Platform.OS ? get32BitUid(uid) : parseInt(uid);
399
352
 
400
353
  if (channelId === rtcProps.channel) {
401
- if (
402
- type === eventMessageType.CONTROL_GROUP ||
403
- type === messageActionType.Control
404
- ) {
405
- let actionMsg = '';
406
- if (hasJsonStructure(msg)) {
407
- const [err, result] = safeJsonParse(msg);
408
- if (!err) {
409
- const {action} = result;
410
- actionMsg = action;
411
- }
412
- } else {
413
- actionMsg = msg;
414
- }
415
- switch (actionMsg) {
416
- case controlMessageEnum.muteVideo:
417
- RtcEngine.muteLocalVideoStream(true);
418
- dispatch({
419
- type: 'LocalMuteVideo',
420
- value: [0],
421
- });
422
- break;
423
- case controlMessageEnum.muteAudio:
424
- RtcEngine.muteLocalAudioStream(true);
425
- dispatch({
426
- type: 'LocalMuteAudio',
427
- value: [0],
428
- });
429
- break;
430
- default:
431
- break;
432
- // throw new Error('Unsupported message type');
433
- }
434
- } else if (type === eventMessageType.CUSTOM_EVENT) {
435
- console.log('CUSTOM_EVENT_API: inside custom event type ', evt);
436
- try {
437
- customEventDispatcher(msg, sender, timestamp);
438
- } catch (error) {
439
- console.log('error while dispacthing', error);
440
- }
354
+ try {
355
+ eventDispatcher(msg, sender, timestamp);
356
+ } catch (error) {
357
+ console.log('error while dispacthing', error);
441
358
  }
442
359
  }
443
360
  });
444
361
  doLoginAndSetupRTM();
445
362
  };
446
363
 
447
- const runQueuedCustomEvents = async () => {
364
+ const runQueuedEvents = async () => {
448
365
  try {
449
- const eventsInQueue = EventsQueue.printQueue();
450
- if (eventsInQueue.length !== 0) {
451
- for (const queuedEvents of eventsInQueue) {
452
- await customEventDispatcher(
453
- queuedEvents.data,
454
- queuedEvents.uid,
455
- queuedEvents.ts,
456
- );
457
- // EventsQueue.dequeue();
458
- }
366
+ while (!EventsQueue.isEmpty()) {
367
+ const currEvt = EventsQueue.dequeue();
368
+ await eventDispatcher(currEvt.data, currEvt.uid, currEvt.ts);
459
369
  }
460
370
  } catch (error) {
461
- throw Error(
462
- 'CUSTOM_EVENTS_API: error while running queued events ',
463
- error,
464
- );
371
+ console.log('CUSTOM_EVENT_API: error while running queue events', error);
465
372
  }
466
373
  };
467
374
 
468
- const customEventDispatcher = async (
375
+ const eventDispatcher = async (
469
376
  data: {
470
377
  evt: string;
471
- payload: {
472
- level: 1 | 2 | 3;
473
- action: string;
474
- value: string;
475
- };
378
+ value: string;
476
379
  },
477
380
  sender: string,
478
381
  ts: number,
479
382
  ) => {
480
- console.log('CUSTOM_EVENT_API: inside customEventDispatcher ', data);
481
- const {evt, payload} = data;
383
+ console.log('CUSTOM_EVENT_API: inside eventDispatcher ', data);
384
+ const {evt, value} = data;
482
385
  // Step 1: Set local attributes
483
- if (payload?.level === 3) {
484
- const rtmAttribute = {key: evt, value: JSON.stringify(data.payload)};
386
+ if (value?.persistLevel === EventPersistLevel.LEVEL3) {
387
+ const rtmAttribute = {key: evt, value: value};
485
388
  await engine.current.addOrUpdateLocalUserAttributes([rtmAttribute]);
486
389
  }
487
390
  // Step 2: Emit the event
488
391
  try {
489
- console.log('CUSTOM_EVENT_API: emiting event: ');
490
- EventUtils.emitEvent(evt, {payload, sender, ts});
392
+ const {payload, persistLevel, source} = JSON.parse(value);
393
+ console.log('CUSTOM_EVENT_API: emiting event..: ');
394
+ EventUtils.emitEvent(evt, source, {payload, persistLevel, sender, ts});
491
395
  } catch (error) {
492
396
  console.log('CUSTOM_EVENT_API: error while emiting event: ', error);
493
397
  }
494
398
  };
495
399
 
496
- const sendMessage = async (msg: string) => {
497
- if (msg.trim() === '') return;
498
- const text = stringifyPayload(
499
- messageSourceType.Core,
500
- messageActionType.Normal,
501
- msg,
502
- );
503
- await (engine.current as RtmEngine).sendMessageByChannelId(
504
- rtcProps.channel,
505
- text,
506
- );
507
- };
508
-
509
- const sendMessageToUid = async (msg: string, uid: UidType) => {
510
- if (msg.trim() === '') return;
511
-
512
- const adjustedUID = adjustUID(uid);
513
-
514
- const text = stringifyPayload(
515
- messageSourceType.Core,
516
- messageActionType.Normal,
517
- msg,
518
- );
519
- await (engine.current as RtmEngine).sendMessageToPeer({
520
- peerId: adjustedUID.toString(),
521
- offline: false,
522
- text,
523
- });
524
- };
525
-
526
- const sendControlMessage = async (msg: string) => {
527
- const text = stringifyPayload(
528
- messageSourceType.Core,
529
- messageActionType.Control,
530
- msg,
531
- );
532
- await (engine.current as RtmEngine).sendMessageByChannelId(
533
- rtcProps.channel,
534
- text,
535
- );
536
- };
537
-
538
- const sendControlMessageToUid = async (msg: string, uid: UidType) => {
539
- if (msg.trim() === '') return;
540
-
541
- const adjustedUID = adjustUID(uid);
542
-
543
- const text = stringifyPayload(
544
- messageSourceType.Core,
545
- messageActionType.Control,
546
- msg,
547
- );
548
- await (engine.current as RtmEngine).sendMessageToPeer({
549
- peerId: adjustedUID.toString(),
550
- offline: false,
551
- text,
552
- });
553
- };
554
-
555
400
  const end = async () => {
556
401
  callActive
557
- ? (await (engine.current as RtmEngine).logout(),
558
- await (engine.current as RtmEngine).destroyClient(),
402
+ ? (RTMEngine.getInstance().destroy(),
403
+ EventUtils.clear(),
404
+ setHasUserJoinedRTM(false),
559
405
  // setLogin(false),
560
406
  console.log('RTM cleanup done'))
561
407
  : {};
@@ -573,10 +419,6 @@ const RtmConfigure = (props: any) => {
573
419
  <ChatContext.Provider
574
420
  value={{
575
421
  hasUserJoinedRTM,
576
- sendControlMessage,
577
- sendControlMessageToUid,
578
- sendMessage,
579
- sendMessageToUid,
580
422
  engine: engine.current,
581
423
  localUid: localUid,
582
424
  onlineUsersCount,
@@ -15,17 +15,20 @@ import SelectDevice from '../subComponents/SelectDevice';
15
15
  import HostControlView from './HostControlView';
16
16
  import {useString} from '../utils/useString';
17
17
  import LanguageSelector from '../subComponents/LanguageSelector';
18
- import {isWeb} from '../utils/common';
18
+ import {isWebInternal} from '../utils/common';
19
19
  import {useMeetingInfo} from './meeting-info/useMeetingInfo';
20
20
 
21
21
  const SettingsView = () => {
22
- const {isHost} = useMeetingInfo();
22
+ const {
23
+ data: {isHost},
24
+ } = useMeetingInfo();
23
25
  //commented for v1 release
24
26
  //const selectInputDeviceLabel = useString('selectInputDeviceLabel')();
25
27
  const selectInputDeviceLabel = 'Select Input Device';
26
28
 
27
29
  return (
28
- <View style={isWeb ? style.settingsView : style.settingsViewNative}>
30
+ <View
31
+ style={isWebInternal() ? style.settingsView : style.settingsViewNative}>
29
32
  <View style={style.main}>
30
33
  <View>
31
34
  <Text style={style.heading}>{selectInputDeviceLabel}</Text>
@@ -21,12 +21,12 @@ import {useString} from '../utils/useString';
21
21
  import isSDKCheck from '../utils/isSDK';
22
22
  import Logo from '../components/common/Logo';
23
23
  import {useMeetingInfo} from './meeting-info/useMeetingInfo';
24
- import useNavigateTo from '../utils/useNavigateTo';
25
- import {useFpe} from 'fpe-api';
24
+ import {useHistory} from '../components/Router';
25
+ import {useCustomization} from 'customization-implementation';
26
26
  import {isValidReactComponent} from '../utils/common';
27
27
 
28
28
  const Share = () => {
29
- const {FpeShareComponent} = useFpe((data) => {
29
+ const {FpeShareComponent} = useCustomization((data) => {
30
30
  let components: {
31
31
  FpeShareComponent?: React.ElementType;
32
32
  } = {};
@@ -45,7 +45,9 @@ const Share = () => {
45
45
  return components;
46
46
  });
47
47
  const {copyShareLinkToClipboard, getShareLink} = useShareLink();
48
- const {meetingPassphrase, isSeparateHostLink} = useMeetingInfo();
48
+ const {
49
+ data: {roomId, pstn, isSeparateHostLink},
50
+ } = useMeetingInfo();
49
51
  //commented for v1 release
50
52
  // const meetingUrlText = useString('meetingUrlLabel')();
51
53
  // const meetingIdText = useString('meetingIdLabel')();
@@ -71,10 +73,10 @@ const Share = () => {
71
73
  const pinLabel = 'Pin';
72
74
  const enterMeetingAfterCreateButton = 'Start Meeting (as host)';
73
75
  const copyInviteButton = 'Copy invite to clipboard';
74
- const navigateTo = useNavigateTo();
76
+ const history = useHistory();
75
77
  const enterMeeting = () => {
76
- if (meetingPassphrase?.host) {
77
- navigateTo(meetingPassphrase.host);
78
+ if (roomId?.host) {
79
+ history.push(roomId.host);
78
80
  }
79
81
  };
80
82
 
@@ -87,18 +89,20 @@ const Share = () => {
87
89
  setDim([e.nativeEvent.layout.width, e.nativeEvent.layout.height]);
88
90
  };
89
91
  const isSDK = isSDKCheck();
90
- const isWeb = $config.FRONTEND_ENDPOINT || (platform === 'web' && !isSDK);
92
+ const isWebCheck =
93
+ $config.FRONTEND_ENDPOINT || (platform === 'web' && !isSDK);
91
94
 
92
- const getAttendeeLabel = () => (isWeb ? attendeeUrlLabel : attendeeIdLabel);
95
+ const getAttendeeLabel = () =>
96
+ isWebCheck ? attendeeUrlLabel : attendeeIdLabel;
93
97
 
94
98
  const getHostLabel = () => {
95
99
  if (isSeparateHostLink) {
96
- if (isWeb) {
100
+ if (isWebCheck) {
97
101
  return hostUrlLabel;
98
102
  }
99
103
  return hostIdText;
100
104
  } else {
101
- if (isWeb) {
105
+ if (isWebCheck) {
102
106
  return meetingUrlText;
103
107
  }
104
108
  return meetingIdText;
@@ -118,7 +122,7 @@ const Share = () => {
118
122
  <View style={{width: '80%'}}>
119
123
  <Text style={style.urlTitle}>{getAttendeeLabel()}</Text>
120
124
  <View style={style.urlHolder}>
121
- <Text style={[style.url, isWeb ? urlWeb : {opacity: 1}]}>
125
+ <Text style={[style.url, isWebCheck ? urlWeb : {opacity: 1}]}>
122
126
  {getShareLink(SHARE_LINK_CONTENT_TYPE.ATTENDEE)}
123
127
  </Text>
124
128
  </View>
@@ -156,7 +160,7 @@ const Share = () => {
156
160
  <View style={{width: '80%'}}>
157
161
  <Text style={style.urlTitle}>{getHostLabel()}</Text>
158
162
  <View style={style.urlHolder}>
159
- <Text style={[style.url, isWeb ? urlWeb : {opacity: 1}]}>
163
+ <Text style={[style.url, isWebCheck ? urlWeb : {opacity: 1}]}>
160
164
  {getShareLink(SHARE_LINK_CONTENT_TYPE.HOST)}
161
165
  </Text>
162
166
  </View>
@@ -187,21 +191,23 @@ const Share = () => {
187
191
  </View>
188
192
  </View>
189
193
  </View>
190
- {meetingPassphrase?.pstn ? (
194
+ {pstn ? (
191
195
  <View style={style.urlContainer}>
192
196
  <View style={{width: '80%'}}>
193
197
  <Text style={style.urlTitle}>{pstnLabel}</Text>
194
198
  <View>
195
199
  <View style={style.pstnHolder}>
196
200
  <Text style={style.urlTitle}>{pstnNumberLabel}: </Text>
197
- <Text style={[style.url, isWeb ? urlWeb : {opacity: 1}]}>
198
- {meetingPassphrase?.pstn?.number}
201
+ <Text
202
+ style={[style.url, isWebCheck ? urlWeb : {opacity: 1}]}>
203
+ {pstn?.number}
199
204
  </Text>
200
205
  </View>
201
206
  <View style={style.pstnHolder}>
202
207
  <Text style={style.urlTitle}>{pinLabel}: </Text>
203
- <Text style={[style.url, isWeb ? urlWeb : {opacity: 1}]}>
204
- {meetingPassphrase?.pstn?.pin}
208
+ <Text
209
+ style={[style.url, isWebCheck ? urlWeb : {opacity: 1}]}>
210
+ {pstn?.pin}
205
211
  </Text>
206
212
  </View>
207
213
  </View>