Skip to content

Added data field to add external token server #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<JSONValue>([]),
usersScreenShared: stateComp<JSONValue>([]),
localUser: jsonObjectExposingStateControl(""),
Expand Down Expand Up @@ -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();
Expand All @@ -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(
Expand Down Expand Up @@ -432,8 +430,6 @@ let MTComp = (function () {
client.on(
"user-unpublished",
(user: IAgoraRTCRemoteUser, mediaType: "video" | "audio") => {
console.log("user-unpublished");

setLocalUserVideo(user);
}
);
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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 + "",
Expand Down Expand Up @@ -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);
},
Expand Down
6 changes: 4 additions & 2 deletions client/packages/lowcoder/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down