[mirotalksfu] - implement direct join
هذا الالتزام موجود في:
11
README.md
11
README.md
@@ -103,6 +103,17 @@ $ curl -X POST "http://localhost:3010/api/v1/meeting" -H "authorization: mirotal
|
|||||||
$ curl -X POST "https://sfu.mirotalk.org/api/v1/meeting" -H "authorization: mirotalksfu_default_secret" -H "Content-Type: application/json"
|
$ curl -X POST "https://sfu.mirotalk.org/api/v1/meeting" -H "authorization: mirotalksfu_default_secret" -H "Content-Type: application/json"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Direct Join
|
||||||
|
|
||||||
|
- You can also `join` directly to your `room` by going to https://sfu.mirotalksfu.org/join?room=test&name=mirotalksfu&audio=0&video=0
|
||||||
|
|
||||||
|
| Params | Description | Value |
|
||||||
|
| ------ | ---------------------- | ----------------- |
|
||||||
|
| room | Room Id | test |
|
||||||
|
| name | Your name | mirotalksfu |
|
||||||
|
| audio | Enable / Disable audio | 0/1 or true/false |
|
||||||
|
| video | Enable / Disable video | 0/1 or true/false |
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
- Run the project on a `Linux or Mac` system as the `mediasoup` installation could have issues on `Windows`.
|
- Run the project on a `Linux or Mac` system as the `mediasoup` installation could have issues on `Windows`.
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const hostCfg = {
|
|||||||
protected: config.hostProtected,
|
protected: config.hostProtected,
|
||||||
username: config.hostUsername,
|
username: config.hostUsername,
|
||||||
password: config.hostPassword,
|
password: config.hostPassword,
|
||||||
authenticated: true,
|
authenticated: !config.hostProtected,
|
||||||
};
|
};
|
||||||
|
|
||||||
const apiBasePath = '/api/v1'; // api endpoint path
|
const apiBasePath = '/api/v1'; // api endpoint path
|
||||||
@@ -93,7 +93,11 @@ app.get(['/login'], (req, res) => {
|
|||||||
|
|
||||||
// set new room name and join
|
// set new room name and join
|
||||||
app.get(['/newroom'], (req, res) => {
|
app.get(['/newroom'], (req, res) => {
|
||||||
|
if (hostCfg.authenticated) {
|
||||||
res.sendFile(path.join(__dirname, '../../', 'public/view/newroom.html'));
|
res.sendFile(path.join(__dirname, '../../', 'public/view/newroom.html'));
|
||||||
|
} else {
|
||||||
|
res.sendFile(path.join(__dirname, '../../', 'public/view/login.html'));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// if not allow video/audio
|
// if not allow video/audio
|
||||||
@@ -108,6 +112,18 @@ app.get(['/privacy'], (req, res) => {
|
|||||||
|
|
||||||
// no room name specified to join
|
// no room name specified to join
|
||||||
app.get('/join/', (req, res) => {
|
app.get('/join/', (req, res) => {
|
||||||
|
if (hostCfg.authenticated && Object.keys(req.query).length > 0) {
|
||||||
|
log.debug('Direct Join', req.query);
|
||||||
|
// http://localhost:3010/join?room=test&name=mirotalksfu&audio=1&video=1
|
||||||
|
let roomName = req.query.room;
|
||||||
|
let peerName = req.query.name;
|
||||||
|
let peerAudio = req.query.audio;
|
||||||
|
let peerVideo = req.query.video;
|
||||||
|
if (roomName && peerName && peerAudio && peerVideo) {
|
||||||
|
res.sendFile(path.join(__dirname, '../../', 'public/view/Room.html'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
res.redirect('/');
|
res.redirect('/');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,12 @@ let participantsCount = 0;
|
|||||||
let rc = null;
|
let rc = null;
|
||||||
let producer = null;
|
let producer = null;
|
||||||
|
|
||||||
let peer_name = 'peer_' + getRandomNumber(5);
|
let room_id = getRoomId();
|
||||||
|
let peer_name = getPeerName();
|
||||||
let peer_geo = null;
|
let peer_geo = null;
|
||||||
let peer_info = null;
|
let peer_info = null;
|
||||||
|
|
||||||
let room_id = location.pathname.substring(6);
|
|
||||||
let isEnumerateDevices = false;
|
let isEnumerateDevices = false;
|
||||||
|
|
||||||
let isAudioAllowed = false;
|
let isAudioAllowed = false;
|
||||||
let isVideoAllowed = false;
|
let isVideoAllowed = false;
|
||||||
let isScreenAllowed = false;
|
let isScreenAllowed = false;
|
||||||
@@ -59,16 +58,6 @@ let isButtonsVisible = false;
|
|||||||
|
|
||||||
const socket = io();
|
const socket = io();
|
||||||
|
|
||||||
function getRandomNumber(length) {
|
|
||||||
let result = '';
|
|
||||||
let characters = '0123456789';
|
|
||||||
let charactersLength = characters.length;
|
|
||||||
for (let i = 0; i < length; i++) {
|
|
||||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function initClient() {
|
function initClient() {
|
||||||
if (!DetectRTC.isMobileDevice) {
|
if (!DetectRTC.isMobileDevice) {
|
||||||
setTippy('shareButton', 'Share the room', 'right');
|
setTippy('shareButton', 'Share the room', 'right');
|
||||||
@@ -121,6 +110,30 @@ function setTippy(elem, content, placement) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ####################################################
|
||||||
|
// GET ROOM ID
|
||||||
|
// ####################################################
|
||||||
|
|
||||||
|
function getRoomId() {
|
||||||
|
let qs = new URLSearchParams(window.location.search);
|
||||||
|
let queryRoomId = qs.get('room');
|
||||||
|
let roomId = queryRoomId ? queryRoomId : location.pathname.substring(6);
|
||||||
|
if (roomId == '') {
|
||||||
|
roomId = makeId(12);
|
||||||
|
}
|
||||||
|
return roomId;
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeId(length) {
|
||||||
|
let result = '';
|
||||||
|
let characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
let charactersLength = characters.length;
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
// ENUMERATE DEVICES
|
// ENUMERATE DEVICES
|
||||||
// ####################################################
|
// ####################################################
|
||||||
@@ -220,6 +233,11 @@ function appenChild(device, el) {
|
|||||||
// SOME PEER INFO
|
// SOME PEER INFO
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|
||||||
|
function getPeerName() {
|
||||||
|
let qs = new URLSearchParams(window.location.search);
|
||||||
|
return qs.get('name');
|
||||||
|
}
|
||||||
|
|
||||||
function getPeerInfo() {
|
function getPeerInfo() {
|
||||||
peer_info = {
|
peer_info = {
|
||||||
detect_rtc_version: DetectRTC.version,
|
detect_rtc_version: DetectRTC.version,
|
||||||
@@ -254,6 +272,14 @@ function getPeerGeoLocation() {
|
|||||||
function whoAreYou() {
|
function whoAreYou() {
|
||||||
console.log('04 ----> Who are you');
|
console.log('04 ----> Who are you');
|
||||||
|
|
||||||
|
if (peer_name) {
|
||||||
|
checkMedia();
|
||||||
|
getPeerInfo();
|
||||||
|
shareRoom();
|
||||||
|
joinRoom(peer_name, room_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
allowOutsideClick: false,
|
allowOutsideClick: false,
|
||||||
allowEscapeKey: false,
|
allowEscapeKey: false,
|
||||||
@@ -307,6 +333,16 @@ function handleVideo(e) {
|
|||||||
setColor(startVideoButton, isVideoAllowed ? 'white' : 'red');
|
setColor(startVideoButton, isVideoAllowed ? 'white' : 'red');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkMedia() {
|
||||||
|
let qs = new URLSearchParams(window.location.search);
|
||||||
|
let audio = qs.get('audio').toLowerCase();
|
||||||
|
let video = qs.get('video').toLowerCase();
|
||||||
|
let queryPeerAudio = audio === '1' || audio === 'true';
|
||||||
|
let queryPeerVideo = video === '1' || video === 'true';
|
||||||
|
if (queryPeerAudio != null) isAudioAllowed = queryPeerAudio;
|
||||||
|
if (queryPeerVideo != null) isVideoAllowed = queryPeerVideo;
|
||||||
|
}
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
// SHARE ROOM
|
// SHARE ROOM
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم