Cleans up duplicate code
This commit is contained in:
parent
8fc4c98090
commit
393b49fdbe
@ -42,10 +42,6 @@ function loadLib(libname, success, fail) {
|
||||
10000).fail(failCallback.bind(libname, fail));
|
||||
};
|
||||
|
||||
function loadLibs(libs) {
|
||||
|
||||
}
|
||||
|
||||
Meteor.startup(() => {
|
||||
loadLib('sip.js');
|
||||
loadLib('bbb_webrtc_bridge_sip.js');
|
||||
|
@ -3,10 +3,19 @@ import Meetings from '/imports/api/meetings';
|
||||
import {getInStorage, setInStorage} from '/imports/ui/components/app/service';
|
||||
import {callServer} from '/imports/ui/services/api';
|
||||
import {clientConfig} from '/config';
|
||||
import {joinVertoAudio} from '/imports/api/verto';
|
||||
import {createVertoUserName, joinVertoAudio} from '/imports/api/verto';
|
||||
|
||||
let triedHangup = false;
|
||||
|
||||
function getVoiceBridge() {
|
||||
return Meetings.findOne({}).voiceConf;
|
||||
}
|
||||
|
||||
function amIListenOnly() {
|
||||
const uid = getInStorage('userID');
|
||||
return Users.findOne({ userId: uid }).user.listenOnly;
|
||||
}
|
||||
|
||||
// Periodically check the status of the WebRTC call, when a call has been established attempt to
|
||||
// hangup, retry if a call is in progress, send the leave voice conference message to BBB
|
||||
function exitVoiceCall(afterExitCall) {
|
||||
@ -34,8 +43,7 @@ function exitVoiceCall(afterExitCall) {
|
||||
console.log('Attempting to hangup on WebRTC call');
|
||||
|
||||
// notify BBB-apps we are leaving the call call if we are listen only
|
||||
const uid = getInStorage('userID');
|
||||
if (Users.findOne({ userId: uid }).user.listenOnly) {
|
||||
if (amIListenOnly()) {
|
||||
callServer('listenOnlyRequestToggle', false);
|
||||
}
|
||||
|
||||
@ -60,25 +68,9 @@ function exitVoiceCall(afterExitCall) {
|
||||
};
|
||||
}
|
||||
|
||||
BBB = {};
|
||||
BBB.getMyUserInfo = function (callback) {
|
||||
const uid = getInStorage('userID');
|
||||
console.log(Users);
|
||||
const result = {
|
||||
myUserID: uid,
|
||||
myUsername: Users.findOne({ userId: uid }).user.name,
|
||||
myInternalUserID: uid,
|
||||
myAvatarURL: null,
|
||||
myRole: 'getMyRole',
|
||||
amIPresenter: 'false',
|
||||
voiceBridge: Meetings.findOne({}).voiceConf,
|
||||
dialNumber: null,
|
||||
};
|
||||
return callback(result);
|
||||
};
|
||||
|
||||
// join the conference. If listen only send the request to the server
|
||||
function joinVoiceCall(options) {
|
||||
const extension = getVoiceBridge();
|
||||
console.log(options);
|
||||
if (clientConfig.media.useSIPAudio) {
|
||||
|
||||
@ -91,19 +83,30 @@ function joinVoiceCall(options) {
|
||||
callServer('listenOnlyRequestToggle', true);
|
||||
}
|
||||
|
||||
const voiceBridge = Meetings.findOne({}).voiceConf;
|
||||
callIntoConference(voiceBridge, function () {}, options.isListenOnly);
|
||||
window.BBB = {};
|
||||
window.BBB.getMyUserInfo = function (callback) {
|
||||
const uid = getInStorage('userID');
|
||||
const result = {
|
||||
myUserID: uid,
|
||||
myUsername: Users.findOne({ userId: uid }).user.name,
|
||||
myInternalUserID: uid,
|
||||
myAvatarURL: null,
|
||||
myRole: 'getMyRole',
|
||||
amIPresenter: 'false',
|
||||
voiceBridge: extension,
|
||||
dialNumber: null,
|
||||
};
|
||||
return callback(result);
|
||||
};
|
||||
|
||||
callIntoConference(extension, function () {}, options.isListenOnly);
|
||||
return;
|
||||
} else {
|
||||
const uid = getInStorage('userID');
|
||||
const extension = Meetings.findOne().voiceConf;
|
||||
const uName = Users.findOne({ userId: uid }).user.name;
|
||||
conferenceUsername = 'FreeSWITCH User - ' + encodeURIComponent(uName);
|
||||
const conferenceUsername = createVertoUserName();
|
||||
conferenceIdNumber = '1009';
|
||||
joinVertoAudio({ extension, conferenceUsername, conferenceIdNumber,
|
||||
listenOnly: options.isListenOnly });
|
||||
}
|
||||
}
|
||||
|
||||
export { joinVoiceCall, exitVoiceCall };
|
||||
export { joinVoiceCall, exitVoiceCall, getVoiceBridge, };
|
||||
|
@ -1,5 +1,12 @@
|
||||
import Meetings from '/imports/api/users';
|
||||
import {clientConfig} from '/config';
|
||||
import {getVoiceBridge} from '/imports/api/phone';
|
||||
|
||||
function createVertoUserName() {
|
||||
const uid = getInStorage('userID');
|
||||
const uName = Users.findOne({ userId: uid }).user.name;
|
||||
const conferenceUsername = 'FreeSWITCH User - ' + encodeURIComponent(uName);
|
||||
return conferenceUsername;
|
||||
}
|
||||
|
||||
function joinVertoAudio(options) {
|
||||
joinVertoCall(options);
|
||||
@ -11,12 +18,7 @@ function watchVertoVideo(options) {
|
||||
|
||||
function joinVertoCall(options) {
|
||||
console.log('joinVertoCall');
|
||||
let extension = null;
|
||||
if (options.extension) {
|
||||
extension = options.extension;
|
||||
} else {
|
||||
extension = Meetings.findOne().voiceConf;
|
||||
}
|
||||
const extension = options.extension || getVoiceBridge();
|
||||
|
||||
if (!isWebRTCAvailable()) {
|
||||
return;
|
||||
@ -59,6 +61,7 @@ function joinVertoCall(options) {
|
||||
}
|
||||
|
||||
export {
|
||||
createVertoUserName,
|
||||
joinVertoAudio,
|
||||
watchVertoVideo,
|
||||
};
|
||||
|
@ -1,8 +1,7 @@
|
||||
import Deskshare from '/imports/api/deskshare';
|
||||
import Users from '/imports/api/users';
|
||||
import Meetings from '/imports/api/meetings';
|
||||
import {joinVertoAudio, watchVertoVideo} from '/imports/api/verto';
|
||||
import {conferenceUsername, joinVertoAudio, watchVertoVideo} from '/imports/api/verto';
|
||||
import {getInStorage} from '/imports/ui/components/app/service';
|
||||
import {getVoiceBridge} from '/imports/api/phone';
|
||||
|
||||
// when the meeting information has been updated check to see if it was
|
||||
// desksharing. If it has changed either trigger a call to receive video
|
||||
@ -29,16 +28,8 @@ function videoIsBroadcasting() {
|
||||
}
|
||||
|
||||
function watchDeskshare(options) {
|
||||
let extension = null;
|
||||
if (options.extension) {
|
||||
extension = options.extension;
|
||||
} else {
|
||||
extension = Meetings.findOne().voiceConf;
|
||||
}
|
||||
|
||||
const uid = getInStorage('userID');
|
||||
const uName = Users.findOne({ userId: uid }).user.name;
|
||||
conferenceUsername = 'FreeSWITCH User - ' + encodeURIComponent(uName);
|
||||
const extension = options.extension || getVoiceBridge();
|
||||
const conferenceUsername = createVertoUserName();
|
||||
conferenceIdNumber = '1009';
|
||||
watchVertoVideo({ extension, conferenceUsername, conferenceIdNumber,
|
||||
watchOnly: true });
|
||||
|
Loading…
Reference in New Issue
Block a user