set state for AudioManager when joining or leaving audio

This commit is contained in:
Matthew Marangoni 2017-06-16 13:22:17 -07:00
parent 6dd71a3ee0
commit 12d42aaecb
2 changed files with 55 additions and 46 deletions

View File

@ -1,7 +1,49 @@
import BaseAudioBridge from '../bridge/base'; import BaseAudioBridge from '../bridge/base';
import VertoBridge from '../bridge/verto'; import VertoBridge from '../bridge/verto';
import SIPBridge from '../bridge/sip'; import SIPBridge from '../bridge/sip';
CallStates = class {
static get init() {
return "initialized state";
}
static get echo() {
return "do echo test state";
}
static get callIntoEcho() {
return "calling into echo test state";
}
static get inEchoTest() {
return "in echo test state";
}
static get joinVoiceConference() {
return "join voice conference state";
}
static get callIntoConference() {
return "calling into conference state";
}
static get inConference() {
return "in conference state";
}
static get transferToConference() {
return "joining from echo into conference state";
}
static get echoTestFailed() {
return "echo test failed state";
}
static get callToListenOnly() {
return "call to listen only state";
}
static get connectToListenOnly() {
return "connecting to listen only state";
}
static get inListenOnly() {
return "in listen only state";
}
static get reconnecting() {
return "reconecting";
}
};
// manages audio calls and audio bridges // manages audio calls and audio bridges
export default class AudioManager { export default class AudioManager {
constructor(userData) { constructor(userData) {
@ -17,7 +59,9 @@ export default class AudioManager {
this.bridge = audioBridge; this.bridge = audioBridge;
this.isListenOnly = false; this.isListenOnly = false;
this.microphoneLockEnforced = userData.microphoneLockEnforced; this.microphoneLockEnforced = userData.microphoneLockEnforced;
this.currentState = this.CallStates.init; this.callStates = new CallStates();
console.log(this.callStates);
this.currentState = this.callStates.init;
callbackToAudioBridge = function (audio) { callbackToAudioBridge = function (audio) {
switch (audio.status) { switch (audio.status) {
@ -42,16 +86,20 @@ export default class AudioManager {
} }
exitAudio() { exitAudio() {
this.bridge.exitAudio(this.isListenOnly); this.bridge.exitAudio(this.isListenOnly);
this.currentState = this.callStates.init;
} }
joinAudio(listenOnly) { joinAudio(listenOnly) {
if (listenOnly || this.microphoneLockEnforced) { if (listenOnly || this.microphoneLockEnforced) {
this.isListenOnly = true; this.isListenOnly = true;
this.bridge.joinListenOnly(callbackToAudioBridge); this.bridge.joinListenOnly(callbackToAudioBridge);
this.currentState = this.callStates.inListenOnly;
} else { } else {
this.bridge.joinMicrophone(callbackToAudioBridge); this.bridge.joinMicrophone(callbackToAudioBridge);
} this.currentState = this.callStates.inConference;
}
console.log("CURRENT STATE: " + this.currentState);
} }
transferToConference() { transferToConference() {
@ -92,45 +140,3 @@ export default class AudioManager {
} }
} }
AudioManager.CallStates = class {
static get init() {
return "initialized state";
}
static get echo() {
return "do echo test state";
}
static get callIntoEcho() {
return "calling into echo test state";
}
static get inEchoTest() {
return "in echo test state";
}
static get joinVoiceConference() {
return "join voice conference state";
}
static get callIntoConference() {
return "calling into conference state";
}
static get inConference() {
return "in conference state";
}
static get transferToConference() {
return "joining from echo into conference state";
}
static get echoTestFailed() {
return "echo test failed state";
}
static get callToListenOnly() {
return "call to listen only state";
}
static get connectToListenOnly() {
return "connecting to listen only state";
}
static get inListenOnly() {
return "in listen only state";
}
static get reconnecting() {
return "reconecting";
}
};

View File

@ -3,6 +3,7 @@ import { createContainer } from 'meteor/react-meteor-data';
import Button from '/imports/ui/components/button/component'; import Button from '/imports/ui/components/button/component';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import { defineMessages, injectIntl } from 'react-intl'; import { defineMessages, injectIntl } from 'react-intl';
import AudioManager from '/imports/api/audio/client/manager';
const intlMessages = defineMessages({ const intlMessages = defineMessages({
joinAudio: { joinAudio: {
@ -26,6 +27,8 @@ class JoinAudioOptions extends React.Component {
} = this.props; } = this.props;
if (isInAudio || isInListenOnly) { if (isInAudio || isInListenOnly) {
// if (AudioManager.currentState == AudioManager.callStates.inConference ||
// AudioManager.currentState == AudioManager.callStates.inListenOnly) {
return ( return (
<Button <Button
onClick={handleCloseAudio} onClick={handleCloseAudio}