v1.6.0/conference call upgrade

- anyone can start call
- colision check for calls
- better error handing for calls
This commit is contained in:
2020-08-02 01:11:48 -04:00
parent c80a99cea1
commit 86ee168045
9 changed files with 184 additions and 51 deletions
+31 -8
View File
@@ -33,10 +33,12 @@ export default class CallManager {
this.__accessToken = LocalData().vrT;
this.__sessionInitialized = false;
this.__admin = false;
this.__adminOnly = true;
}
toggleCall(onCall, conference, admin) {
toggleCall(onCall, conference, admin, adminOnly) {
this.listener({ callActionPending: true });
this.__admin = admin;
this.__adminOnly = adminOnly;
if (onCall === true) this.leaveCall();
else this.boot(conference);
}
@@ -56,13 +58,17 @@ export default class CallManager {
console.error('Failed to fetch conference', err);
this.startCall();
});
} else if (opened && !conference) this.startCall();
else console.error('Unable to open Voxeet Session');
} else if (opened && !conference) {
this.startCall();
} else {
this.listener({ onCall: false, muted: false, callActionPending: false });
console.error('Unable to open Voxeet Session');
}
}
async startCall() {
if (this.__admin === true) {
if (!this.__adminOnly || (this.__adminOnly && this.__admin)) {
VoxeetSDK.conference
.create({ alias: LocalData().partyName, pin: LocalData().partyPin })
.create({ alias: `AUTODELETE_${LocalData().partyName}`, pin: LocalData().partyPin })
.then(async (conference) => {
const updatedVoxeet = await UpdateVoxeetApi({
conference,
@@ -72,10 +78,21 @@ export default class CallManager {
})
.then((res) => res.json())
.then((res) => res.status <= 299)
.catch((err) => console.error('Update Voxeet API Error', err));
.catch((err) => {
if (err.conference) {
this.joinCall(err.conference);
return true;
} else {
this.notify(err.message);
this.listener({ onCall: false, muted: false, callActionPending: false });
console.error('Update Voxeet API Error', err);
return false;
}
});
if (updatedVoxeet === true) {
this.joinCall(conference);
} else {
this.listener({ onCall: false, muted: false, callActionPending: false });
console.error('Failed to update party Voxeet');
}
});
@@ -87,7 +104,13 @@ export default class CallManager {
async joinCall(conference) {
const joined = await VoxeetSDK.conference
.join(conference, { constraints: { audio: true, video: false } })
.then(() => true);
.then(() => true)
.catch(e => {
this.listener({ onCall: false, muted: false, callActionPending: false });
this.notify('Unable to join call. Try again in a moment.');
console.error('Error joining call', e);
return true;
});
if (!joined) {
this.startCall();
}
@@ -158,7 +181,7 @@ export default class CallManager {
this.__accessToken !== null ||
this.__refreshToken !== null
) {
await GetVoxeetTokenApi()
await GetVoxeetTokenApi({ partyName: LocalData().partyName })
.then((res) => res.json())
.then((tokenResult) => {
if (tokenResult.status <= 299) {