[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 "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" $ 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. # 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 "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"}' $ 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 ## Direct Join
- You can also `join` directly to your `room` by going to - 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 | | Params | Type | Description |
| ------ | ------- | ---------------- | | ------ | ------- | ---------------- |
@ -117,6 +117,7 @@ $ curl -X POST "https://sfu.mirotalk.org/api/v1/join" -H "authorization: mirotal
| name | string | your name | | name | string | your name |
| audio | boolean | enable / disable | | audio | boolean | enable / disable |
| video | boolean | enable / disable | | video | boolean | enable / disable |
| notify | boolean | enable / disable |
## Notes ## Notes

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

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

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

@ -6,5 +6,5 @@ MIROTALK_URL="http://localhost:3010/api/v1/join"
curl $MIROTALK_URL \ curl $MIROTALK_URL \
--header "authorization: $API_KEY" \ --header "authorization: $API_KEY" \
--header "Content-Type: application/json" \ --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 --request POST

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

@ -113,12 +113,13 @@ app.get(['/privacy'], (req, res) => {
app.get('/join/', (req, res) => { app.get('/join/', (req, res) => {
if (hostCfg.authenticated && Object.keys(req.query).length > 0) { if (hostCfg.authenticated && Object.keys(req.query).length > 0) {
log.debug('Direct Join', req.query); 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 roomName = req.query.room;
let peerName = req.query.name; let peerName = req.query.name;
let peerAudio = req.query.audio; let peerAudio = req.query.audio;
let peerVideo = req.query.video; 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')); res.sendFile(path.join(__dirname, '../../', 'public/view/Room.html'));
return; return;
} }

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

@ -31,6 +31,8 @@ let producer = null;
let room_id = getRoomId(); let room_id = getRoomId();
let peer_name = getPeerName(); let peer_name = getPeerName();
let notify = getNotify();
let peer_geo = null; let peer_geo = null;
let peer_info = 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() { function getPeerName() {
let qs = new URLSearchParams(window.location.search); let qs = new URLSearchParams(window.location.search);
return qs.get('name'); return qs.get('name');
} }
// ####################################################
// SOME PEER INFO
// ####################################################
function getPeerInfo() { function getPeerInfo() {
peer_info = { peer_info = {
detect_rtc_version: DetectRTC.version, detect_rtc_version: DetectRTC.version,
@ -276,7 +292,7 @@ function whoAreYou() {
if (peer_name) { if (peer_name) {
checkMedia(); checkMedia();
getPeerInfo(); getPeerInfo();
shareRoom(); notify ? shareRoom() : sound('joined');
joinRoom(peer_name, room_id); joinRoom(peer_name, room_id);
return; return;
} }
@ -305,7 +321,7 @@ function whoAreYou() {
}, },
}).then(() => { }).then(() => {
getPeerInfo(); getPeerInfo();
shareRoom(); notify ? shareRoom() : sound('joined');
joinRoom(peer_name, room_id); joinRoom(peer_name, room_id);
}); });
@ -336,12 +352,18 @@ function handleVideo(e) {
function checkMedia() { function checkMedia() {
let qs = new URLSearchParams(window.location.search); let qs = new URLSearchParams(window.location.search);
let audio = qs.get('audio').toLowerCase(); let audio = qs.get('audio');
let video = qs.get('video').toLowerCase(); let video = qs.get('video');
let queryPeerAudio = audio === '1' || audio === 'true'; if (audio) {
let queryPeerVideo = video === '1' || video === 'true'; audio = audio.toLowerCase();
if (queryPeerAudio != null) isAudioAllowed = queryPeerAudio; let queryPeerAudio = audio === '1' || audio === 'true';
if (queryPeerVideo != null) isVideoAllowed = queryPeerVideo; 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) { async consume(producer_id, peer_name, peer_info) {
this.getConsumeStream(producer_id).then( this.getConsumeStream(producer_id).then(
function ({ consumer, stream, kind }) { function ({ consumer, stream, kind }) {
console.log('CONSUMER', consumer);
this.consumers.set(consumer.id, consumer); this.consumers.set(consumer.id, consumer);
if (kind === 'video') { if (kind === 'video') {

Loading…
Cancel
Save