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));
|
10000).fail(failCallback.bind(libname, fail));
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadLibs(libs) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Meteor.startup(() => {
|
Meteor.startup(() => {
|
||||||
loadLib('sip.js');
|
loadLib('sip.js');
|
||||||
loadLib('bbb_webrtc_bridge_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 {getInStorage, setInStorage} from '/imports/ui/components/app/service';
|
||||||
import {callServer} from '/imports/ui/services/api';
|
import {callServer} from '/imports/ui/services/api';
|
||||||
import {clientConfig} from '/config';
|
import {clientConfig} from '/config';
|
||||||
import {joinVertoAudio} from '/imports/api/verto';
|
import {createVertoUserName, joinVertoAudio} from '/imports/api/verto';
|
||||||
|
|
||||||
let triedHangup = false;
|
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
|
// 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
|
// hangup, retry if a call is in progress, send the leave voice conference message to BBB
|
||||||
function exitVoiceCall(afterExitCall) {
|
function exitVoiceCall(afterExitCall) {
|
||||||
@ -34,8 +43,7 @@ function exitVoiceCall(afterExitCall) {
|
|||||||
console.log('Attempting to hangup on WebRTC call');
|
console.log('Attempting to hangup on WebRTC call');
|
||||||
|
|
||||||
// notify BBB-apps we are leaving the call call if we are listen only
|
// notify BBB-apps we are leaving the call call if we are listen only
|
||||||
const uid = getInStorage('userID');
|
if (amIListenOnly()) {
|
||||||
if (Users.findOne({ userId: uid }).user.listenOnly) {
|
|
||||||
callServer('listenOnlyRequestToggle', false);
|
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
|
// join the conference. If listen only send the request to the server
|
||||||
function joinVoiceCall(options) {
|
function joinVoiceCall(options) {
|
||||||
|
const extension = getVoiceBridge();
|
||||||
console.log(options);
|
console.log(options);
|
||||||
if (clientConfig.media.useSIPAudio) {
|
if (clientConfig.media.useSIPAudio) {
|
||||||
|
|
||||||
@ -91,19 +83,30 @@ function joinVoiceCall(options) {
|
|||||||
callServer('listenOnlyRequestToggle', true);
|
callServer('listenOnlyRequestToggle', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const voiceBridge = Meetings.findOne({}).voiceConf;
|
window.BBB = {};
|
||||||
callIntoConference(voiceBridge, function () {}, options.isListenOnly);
|
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;
|
return;
|
||||||
} else {
|
} else {
|
||||||
const uid = getInStorage('userID');
|
const conferenceUsername = createVertoUserName();
|
||||||
const extension = Meetings.findOne().voiceConf;
|
|
||||||
const uName = Users.findOne({ userId: uid }).user.name;
|
|
||||||
conferenceUsername = 'FreeSWITCH User - ' + encodeURIComponent(uName);
|
|
||||||
conferenceIdNumber = '1009';
|
conferenceIdNumber = '1009';
|
||||||
joinVertoAudio({ extension, conferenceUsername, conferenceIdNumber,
|
joinVertoAudio({ extension, conferenceUsername, conferenceIdNumber,
|
||||||
listenOnly: options.isListenOnly });
|
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 {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) {
|
function joinVertoAudio(options) {
|
||||||
joinVertoCall(options);
|
joinVertoCall(options);
|
||||||
@ -11,12 +18,7 @@ function watchVertoVideo(options) {
|
|||||||
|
|
||||||
function joinVertoCall(options) {
|
function joinVertoCall(options) {
|
||||||
console.log('joinVertoCall');
|
console.log('joinVertoCall');
|
||||||
let extension = null;
|
const extension = options.extension || getVoiceBridge();
|
||||||
if (options.extension) {
|
|
||||||
extension = options.extension;
|
|
||||||
} else {
|
|
||||||
extension = Meetings.findOne().voiceConf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isWebRTCAvailable()) {
|
if (!isWebRTCAvailable()) {
|
||||||
return;
|
return;
|
||||||
@ -59,6 +61,7 @@ function joinVertoCall(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
createVertoUserName,
|
||||||
joinVertoAudio,
|
joinVertoAudio,
|
||||||
watchVertoVideo,
|
watchVertoVideo,
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Deskshare from '/imports/api/deskshare';
|
import Deskshare from '/imports/api/deskshare';
|
||||||
import Users from '/imports/api/users';
|
import {conferenceUsername, joinVertoAudio, watchVertoVideo} from '/imports/api/verto';
|
||||||
import Meetings from '/imports/api/meetings';
|
|
||||||
import {joinVertoAudio, watchVertoVideo} from '/imports/api/verto';
|
|
||||||
import {getInStorage} from '/imports/ui/components/app/service';
|
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
|
// 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
|
// desksharing. If it has changed either trigger a call to receive video
|
||||||
@ -29,16 +28,8 @@ function videoIsBroadcasting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function watchDeskshare(options) {
|
function watchDeskshare(options) {
|
||||||
let extension = null;
|
const extension = options.extension || getVoiceBridge();
|
||||||
if (options.extension) {
|
const conferenceUsername = createVertoUserName();
|
||||||
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);
|
|
||||||
conferenceIdNumber = '1009';
|
conferenceIdNumber = '1009';
|
||||||
watchVertoVideo({ extension, conferenceUsername, conferenceIdNumber,
|
watchVertoVideo({ extension, conferenceUsername, conferenceIdNumber,
|
||||||
watchOnly: true });
|
watchOnly: true });
|
||||||
|
Loading…
Reference in New Issue
Block a user