|
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'; |
@@ -84,7 +84,8 @@ export default class MakeCall extends React.Component { |
84 | 84 | preCallDiagnosticsResults: {}, |
85 | 85 | isTeamsUser: false, |
86 | 86 | headsetEnhancement: false, |
87 | | - identityMri: undefined |
| 87 | + identityMri: undefined, |
| 88 | + activeCallDetails: undefined |
88 | 89 | }; |
89 | 90 |
|
90 | 91 | // override logger to be able to dowload logs locally |
@@ -163,6 +164,24 @@ export default class MakeCall extends React.Component { |
163 | 164 | await this.callClient.createTeamsCallAgent(tokenCredential) : |
164 | 165 | await this.callClient.createCallAgent(tokenCredential, { displayName: userDetails.displayName }); |
165 | 166 | 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 | + |
166 | 185 |
|
167 | 186 | this.callAgent.on('callsUpdated', e => { |
168 | 187 | console.log(`callsUpdated, added=${e.added}, removed=${e.removed}`); |
@@ -231,7 +250,7 @@ export default class MakeCall extends React.Component { |
231 | 250 | this.setState({ loggedIn: true }); |
232 | 251 | this.logInComponentRef.current.setCallAgent(this.callAgent); |
233 | 252 | this.logInComponentRef.current.setCallClient(this.callClient); |
234 | | - this.autoJoinMeetingByMeetingLink(); |
| 253 | + this.autoJoinMeetingByMeetingLink(); |
235 | 254 | } catch (e) { |
236 | 255 | console.error(e); |
237 | 256 | } |
@@ -994,6 +1013,32 @@ this.callAgent.on('incomingCall', async (args) => { |
994 | 1013 | {this.state.ufdMessages.map((msg, index) => <li key={index}>{msg.msg}</li>)} |
995 | 1014 | </MessageBar> |
996 | 1015 | } |
| 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 | + } |
997 | 1042 | { |
998 | 1043 | !this.state.incomingCall && !this.state.call && !this.state.callSurvey && |
999 | 1044 | <div> |
|
0 commit comments