Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
594ad7b
Adding Quickstart for Network Traversal Java SDK (#22)
AriZavala2 Dec 7, 2021
6a814a3
init project
fangchen0601 Dec 8, 2021
3ce60bf
update incomingcallquickstart
fangchen0601 Dec 20, 2021
a322e79
update git ignore
fangchen0601 Dec 20, 2021
2759795
new project incomingcallsample
fangchen0601 Dec 20, 2021
6e458d2
add sample get controller
fangchen0601 Dec 20, 2021
6843f4a
add sample controller
fangchen0601 Dec 20, 2021
468e2b3
update readme
fangchen0601 Dec 20, 2021
3da6075
add handler function for registering acs event
fangchen0601 Dec 20, 2021
a25d30c
add logger
fangchen0601 Dec 21, 2021
7adfcc7
update readme
fangchen0601 Dec 21, 2021
ef2121c
incoming call event handler and answercall feature
fangchen0601 Dec 22, 2021
3b6cc5b
add EventDispatcher and callback for answering call
fangchen0601 Dec 22, 2021
25ab107
add feature to play audio
fangchen0601 Dec 24, 2021
66afc39
refactor timeout logic
fangchen0601 Dec 26, 2021
29c4c9d
refactor some code
fangchen0601 Dec 29, 2021
45dce76
refactor code, add hangup
fangchen0601 Dec 29, 2021
e4c8ac9
add dtmf envet handler
fangchen0601 Dec 30, 2021
050374a
add transfer feature
fangchen0601 Jan 5, 2022
9c98b89
add transfer call feature and allow list
fangchen0601 Jan 11, 2022
863eb07
put transfer call into dtmf event handler
fangchen0601 Jan 11, 2022
d1a5575
remove unused project
fangchen0601 Jan 11, 2022
e8d75f7
use internal feed for sdk
fangchen0601 Jan 13, 2022
ca8c4a1
update code for testing dtmf
fangchen0601 Jan 14, 2022
02cacf7
update readme
fangchen0601 Jan 14, 2022
3b3da7a
reorder import
fangchen0601 Jan 17, 2022
72f4a6f
Merge branch 'feature/communication-CallingServer-preview' into fanch…
fangchen0601 Jan 17, 2022
3514453
fix compile error
fangchen0601 Jan 18, 2022
3602a3e
add logger
fangchen0601 Jan 18, 2022
801ac75
update import
fangchen0601 Jan 18, 2022
712e5e5
fix import
fangchen0601 Jan 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,9 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# vscode
.vscode/

# Other Tooling #
target
46 changes: 46 additions & 0 deletions get-relay-config-quickstart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
page_type: sample
languages:
- Java
products:
- azure
- azure-communication-networktraversal
- azure-communication-common
---


# Get a relay Configuration

## Prerequisites

- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
- [Java Development Kit (JDK)](https://docs.microsoft.com/azure/developer/java/fundamentals/java-jdk-install) version 8 or above
- [Apache Maven](https://maven.apache.org/download.cgi)
- An deployed Communication Services resource and connection string. For details, see [Create a Communication Services resource](https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource).

## Code Structure

- **./get-relay-config-quickstart/src/main/java/com/communication/quickstart/App.java:** contains code for getting a relay configuration.
- **pom.xml:** Project's Project Object Model, or [POM](https://maven.apache.org/guides/introduction/introduction-to-the-pom.html).

## Before running sample code

1. Open an instance of PowerShell, Windows Terminal, Command Prompt or equivalent and navigate to the directory that you'd like to clone the sample to.
2. `git clone https://github.com/Azure-Samples/communication-services-java-quickstarts.git`
3. With the Communication Services procured in pre-requisites, add connection string in the code at line no 14
```String connectionString = "https://<RESOURCE_NAME>.communication.azure.com/;accesskey=<ACCESS_KEY>";```.

## Run the code

1. Navigate to the directory containing the pom.xml file and compile the project by using command `mvn compile`.
2. Then, build the package using command `mvn package`.
3. Run the command to execute the app `mvn exec:java -Dexec.mainClass="com.communication.quickstart.App" -Dexec.cleanupDaemonThreads=false`. If you are on Windows, run the following command: `mvn exec:java -D"exec.mainClass"="com.communication.quickstart.App" -D"exec.cleanupDaemonThreads"="false"`

## Next Steps

Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients:

[getrelayconfiguration]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/communication/azure-communication-networktraversal/src/samples/java/com/azure/communication/networktraversal
[freesub]: https://azure.microsoft.com/free/
[createinstance_azurecommunicationservicesaccount]: https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource
[package]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/communication/azure-communication-networktraversal/README.md
101 changes: 101 additions & 0 deletions get-relay-config-quickstart/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.communication.quickstart</groupId>
<artifactId>communication-quickstart</artifactId>
<version>1.0-SNAPSHOT</version>

<name>communication-quickstart</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-networktraversal</artifactId>
<version>1.0.0-beta.2</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-common</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-identity</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.68.Final</version>
</dependency>
<dependency>
<groupId>org.kurento</groupId>
<artifactId>kurento-client</artifactId>
<version>6.15.0</version>
</dependency>

</dependencies>

<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.communication.quickstart;

import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.identity.CommunicationIdentityClient;
import com.azure.communication.identity.CommunicationIdentityClientBuilder;
import com.azure.communication.networktraversal.*;
import com.azure.communication.networktraversal.models.*;
import org.kurento.client.WebRtcEndpoint;
import org.kurento.client.MediaPipeline;
import org.kurento.client.KurentoClient;
import java.util.List;
import java.lang.reflect.*;

public class App
{
private static KurentoClient kurento;

// You can find your connection string from your resource in the Azure portal
private static String connectionString = "https://<RESOURCE_NAME>.communication.azure.com/;accesskey=<ACCESS_KEY>";
private static CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClientBuilder()
.connectionString(connectionString)
.buildClient();

private static CommunicationRelayClient communicationRelayClient = new CommunicationRelayClientBuilder()
.connectionString(connectionString)
.buildClient();

public static void main(String[] args)
{
System.out.println("Azure Communication Services - NetworkTraversal Quickstart");

System.out.println("Getting a relay configuration");
getRelayConfiguration();

System.out.println("Getting a relay configuration using Identity");
getRelayConfigurationUsingIdentity();

System.out.println("Getting a relay configuration passing a Route Type");
getRelayConfigurationUsingRouteType();
}

public static void getRelayConfiguration()
{
CommunicationRelayConfiguration config = communicationRelayClient.getRelayConfiguration();

System.out.println("Expires on:" + config.getExpiresOn());
List<CommunicationIceServer> iceServers = config.getIceServers();

for (CommunicationIceServer iceS : iceServers) {
System.out.println("URLS: " + iceS.getUrls());
System.out.println("Username: " + iceS.getUsername());
System.out.println("credential: " + iceS.getCredential());
System.out.println("RouteType: " + iceS.getRouteType());
}

// Now you can configure your WebRtcEndpoint to use TURN credentials

// MediaPipeline pipeline = kurento.createMediaPipeline();
// WebRtcEndpoint webRtcEndpoint = new WebRtcEndpoint.Builder(pipeline).build();

// CommunicationIceServer iceServerToUse = iceServers.get(0);
// String urlToUse = iceServerToUse.getUrls().get(0);

// Format for URL must be user:password@ipaddress:port
// String ipAndPort = urlToUse.substring(5, urlToUse.length());
// webRtcEndpoint.setTurnUrl(iceServerToUse.getUsername()+ ":" + iceServerToUse.getCredential() + "@" + ipAndPort);
}

public static void getRelayConfigurationUsingIdentity()
{
CommunicationUserIdentifier user = communicationIdentityClient.createUser();
System.out.println("User id: " + user.getId());

CommunicationRelayConfiguration config = communicationRelayClient.getRelayConfiguration(user);

System.out.println("Expires on:" + config.getExpiresOn());
List<CommunicationIceServer> iceServers = config.getIceServers();

for (CommunicationIceServer iceS : iceServers) {
System.out.println("URLS: " + iceS.getUrls());
System.out.println("Username: " + iceS.getUsername());
System.out.println("credential: " + iceS.getCredential());
System.out.println("RouteType: " + iceS.getRouteType());
}
}

public static void getRelayConfigurationUsingRouteType()
{
CommunicationRelayConfiguration config = communicationRelayClient.getRelayConfiguration(RouteType.NEAREST);

System.out.println("Expires on:" + config.getExpiresOn());
List<CommunicationIceServer> iceServers = config.getIceServers();

for (CommunicationIceServer iceS : iceServers) {
System.out.println("URLS: " + iceS.getUrls());
System.out.println("Username: " + iceS.getUsername());
System.out.println("credential: " + iceS.getCredential());
System.out.println("RouteType: " + iceS.getRouteType());
}
}
}
102 changes: 102 additions & 0 deletions incomingcallsample/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<distributionManagement>
<repository>
<id>azure-sdk-for-java</id>
<url>https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-java/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>

<repositories>
<repository>
<id>azure-sdk-for-java</id>
<url>https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-java/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>com.communication.incomingcallsample</groupId>
<artifactId>incomingcallsample</artifactId>
<version>0.0.1-SNAPSHOT</version>

<name>incomingcallsample</name>
<description>Demo project for IncomingCall</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
</properties>

<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.23.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-messaging-eventgrid</artifactId>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-cosmos</artifactId>
<version>4.18.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-callingserver</artifactId>
<version>1.0.0-alpha.20220112.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Loading