From e907f17678fe43329cbcac6a09643c8a8c123664 Mon Sep 17 00:00:00 2001 From: freddysundowner Date: Thu, 16 Nov 2023 11:21:42 +0300 Subject: [PATCH] added data field to add external token server --- .../videoMeetingControllerComp.tsx | 46 +++++++++---------- .../packages/lowcoder/src/i18n/locales/en.ts | 6 ++- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingControllerComp.tsx b/client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingControllerComp.tsx index 427feabb3..ae67cebaf 100644 --- a/client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingControllerComp.tsx +++ b/client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingControllerComp.tsx @@ -111,18 +111,21 @@ let screenShareStream: ILocalVideoTrack; let userId: UID | null | undefined; let rtmChannelResponse: RtmChannel; let rtmClient: RtmClient; -const agoraTokenUrl = `https://sandbox.wiggolive.com/token/rtc`; const generateToken = async ( appId: any, certificate: any, - channelName: any + channelName: any, + serverurl: any ) => { - let response = await axios.post(agoraTokenUrl, { - appId, - certificate, - channelName, - }); + let response = await axios.post( + serverurl ?? "https://sandbox.wiggolive.com/token/rtc", + { + appId, + certificate, + channelName, + } + ); return response.data; }; @@ -179,17 +182,16 @@ const leaveChannel = async () => { await rtmChannelResponse.leave(); }; -const hostChanged = (users: any) => {}; - const publishVideo = async ( appId: string, channel: any, height: any, - certifiCateKey: string + certifiCateKey: string, + serverurl: string ) => { let token = null; if (certifiCateKey) { - token = await generateToken(appId, certifiCateKey, channel); + token = await generateToken(appId, certifiCateKey, channel, serverurl); } await turnOnCamera(true); await client.join(appId, channel, token, userId); @@ -234,6 +236,7 @@ export const meetingControllerChildren = { endCall: withDefault(BooleanStateControl, "false"), sharing: withDefault(BooleanStateControl, "false"), appId: withDefault(StringControl, trans("meeting.appid")), + tokenServerUrl: withDefault(StringControl, trans("meeting.serverurl")), participants: stateComp([]), usersScreenShared: stateComp([]), localUser: jsonObjectExposingStateControl(""), @@ -276,27 +279,23 @@ let MTComp = (function () { useEffect(() => { if (userJoined) { + let prevUsers: any[] = props.participants as []; let userData = { user: userJoined.uid, - host: false, audiostatus: userJoined.hasAudio, streamingVideo: true, }; setUserIds((userIds: any) => [...userIds, userData]); - if (userIds.length == 0) { - userData.host = true; - } else { - userData.host = false; - } dispatch( changeChildAction( "participants", - removeDuplicates(getData([...userIds, userData]).data, "user"), + removeDuplicates(getData([...prevUsers, userData]).data, "user"), false ) ); } }, [userJoined]); + function removeDuplicates(arr: any, prop: any) { const uniqueObjects = []; const seenValues = new Set(); @@ -320,7 +319,6 @@ let MTComp = (function () { let hostExists = newUsers.filter((f: any) => f.host === true); if (hostExists.length == 0 && newUsers.length > 0) { newUsers[0].host = true; - hostChanged(newUsers); } setUserIds(newUsers); dispatch( @@ -432,8 +430,6 @@ let MTComp = (function () { client.on( "user-unpublished", (user: IAgoraRTCRemoteUser, mediaType: "video" | "audio") => { - console.log("user-unpublished"); - setLocalUserVideo(user); } ); @@ -511,10 +507,12 @@ let MTComp = (function () { {children.certifiCateKey.propertyView({ label: trans("meeting.certifiCateKey"), })} - {children.meetingName.propertyView({ label: trans("meeting.meetingName"), })} + {children.tokenServerUrl.propertyView({ + label: trans("meeting.serverurl"), + })} {children.placement.propertyView({ label: trans("drawer.placement"), @@ -636,6 +634,7 @@ MTComp = withMethodExposing(MTComp, [ params: [], }, execute: async (comp, values) => { + if (comp.children.meetingActive.getView().value) return; userId = Math.floor(100000 + Math.random() * 900000); comp.children.localUser.change({ user: userId + "", @@ -663,7 +662,8 @@ MTComp = withMethodExposing(MTComp, [ ? "_meetingId" : comp.children.meetingName.getView().value, comp.children, - comp.children.certifiCateKey.getView().value + comp.children.certifiCateKey.getView().value, + comp.children.tokenServerUrl.getView() ); comp.children.meetingActive.change(true); }, diff --git a/client/packages/lowcoder/src/i18n/locales/en.ts b/client/packages/lowcoder/src/i18n/locales/en.ts index 7f20f9c9e..717764bb4 100644 --- a/client/packages/lowcoder/src/i18n/locales/en.ts +++ b/client/packages/lowcoder/src/i18n/locales/en.ts @@ -2,7 +2,8 @@ import table from "./componentDocExtra/table.md?url"; export const en = { productName: "Lowcoder", - productDesc: "Create software applications for your Company and your Customers with minimal coding experience. Lowcoder is the best Retool, Appsmith or Tooljet Alternative.", + productDesc: + "Create software applications for your Company and your Customers with minimal coding experience. Lowcoder is the best Retool, Appsmith or Tooljet Alternative.", notSupportedBrowser: "Your current browser may have compatibility issues. For a better user experience, it is recommended to use the latest version of the Chrome browser.", create: "Create", @@ -1458,6 +1459,7 @@ export const en = { participants: "Participants", shareScreen: "Share Screen", appid: "Application Id", + serverurl: "Token Server url", meetingName: "Meeting Name", videoCompText: "No video Text", profileImageUrl: "Profile Image Url", @@ -2094,7 +2096,7 @@ export const en = { resetSuccessDesc: "Password reset succeeded. The new password is: {password}", copyPassword: "Copy password", - poweredByLowcoder: "Powered by Lowcoder.cloud" + poweredByLowcoder: "Powered by Lowcoder.cloud", }, preLoad: { jsLibraryHelpText: