2017-03-28 04:40:44 +08:00
|
|
|
import React from 'react';
|
2017-03-28 22:02:23 +08:00
|
|
|
import AudioModal from './audio-modal/component';
|
|
|
|
import Meetings from '/imports/api/meetings';
|
2017-04-19 23:01:28 +08:00
|
|
|
import Users from '/imports/api/users';
|
|
|
|
import Auth from '/imports/ui/services/auth';
|
2017-03-28 22:02:23 +08:00
|
|
|
|
|
|
|
import { showModal } from '/imports/ui/components/app/service';
|
2017-04-19 22:59:57 +08:00
|
|
|
import AudioManager from '/imports/api/audio/client/manager'
|
2017-03-28 22:02:23 +08:00
|
|
|
|
|
|
|
const handleJoinAudio = () => {
|
|
|
|
const handleJoinListenOnly = () => joinListenOnly();
|
|
|
|
return showModal(<AudioModal handleJoinListenOnly={handleJoinListenOnly} />);
|
|
|
|
};
|
|
|
|
|
2017-04-19 22:59:57 +08:00
|
|
|
let audioManager = undefined;
|
|
|
|
const init = () => {
|
2017-04-19 23:01:28 +08:00
|
|
|
const userId = Auth.userID;
|
|
|
|
const User = Users.findOne({ userId });
|
|
|
|
const username = User.user.name;
|
|
|
|
const listenOnly = User.user.listenOnly;
|
|
|
|
|
|
|
|
const Meeting = Meetings.findOne(); //TODO test this with Breakouts
|
|
|
|
const turns = Meeting.turns;
|
|
|
|
const stuns = Meeting.stuns;
|
|
|
|
const voiceBridge = Meeting.voiceBridge;
|
2017-04-19 22:59:57 +08:00
|
|
|
|
2017-04-19 23:01:28 +08:00
|
|
|
const userData = {
|
|
|
|
userId,
|
|
|
|
username,
|
|
|
|
listenOnly,
|
|
|
|
turns,
|
|
|
|
stuns,
|
|
|
|
voiceBridge,
|
|
|
|
};
|
|
|
|
|
|
|
|
audioManager = new AudioManager(userData);
|
|
|
|
};
|
2017-04-19 22:59:57 +08:00
|
|
|
|
|
|
|
let exitAudio = () => audioManager.exitAudio();
|
|
|
|
let joinListenOnly = () => audioManager.joinAudio(true);
|
|
|
|
let joinMicrophone = () => audioManager.joinAudio(false);
|
2017-03-31 01:57:05 +08:00
|
|
|
|
2017-03-28 22:02:23 +08:00
|
|
|
export {
|
2017-04-19 22:59:57 +08:00
|
|
|
init,
|
2017-03-28 22:02:23 +08:00
|
|
|
handleJoinAudio,
|
|
|
|
exitAudio,
|
|
|
|
joinListenOnly,
|
|
|
|
joinMicrophone,
|
2017-03-28 04:40:44 +08:00
|
|
|
};
|