Skip to content

Commit 3788c5e

Browse files
authored
Merge pull request #505 from lowcoder-org/agora-integrationn
Added data field to add external token server
2 parents dba4290 + 5a05656 commit 3788c5e

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

client/packages/lowcoder/src/comps/comps/meetingComp/videoMeetingControllerComp.tsx

+23-23
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,21 @@ let screenShareStream: ILocalVideoTrack;
111111
let userId: UID | null | undefined;
112112
let rtmChannelResponse: RtmChannel;
113113
let rtmClient: RtmClient;
114-
const agoraTokenUrl = `https://sandbox.wiggolive.com/token/rtc`;
115114

116115
const generateToken = async (
117116
appId: any,
118117
certificate: any,
119-
channelName: any
118+
channelName: any,
119+
serverurl: any
120120
) => {
121-
let response = await axios.post(agoraTokenUrl, {
122-
appId,
123-
certificate,
124-
channelName,
125-
});
121+
let response = await axios.post(
122+
serverurl ?? "https://sandbox.wiggolive.com/token/rtc",
123+
{
124+
appId,
125+
certificate,
126+
channelName,
127+
}
128+
);
126129
return response.data;
127130
};
128131

@@ -179,17 +182,16 @@ const leaveChannel = async () => {
179182
await rtmChannelResponse.leave();
180183
};
181184

182-
const hostChanged = (users: any) => {};
183-
184185
const publishVideo = async (
185186
appId: string,
186187
channel: any,
187188
height: any,
188-
certifiCateKey: string
189+
certifiCateKey: string,
190+
serverurl: string
189191
) => {
190192
let token = null;
191193
if (certifiCateKey) {
192-
token = await generateToken(appId, certifiCateKey, channel);
194+
token = await generateToken(appId, certifiCateKey, channel, serverurl);
193195
}
194196
await turnOnCamera(true);
195197
await client.join(appId, channel, token, userId);
@@ -234,6 +236,7 @@ export const meetingControllerChildren = {
234236
endCall: withDefault(BooleanStateControl, "false"),
235237
sharing: withDefault(BooleanStateControl, "false"),
236238
appId: withDefault(StringControl, trans("meeting.appid")),
239+
tokenServerUrl: withDefault(StringControl, trans("meeting.serverurl")),
237240
participants: stateComp<JSONValue>([]),
238241
usersScreenShared: stateComp<JSONValue>([]),
239242
localUser: jsonObjectExposingStateControl(""),
@@ -276,27 +279,23 @@ let MTComp = (function () {
276279

277280
useEffect(() => {
278281
if (userJoined) {
282+
let prevUsers: any[] = props.participants as [];
279283
let userData = {
280284
user: userJoined.uid,
281-
host: false,
282285
audiostatus: userJoined.hasAudio,
283286
streamingVideo: true,
284287
};
285288
setUserIds((userIds: any) => [...userIds, userData]);
286-
if (userIds.length == 0) {
287-
userData.host = true;
288-
} else {
289-
userData.host = false;
290-
}
291289
dispatch(
292290
changeChildAction(
293291
"participants",
294-
removeDuplicates(getData([...userIds, userData]).data, "user"),
292+
removeDuplicates(getData([...prevUsers, userData]).data, "user"),
295293
false
296294
)
297295
);
298296
}
299297
}, [userJoined]);
298+
300299
function removeDuplicates(arr: any, prop: any) {
301300
const uniqueObjects = [];
302301
const seenValues = new Set();
@@ -320,7 +319,6 @@ let MTComp = (function () {
320319
let hostExists = newUsers.filter((f: any) => f.host === true);
321320
if (hostExists.length == 0 && newUsers.length > 0) {
322321
newUsers[0].host = true;
323-
hostChanged(newUsers);
324322
}
325323
setUserIds(newUsers);
326324
dispatch(
@@ -432,8 +430,6 @@ let MTComp = (function () {
432430
client.on(
433431
"user-unpublished",
434432
(user: IAgoraRTCRemoteUser, mediaType: "video" | "audio") => {
435-
console.log("user-unpublished");
436-
437433
setLocalUserVideo(user);
438434
}
439435
);
@@ -511,10 +507,12 @@ let MTComp = (function () {
511507
{children.certifiCateKey.propertyView({
512508
label: trans("meeting.certifiCateKey"),
513509
})}
514-
515510
{children.meetingName.propertyView({
516511
label: trans("meeting.meetingName"),
517512
})}
513+
{children.tokenServerUrl.propertyView({
514+
label: trans("meeting.serverurl"),
515+
})}
518516

519517
{children.placement.propertyView({
520518
label: trans("drawer.placement"),
@@ -636,6 +634,7 @@ MTComp = withMethodExposing(MTComp, [
636634
params: [],
637635
},
638636
execute: async (comp, values) => {
637+
if (comp.children.meetingActive.getView().value) return;
639638
userId = Math.floor(100000 + Math.random() * 900000);
640639
comp.children.localUser.change({
641640
user: userId + "",
@@ -663,7 +662,8 @@ MTComp = withMethodExposing(MTComp, [
663662
? "_meetingId"
664663
: comp.children.meetingName.getView().value,
665664
comp.children,
666-
comp.children.certifiCateKey.getView().value
665+
comp.children.certifiCateKey.getView().value,
666+
comp.children.tokenServerUrl.getView()
667667
);
668668
comp.children.meetingActive.change(true);
669669
},

client/packages/lowcoder/src/i18n/locales/en.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import table from "./componentDocExtra/table.md?url";
22

33
export const en = {
44
productName: "Lowcoder",
5-
productDesc: "Create software applications for your Company and your Customers with minimal coding experience. Lowcoder is the best Retool, Appsmith or Tooljet Alternative.",
5+
productDesc:
6+
"Create software applications for your Company and your Customers with minimal coding experience. Lowcoder is the best Retool, Appsmith or Tooljet Alternative.",
67
notSupportedBrowser:
78
"Your current browser may have compatibility issues. For a better user experience, it is recommended to use the latest version of the Chrome browser.",
89
create: "Create",
@@ -1458,6 +1459,7 @@ export const en = {
14581459
participants: "Participants",
14591460
shareScreen: "Share Screen",
14601461
appid: "Application Id",
1462+
serverurl: "Token Server url",
14611463
meetingName: "Meeting Name",
14621464
videoCompText: "No video Text",
14631465
profileImageUrl: "Profile Image Url",
@@ -2094,7 +2096,7 @@ export const en = {
20942096
resetSuccessDesc:
20952097
"Password reset succeeded. The new password is: {password}",
20962098
copyPassword: "Copy password",
2097-
poweredByLowcoder: "Powered by Lowcoder.cloud"
2099+
poweredByLowcoder: "Powered by Lowcoder.cloud",
20982100
},
20992101
preLoad: {
21002102
jsLibraryHelpText:

0 commit comments

Comments
 (0)