|
| 1 | +--- |
| 2 | +title: include file |
| 3 | +description: Java mute participant |
| 4 | +services: azure-communication-services |
| 5 | +author: Kunaal Punjabi |
| 6 | +ms.service: azure-communication-services |
| 7 | +ms.subservice: azure-communication-services |
| 8 | +ms.date: 03/19/2023 |
| 9 | +ms.topic: include |
| 10 | +ms.topic: include file |
| 11 | +ms.author: kpunjabi |
| 12 | +--- |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- Azure account with an active subscription, for details see [Create an account for free.](https://azure.microsoft.com/free/) |
| 17 | +- Azure Communication Services resource. See [Create an Azure Communication Services resource](../../../quickstarts/create-communication-resource.md?tabs=windows&pivots=platform-azp) |
| 18 | +- Create a new web service application using the [Call Automation SDK](../../../quickstarts/call-automation/callflows-for-customer-interactions.md). |
| 19 | +- [Java Development Kit](/java/azure/jdk/?preserve-view=true&view=azure-java-stable) version 8 or above. |
| 20 | +- [Apache Maven](https://maven.apache.org/download.cgi). |
| 21 | + |
| 22 | +## Create a new Java application |
| 23 | + |
| 24 | +In your terminal or command window, navigate to the directory where you would like to create your Java application. Run the command below to generate the Java project from the maven-archetype-quickstart template. |
| 25 | + |
| 26 | +```console |
| 27 | +mvn archetype:generate -DgroupId=com.communication.quickstart -DartifactId=communication-quickstart -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false |
| 28 | +``` |
| 29 | + |
| 30 | +The command above creates a directory with the same name as `artifactId` argument. Under this directory, `src/main/java` directory contains the project source code, `src/test/java` directory contains the test source. |
| 31 | + |
| 32 | +You'll notice that the 'generate' step created a directory with the same name as the artifactId. Under this directory, `src/main/java` directory contains source code, `src/test/java` directory contains tests, and `pom.xml` file is the project's Project Object Model, or POM. |
| 33 | + |
| 34 | +Update your applications POM file to use Java 8 or higher. |
| 35 | + |
| 36 | +```xml |
| 37 | +<properties> |
| 38 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| 39 | + <maven.compiler.source>1.8</maven.compiler.source> |
| 40 | + <maven.compiler.target>1.8</maven.compiler.target> |
| 41 | +</properties> |
| 42 | +``` |
| 43 | + |
| 44 | +## Configure Azure SDK dev feed |
| 45 | + |
| 46 | +Since the Call Automation SDK version used in this quickstart isn't yet available in Maven Central Repository, we need to add an Azure Artifacts development feed, which contains the latest version of Call Automation SDK. |
| 47 | + |
| 48 | +Add the [azure-sdk-for-java feed](https://dev.azure.com/azure-sdk/public/_artifacts/feed/azure-sdk-for-java) to your `pom.xml`. Follow the instructions after clicking the "Connect to Feed" button. |
| 49 | + |
| 50 | +## Add package references |
| 51 | + |
| 52 | +In your POM file, add the following reference for the project. |
| 53 | + |
| 54 | +**azure-communication-callingserver** |
| 55 | + |
| 56 | +Azure Communication Services Call Automation SDK package is retrieved from the Azure SDK Dev Feed configured above. |
| 57 | + |
| 58 | +``` xml |
| 59 | +<dependency> |
| 60 | + <groupId>com.azure</groupId> |
| 61 | + <artifactId>azure-communication-callautomation</artifactId> |
| 62 | + <version>1.0.0-alpha.20230317.1</version> |
| 63 | +</dependency> |
| 64 | +``` |
| 65 | + |
| 66 | +## Update App.java with code |
| 67 | + |
| 68 | +In your editor of choice, open App.java file and update it with the code provided in [Update app.java with code](../../../quickstarts/call-automation/callflows-for-customer-interactions.md) section. |
| 69 | + |
| 70 | +## Establish a call |
| 71 | + |
| 72 | +By this point you should be familiar with starting calls, if you need to learn more about making a call, follow our [quickstart](../../../quickstarts/call-automation/callflows-for-customer-interactions.md). In this quickstart, we'll answer an incoming call. |
| 73 | + |
| 74 | + |
| 75 | +## Mute participant during a call |
| 76 | + |
| 77 | +``` java |
| 78 | +var target = new CommunicationUserIdentifier(ACS_USER_ID); |
| 79 | +var callConnectionAsync = callAutomationClientAsync.getCallConnectionAsync(CALL_CONNECTION_ID); |
| 80 | +callConnectionAsync.muteParticipantsAsync(target).block(); |
| 81 | +``` |
| 82 | + |
| 83 | +## Participant muted event |
| 84 | + |
| 85 | +``` json |
| 86 | +{ |
| 87 | + "id": "9dff6ffa-a496-4279-979d-f6455cb88b22", |
| 88 | + "source": "calling/callConnections/401f3500-08a0-4e9e-b844-61a65c845a0b", |
| 89 | + "type": "Microsoft.Communication.ParticipantsUpdated", |
| 90 | + "data": { |
| 91 | + "participants": [ |
| 92 | + { |
| 93 | + "identifier": { |
| 94 | + "rawId": "<ACS_USER_ID>", |
| 95 | + "kind": "communicationUser", |
| 96 | + "communicationUser": { |
| 97 | + "id": "<ACS_USER_ID>" |
| 98 | + } |
| 99 | + }, |
| 100 | + "isMuted": true |
| 101 | + }, |
| 102 | + { |
| 103 | + "identifier": { |
| 104 | + "rawId": "<ACS_USER_ID>", |
| 105 | + "kind": "communicationUser", |
| 106 | + "communicationUser": { |
| 107 | + "id": "<ACS_USER_ID>" |
| 108 | + } |
| 109 | + }, |
| 110 | + "isMuted": false |
| 111 | + }, |
| 112 | + { |
| 113 | + "identifier": { |
| 114 | + "rawId": "<ACS_USER_ID>", |
| 115 | + "kind": "communicationUser", |
| 116 | + "communicationUser": { |
| 117 | + "id": "<ACS_USER_ID>" |
| 118 | + } |
| 119 | + }, |
| 120 | + "isMuted": false |
| 121 | + } |
| 122 | + ], |
| 123 | + "sequenceNumber": 4, |
| 124 | + "callConnectionId": "401f3500-08a0-4e9e-b844-61a65c845a0b", |
| 125 | + "serverCallId": "aHR0cHM6Ly9hcGkuZmxpZ2h0cHJveHkuc2t5cGUuY29tL2FwaS92Mi9jcC9jb252LXVzZWEyLTAxLmNvbnYuc2t5cGUuY29tL2NvbnYvRkhjV1lURXFZMENUY0VKUlJ3VHc1UT9pPTQmZT02MzgxNDkzMTEwNDk0NTM2ODQ=", |
| 126 | + "correlationId": "e47198fb-1798-4f3e-b245-4fd06569ad5c" |
| 127 | + }, |
| 128 | + "time": "2023-03-21T17:22:35.4300007+00:00", |
| 129 | + "specversion": "1.0", |
| 130 | + "datacontenttype": "application/json", |
| 131 | + "subject": "calling/callConnections/401f3500-08a0-4e9e-b844-61a65c845a0b" |
| 132 | +} |
| 133 | +``` |
0 commit comments