diff --git a/Project/src/MakeCall/MakeCall.js b/Project/src/MakeCall/MakeCall.js index 6b98589..d84880d 100644 --- a/Project/src/MakeCall/MakeCall.js +++ b/Project/src/MakeCall/MakeCall.js @@ -1,7 +1,7 @@ import React from "react"; import { CallClient, LocalVideoStream, Features, CallAgentKind, VideoStreamRenderer } from '@azure/communication-calling'; import { AzureCommunicationTokenCredential, createIdentifierFromRawId} from '@azure/communication-common'; -import { PrimaryButton } from '@fluentui/react/lib/Button'; +import { DefaultButton, PrimaryButton } from '@fluentui/react/lib/Button'; import { TextField } from '@fluentui/react/lib/TextField'; import { MessageBar, MessageBarType, Toggle } from '@fluentui/react'; import { Icon } from '@fluentui/react/lib/Icon'; @@ -83,7 +83,8 @@ export default class MakeCall extends React.Component { }, preCallDiagnosticsResults: {}, isTeamsUser: false, - identityMri: undefined + identityMri: undefined, + activeCallDetails: undefined }; // override logger to be able to dowload logs locally @@ -155,6 +156,17 @@ export default class MakeCall extends React.Component { await this.callClient.createTeamsCallAgent(tokenCredential) : await this.callClient.createCallAgent(tokenCredential, { displayName: userDetails.displayName }); window.callAgent = this.callAgent; + + this.callAgent.on('activeCallsUpdated', (args) => { + console.log(`activeCallsUpdated, activeCalls=${args.activeCallDetails}`); + this.setState({activeCallDetails: args.activeCallDetails}); + }); + + this.callAgent.on('noActiveCalls', () => { + console.log('noActiveCalls event received - user no longer in a call'); + this.setState({activeCallDetails: undefined}); + }); + this.callAgent.on('callsUpdated', e => { console.log(`callsUpdated, added=${e.added}, removed=${e.removed}`); @@ -224,6 +236,8 @@ export default class MakeCall extends React.Component { this.logInComponentRef.current.setCallAgent(this.callAgent); this.logInComponentRef.current.setCallClient(this.callClient); this.autoJoinMeetingByMeetingLink(); + const activeCalls = await this.callAgent.getActiveCallDetails(); + this.setState({ activeCallDetails: activeCalls.callId ? activeCalls : undefined }); } catch (e) { console.error(e); } @@ -986,6 +1000,32 @@ this.callAgent.on('incomingCall', async (args) => { {this.state.ufdMessages.map((msg, index) =>