Skip to content

Commit afb7125

Browse files
Merge branch 'main' into yassirb/4146407
2 parents 4dc1779 + 80b3f66 commit afb7125

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

Project/src/MakeCall/MakeCall.js

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import { CallClient, LocalVideoStream, Features, CallAgentKind, VideoStreamRenderer } from '@azure/communication-calling';
33
import { AzureCommunicationTokenCredential, createIdentifierFromRawId} from '@azure/communication-common';
4-
import { PrimaryButton } from '@fluentui/react/lib/Button';
4+
import { DefaultButton, PrimaryButton } from '@fluentui/react/lib/Button';
55
import { TextField } from '@fluentui/react/lib/TextField';
66
import { MessageBar, MessageBarType, Toggle } from '@fluentui/react';
77
import { Icon } from '@fluentui/react/lib/Icon';
@@ -84,7 +84,8 @@ export default class MakeCall extends React.Component {
8484
preCallDiagnosticsResults: {},
8585
isTeamsUser: false,
8686
headsetEnhancement: false,
87-
identityMri: undefined
87+
identityMri: undefined,
88+
activeCallDetails: undefined
8889
};
8990

9091
// override logger to be able to dowload logs locally
@@ -163,6 +164,24 @@ export default class MakeCall extends React.Component {
163164
await this.callClient.createTeamsCallAgent(tokenCredential) :
164165
await this.callClient.createCallAgent(tokenCredential, { displayName: userDetails.displayName });
165166
window.callAgent = this.callAgent;
167+
168+
try {
169+
this.callAgent.on('activeCallsUpdated', (args) => {
170+
console.log(`activeCallsUpdated, activeCalls=${args.activeCallDetails}`);
171+
this.setState({activeCallDetails: args.activeCallDetails});
172+
});
173+
174+
this.callAgent.on('noActiveCalls', () => {
175+
console.log('noActiveCalls event received - user no longer in a call');
176+
this.setState({activeCallDetails: undefined});
177+
});
178+
const activeCalls = await this.callAgent.getActiveCallDetails();
179+
this.setState({ activeCallDetails: activeCalls.callId ? activeCalls : undefined });
180+
} catch (e) {
181+
console.log('active call transfer not configured for this release version');
182+
}
183+
184+
166185

167186
this.callAgent.on('callsUpdated', e => {
168187
console.log(`callsUpdated, added=${e.added}, removed=${e.removed}`);
@@ -231,7 +250,7 @@ export default class MakeCall extends React.Component {
231250
this.setState({ loggedIn: true });
232251
this.logInComponentRef.current.setCallAgent(this.callAgent);
233252
this.logInComponentRef.current.setCallClient(this.callClient);
234-
this.autoJoinMeetingByMeetingLink();
253+
this.autoJoinMeetingByMeetingLink();
235254
} catch (e) {
236255
console.error(e);
237256
}
@@ -994,6 +1013,32 @@ this.callAgent.on('incomingCall', async (args) => {
9941013
{this.state.ufdMessages.map((msg, index) => <li key={index}>{msg.msg}</li>)}
9951014
</MessageBar>
9961015
}
1016+
{
1017+
this.state.activeCallDetails && !this.state.call && <MessageBar
1018+
messageBarType={MessageBarType.warning}
1019+
isMultiline={true}
1020+
onDismiss={() => { this.setState({ activeCallDetails: undefined }) }}
1021+
dismissButtonAriaLabel="Close">
1022+
<div className="ms-Grid-row">
1023+
<b className="ms-Grid-col">You're in an active call!</b>
1024+
<div className="ms-Grid-col">
1025+
<DefaultButton onClick={async () => {
1026+
const callOptions = await this.getCallOptions({video: false, micMuted: false});
1027+
const newCall = await this.callAgent.activeCallTransfer(this.state.activeCallDetails, {isTransfer: true, joinCallOptions: callOptions});
1028+
this.setState({call: newCall});
1029+
}}>Transfer to this device</DefaultButton>
1030+
</div>
1031+
<div className="ms-Grid-col">
1032+
<DefaultButton onClick={async () => {
1033+
const callOptions = await this.getCallOptions({video: false, micMuted: false});
1034+
const newCall = await this.callAgent.activeCallTransfer(this.state.activeCallDetails, {isTransfer: false, joinCallOptions: callOptions});
1035+
this.setState({call: newCall});
1036+
}}>Add this device</DefaultButton>
1037+
</div>
1038+
1039+
</div>
1040+
</MessageBar>
1041+
}
9971042
{
9981043
!this.state.incomingCall && !this.state.call && !this.state.callSurvey &&
9991044
<div>

0 commit comments

Comments
 (0)