Skip to content

Commit

Permalink
Integrating with dyte 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MOHAMMED1MEDHAT committed Sep 15, 2023
1 parent c7f044f commit 8457138
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 110 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ yarn-error.log*


config.env
*.env
*.env
*.rdb
2 changes: 1 addition & 1 deletion config.env
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ EMAIL_HOST=gmail
CLIENT_URL=DEMO.com

#dyte configration
DYTE_URL=https://api.dyte.io/v2
DYTE_BASE_URL=https://api.dyte.io/v2
DYTE_ORG_ID=ca9bb773-faa3-4983-a7a4-d0cddd07818d
DYTE_API_KEY=ec19c2d69a52287711b1
DYTE_API_TOKEN=Y2E5YmI3NzMtZmFhMy00OTgzLWE3YTQtZDBjZGRkMDc4MThkOmVjMTljMmQ2OWE1MjI4NzcxMWIx
155 changes: 48 additions & 107 deletions src/utils/dyte.js
Original file line number Diff line number Diff line change
@@ -1,119 +1,60 @@
//preset
var axios = require('axios').default;
const axios = require('axios').default;

const API_HASH = Buffer.from(
`${process.env.DYTE_ORG_ID}:${process.env.DYTE_API_KEY}`,
'utf-8'
).toString('base64');
// const DYTE_API_Meeting_URL = 'https://api.dyte.io/v2/meetings';
// const DYTE_API_Adding_URL = `https://api.dyte.io/v2
// /meetings/{meeting_id}/participants`;

var options = {
method: 'POST',
url: 'https://api.dyte.io/v2/presets',
headers: {
'Content-Type': 'application/json',
Authorization:
'Basic Y2E5YmI3NzMtZmFhMy00OTgzLWE3YTQtZDBjZGRkMDc4MThkOmVjMTljMmQ2OWE1MjI4NzcxMWIx'
},
data: {
name: 'Test',
config: {
view_type: 'GROUP_CALL',
max_video_streams: { mobile: 0, desktop: 0 },
max_screenshare_count: 0,
media: {
video: { quality: 'hd', frame_rate: 30 },
screenshare: { quality: 'hd', frame_rate: 0 }
}
},
permissions: {
accept_waiting_requests: true,
can_accept_production_requests: true,
can_edit_display_name: true,
can_spotlight: true,
is_recorder: false,
recorder_type: 'NONE',
disable_participant_audio: true,
disable_participant_screensharing: true,
disable_participant_video: true,
kick_participant: true,
pin_participant: true,
can_record: true,
can_livestream: true,
waiting_room_type: 'SKIP',
plugins: {
can_close: true,
can_start: true,
can_edit_config: true,
config: '4de5a1b6-f730-4513-9ebe-16895971a32d'
},
connected_meetings: {
can_alter_connected_meetings: true,
can_switch_connected_meetings: true,
can_switch_to_parent_meeting: true
},
polls: { can_create: true, can_vote: true, can_view: true },
media: {
video: { can_produce: 'ALLOWED' },
audio: { can_produce: 'ALLOWED' },
screenshare: { can_produce: 'ALLOWED' }
exports.createDyteMeeting = async title => {
try {
const response = await axios.post(
`${process.env.DYTE_BASE_URL}/meetings`,
{
title: `${title}`,
preferred_region: 'ap-south-1',
record_on_start: false,
live_stream_on_start: false
},
chat: {
public: { can_send: true, text: true, files: true },
private: {
can_send: true,
can_receive: true,
text: true,
files: true
{
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${process.env.DYTE_API_TOKEN}`
}
},
hidden_participant: true,
show_participant_list: true,
can_change_participant_permissions: true
},
ui: {
design_tokens: {
border_radius: 'rounded',
border_width: 'thin',
spacing_base: 4,
theme: 'dark',
colors: {
brand: {
'300': '#844d1c',
'400': '#9d5b22',
'500': '#b56927',
'600': '#d37c30',
'700': '#d9904f'
},
background: {
'600': '#222222',
'700': '#1f1f1f',
'800': '#1b1b1b',
'900': '#181818',
'1000': '#141414'
},
danger: '#FF2D2D',
text: '#EEEEEE',
text_on_brand: '#EEEEEE',
success: '#62A504',
video_bg: '#191919',
warning: '#FFCD07'
},
logo: 'string'
},
config_diff: {}
}
}
);

// console.log(response.data.data.id);

return response.data.data.id;
} catch (error) {
console.error('Error creating Dyte meeting:', error.message);
// throw error;
}
};

exports.runPreset = async () => {
// console.log(process.env.DYTE_API_TOKEN);
//add participant -->auth token

exports.addUserToMeeting = async function(meetingId, userData) {
try {
const response = await axios.request(options);
console.log(response.data);
const url = `${process.env.DYTE_BASE_URL}/meetings/${meetingId}/participants`;
const response = await axios.post(url, userData, {
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${process.env.DYTE_API_TOKEN}`
}
});

console.log(response.data.data.token);

return response.data.data.token;
} catch (error) {
console.error(error.message);
console.error('Error adding user to Dyte meeting:', error);
throw error;
}
};

//create meeting -->meeting id
//add participant -->auth token
const userData = {
name: '',
picture: '',
preset_name: '',
custom_participant_id: ''
};
10 changes: 9 additions & 1 deletion src/utils/sockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,15 @@ const listen = function(io) {
});

socket.on('hi', async function({ userId }) {
dyte.runPreset();
const meetingID = await dyte.createDyteMeeting('test');
console.log(meetingID);
const token = await dyte.addUserToMeeting(meetingID, {
// name: 'test',
// picture: 'test',
preset_name: 'test',
custom_participant_id: 'sdafhosadkfhoksadf'
});
console.log(token);
});

socket.on('disconnect', reason => {
Expand Down

0 comments on commit 8457138

Please sign in to comment.