|
1 | 1 | import React from "react"; |
2 | 2 | import { CallClient, LocalVideoStream, Features, CallAgentKind, VideoStreamRenderer } from '@azure/communication-calling'; |
3 | 3 | import { AzureCommunicationTokenCredential, createIdentifierFromRawId} from '@azure/communication-common'; |
4 | | -import { PrimaryButton } from '@fluentui/react/lib/Button'; |
| 4 | +import { DefaultButton, PrimaryButton } from '@fluentui/react/lib/Button'; |
5 | 5 | import { TextField } from '@fluentui/react/lib/TextField'; |
6 | 6 | import { MessageBar, MessageBarType, Toggle } from '@fluentui/react'; |
7 | 7 | import { Icon } from '@fluentui/react/lib/Icon'; |
@@ -83,7 +83,8 @@ export default class MakeCall extends React.Component { |
83 | 83 | }, |
84 | 84 | preCallDiagnosticsResults: {}, |
85 | 85 | isTeamsUser: false, |
86 | | - identityMri: undefined |
| 86 | + identityMri: undefined, |
| 87 | + activeCallDetails: undefined |
87 | 88 | }; |
88 | 89 |
|
89 | 90 | // override logger to be able to dowload logs locally |
@@ -155,6 +156,16 @@ export default class MakeCall extends React.Component { |
155 | 156 | await this.callClient.createTeamsCallAgent(tokenCredential) : |
156 | 157 | await this.callClient.createCallAgent(tokenCredential, { displayName: userDetails.displayName }); |
157 | 158 | window.callAgent = this.callAgent; |
| 159 | + |
| 160 | + this.callAgent.on('activeCallsUpdated', (args) => { |
| 161 | + console.log(`activeCallsUpdated, activeCalls=${args.activeCallDetails}`); |
| 162 | + this.setState({activeCallDetails: args.activeCallDetails}); |
| 163 | + }); |
| 164 | + |
| 165 | + this.callAgent.on('noActiveCalls', () => { |
| 166 | + console.log('noActiveCalls event received - user no longer in a call'); |
| 167 | + }); |
| 168 | + |
158 | 169 |
|
159 | 170 | this.callAgent.on('callsUpdated', e => { |
160 | 171 | console.log(`callsUpdated, added=${e.added}, removed=${e.removed}`); |
@@ -986,6 +997,25 @@ this.callAgent.on('incomingCall', async (args) => { |
986 | 997 | {this.state.ufdMessages.map((msg, index) => <li key={index}>{msg.msg}</li>)} |
987 | 998 | </MessageBar> |
988 | 999 | } |
| 1000 | + { |
| 1001 | + this.state.activeCallDetails && <MessageBar |
| 1002 | + messageBarType={MessageBarType.info} |
| 1003 | + isMultiline={true} |
| 1004 | + onDismiss={() => { this.setState({ activeCallDetails: undefined }) }} |
| 1005 | + dismissButtonAriaLabel="Close"> |
| 1006 | + <div className="ms-Grid-row ml-2 mr-2"> |
| 1007 | + <b>You're in an active call!</b> |
| 1008 | + <DefaultButton onClick={async () => { |
| 1009 | + const newCall = await this.callAgent.activeCallTransfer(this.state.activeCallDetails, {isTransfer: true}); |
| 1010 | + this.setState({call: newCall}); |
| 1011 | + }}>Transfer to this device</DefaultButton> |
| 1012 | + <DefaultButton onClick={async () => { |
| 1013 | + const newCall = await this.callAgent.activeCallTransfer(this.state.activeCallDetails, {isTransfer: false}); |
| 1014 | + this.setState({call: newCall}); |
| 1015 | + }}>Join here</DefaultButton> |
| 1016 | + </div> |
| 1017 | + </MessageBar> |
| 1018 | + } |
989 | 1019 | { |
990 | 1020 | !this.state.incomingCall && !this.state.call && !this.state.callSurvey && |
991 | 1021 | <div> |
|
0 commit comments