[mirotalksfu] - add param notify to API join

main
Miroslav Pejic 5 years ago
parent 7059a0a7bd
commit c99fdb3a0a

@ -102,14 +102,14 @@ $ docker-compose down
$ curl -X POST "http://localhost:3010/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"
# The response will give you a entrypoint / URL for the direct join to the meeting.
$ curl -X POST "http://localhost:3010/api/v1/join" -H "authorization: mirotalksfu_default_secret" -H "Content-Type: application/json" --data '{"room":"test","name":"mirotalksfu","audio":"0","video":"0"}'
$ curl -X POST "https://sfu.mirotalk.org/api/v1/join" -H "authorization: mirotalksfu_default_secret" -H "Content-Type: application/json" --data '{"room":"test","name":"mirotalksfu","audio":"0","video":"0"}'
$ curl -X POST "http://localhost:3010/api/v1/join" -H "authorization: mirotalksfu_default_secret" -H "Content-Type: application/json" --data '{"room":"test","name":"mirotalksfu","audio":"0","video":"0","notify":"0"}'
$ curl -X POST "https://sfu.mirotalk.org/api/v1/join" -H "authorization: mirotalksfu_default_secret" -H "Content-Type: application/json" --data '{"room":"test","name":"mirotalksfu","audio":"0","video":"0","notify":"0"}'
```
## Direct Join
- You can also `join` directly to your `room` by going to
- https://sfu.mirotalk.org/join?room=test&name=mirotalksfu&audio=0&video=0
- https://sfu.mirotalk.org/join?room=test&name=mirotalksfu&audio=0&video=0&notify=0
| Params | Type | Description |
| ------ | ------- | ---------------- |
@ -117,6 +117,7 @@ $ curl -X POST "https://sfu.mirotalk.org/api/v1/join" -H "authorization: mirotal
| name | string | your name |
| audio | boolean | enable / disable |
| video | boolean | enable / disable |
| notify | boolean | enable / disable |
## Notes

@ -17,6 +17,7 @@ function getResponse() {
name: 'mirotalksfu',
audio: true,
video: true,
notify: true,
}),
});
}

@ -16,10 +16,11 @@ $headers = [
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = array(
"room" => "test",
"name" => "mirotalksfu",
"audio" => true,
"video" => true,
"room" => "test",
"name" => "mirotalksfu",
"audio" => true,
"video" => true,
"notify" => true,
);
$data_string = json_encode($data);

@ -14,6 +14,7 @@ data = {
"name": "mirotalksfu",
"audio": "true",
"video": "true",
"notify": "true",
}
response = requests.post(

@ -6,5 +6,5 @@ MIROTALK_URL="http://localhost:3010/api/v1/join"
curl $MIROTALK_URL \
--header "authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '{"room":"test","name":"mirotalksfu","audio":"1","video":"1"}' \
--data '{"room":"test","name":"mirotalksfu","audio":"1","video":"1","notify":"1"}' \
--request POST

@ -48,6 +48,7 @@ paths:
- name
- audio
- video
- notify
properties:
room:
type: string
@ -57,6 +58,8 @@ paths:
type: boolean
video:
type: boolean
notify:
type: boolean
consumes:
- 'application/json'
produces:

@ -113,12 +113,13 @@ app.get(['/privacy'], (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
// http://localhost:3010/join?room=test&name=mirotalksfu&audio=1&video=1&notify=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) {
let notify = req.query.notify;
if (roomName && peerName && peerAudio && peerVideo && notify) {
res.sendFile(path.join(__dirname, '../../', 'public/view/Room.html'));
return;
}

@ -30,7 +30,9 @@ module.exports = class ServerApi {
'&audio=' +
data.audio +
'&video=' +
data.video
data.video +
'&notify=' +
data.notify
);
}
};

@ -31,6 +31,8 @@ let producer = null;
let room_id = getRoomId();
let peer_name = getPeerName();
let notify = getNotify();
let peer_geo = null;
let peer_info = null;
@ -231,14 +233,28 @@ function appenChild(device, el) {
}
// ####################################################
// SOME PEER INFO
// API CHECK
// ####################################################
function getNotify() {
let qs = new URLSearchParams(window.location.search);
let notify = qs.get('notify');
if (notify) {
let queryNotify = notify === '1' || notify === 'true';
if (queryNotify != null) return queryNotify;
}
return true;
}
function getPeerName() {
let qs = new URLSearchParams(window.location.search);
return qs.get('name');
}
// ####################################################
// SOME PEER INFO
// ####################################################
function getPeerInfo() {
peer_info = {
detect_rtc_version: DetectRTC.version,
@ -276,7 +292,7 @@ function whoAreYou() {
if (peer_name) {
checkMedia();
getPeerInfo();
shareRoom();
notify ? shareRoom() : sound('joined');
joinRoom(peer_name, room_id);
return;
}
@ -305,7 +321,7 @@ function whoAreYou() {
},
}).then(() => {
getPeerInfo();
shareRoom();
notify ? shareRoom() : sound('joined');
joinRoom(peer_name, room_id);
});
@ -336,12 +352,18 @@ function handleVideo(e) {
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;
let audio = qs.get('audio');
let video = qs.get('video');
if (audio) {
audio = audio.toLowerCase();
let queryPeerAudio = audio === '1' || audio === 'true';
if (queryPeerAudio != null) isAudioAllowed = queryPeerAudio;
}
if (video) {
video = video.toLowerCase();
let queryPeerVideo = video === '1' || video === 'true';
if (queryPeerVideo != null) isVideoAllowed = queryPeerVideo;
}
}
// ####################################################

@ -920,6 +920,8 @@ class RoomClient {
async consume(producer_id, peer_name, peer_info) {
this.getConsumeStream(producer_id).then(
function ({ consumer, stream, kind }) {
console.log('CONSUMER', consumer);
this.consumers.set(consumer.id, consumer);
if (kind === 'video') {

Loading…
Cancel
Save