Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.0.0-beta.3 (Unreleased)

### Features Added
- Making user identity an optional argument when calling GetRelayConfiguration and GetRelayConfigurationAsync

### Breaking Changes

Expand Down
18 changes: 18 additions & 0 deletions sdk/communication/Azure.Communication.NetworkTraversal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ foreach (CommunicationIceServer iceServer in iceServers)
}
```

## Getting a Relay Configuration for a user without identity async

```C# Snippet:GetRelayConfigurationAsyncWithoutIdentity
Response<CommunicationRelayConfiguration> relayConfiguration = await client.GetRelayConfigurationAsync();
DateTimeOffset turnTokenExpiresOn = relayConfiguration.Value.ExpiresOn;
IReadOnlyList<CommunicationIceServer> iceServers = relayConfiguration.Value.IceServers;
Console.WriteLine($"Expires On: {turnTokenExpiresOn}");
foreach (CommunicationIceServer iceServer in iceServers)
{
foreach (string url in iceServer.Urls)
{
Console.WriteLine($"ICE Server Url: {url}");
}
Console.WriteLine($"ICE Server Username: {iceServer.Username}");
Console.WriteLine($"ICE Server Credential: {iceServer.Credential}");
}
```

## Troubleshooting

> TODO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public CommunicationRelayClient(string connectionString) { }
public CommunicationRelayClient(string connectionString, Azure.Communication.NetworkTraversal.CommunicationRelayClientOptions options) { }
public CommunicationRelayClient(System.Uri endpoint, Azure.AzureKeyCredential keyCredential, Azure.Communication.NetworkTraversal.CommunicationRelayClientOptions options = null) { }
public CommunicationRelayClient(System.Uri endpoint, Azure.Core.TokenCredential tokenCredential, Azure.Communication.NetworkTraversal.CommunicationRelayClientOptions options = null) { }
public virtual Azure.Response<Azure.Communication.NetworkTraversal.CommunicationRelayConfiguration> GetRelayConfiguration(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.NetworkTraversal.CommunicationRelayConfiguration>> GetRelayConfigurationAsync(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Communication.NetworkTraversal.CommunicationRelayConfiguration> GetRelayConfiguration(Azure.Communication.CommunicationUserIdentifier communicationUser = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.NetworkTraversal.CommunicationRelayConfiguration>> GetRelayConfigurationAsync(Azure.Communication.CommunicationUserIdentifier communicationUser = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public partial class CommunicationRelayClientOptions : Azure.Core.ClientOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ protected CommunicationRelayClient()
/// <param name="communicationUser">The <see cref="CommunicationUserIdentifier"/> for whom to issue a token.</param>
/// <param name="cancellationToken">The cancellation token to use.</param>
/// <exception cref="RequestFailedException">The server returned an error.</exception>
public virtual Response<CommunicationRelayConfiguration> GetRelayConfiguration(CommunicationUserIdentifier communicationUser, CancellationToken cancellationToken = default)
public virtual Response<CommunicationRelayConfiguration> GetRelayConfiguration(CommunicationUserIdentifier communicationUser = null, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationRelayClient)}.{nameof(GetRelayConfiguration)}");
scope.Start();
try
{
return RestClient.IssueRelayConfiguration(communicationUser.Id, cancellationToken);
return RestClient.IssueRelayConfiguration(communicationUser?.Id, cancellationToken);
}
catch (Exception ex)
{
Expand All @@ -112,13 +112,13 @@ public virtual Response<CommunicationRelayConfiguration> GetRelayConfiguration(C
/// <summary>Asynchronously gets a Relay Configuration for a <see cref="CommunicationUserIdentifier"/>.</summary>
/// <param name="communicationUser">The <see cref="CommunicationUserIdentifier"/> for whom to issue a token.</param>
/// <param name="cancellationToken">The cancellation token to use.</param>
public virtual async Task<Response<CommunicationRelayConfiguration>> GetRelayConfigurationAsync(CommunicationUserIdentifier communicationUser, CancellationToken cancellationToken = default)
public virtual async Task<Response<CommunicationRelayConfiguration>> GetRelayConfigurationAsync(CommunicationUserIdentifier communicationUser = null, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationRelayClient)}.{nameof(GetRelayConfiguration)}");
scope.Start();
try
{
return await RestClient.IssueRelayConfigurationAsync(communicationUser.Id, cancellationToken).ConfigureAwait(false);
return await RestClient.IssueRelayConfigurationAsync(communicationUser?.Id, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ title: Network traversal
tag: package-2021-06-21-preview
model-namespace: false
require:
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/a59747e42da9d74654106f16c5410620b5941fe0/specification/communication/data-plane/Turn/readme.md
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/4c8162b0a1f7bbd46e9aedc0e19bbe181e549c4c/specification/communication/data-plane/NetworkTraversal/readme.md
payload-flattening-threshold: 3
```
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,35 @@ public async Task GettingTurnCredentialsGeneratesTurnCredentials(AuthMethod auth
Assert.IsFalse(string.IsNullOrWhiteSpace(serverCredential.Credential));
}
}

[Test]
[TestCase(AuthMethod.ConnectionString, TestName = "GettingTurnCredentialsWithConnectionStringWithoutIdentity")]
[TestCase(AuthMethod.KeyCredential, TestName = "GettingTurnCredentialsWithKeyCredentialWithoutIdentity")]
[TestCase(AuthMethod.TokenCredential, TestName = "GettingTurnCredentialsWithTokenCredentialWithoutIdentity")]
public async Task GettingTurnCredentialsGeneratesTurnCredentialsWithoutIdentity(AuthMethod authMethod, params string[] scopes)
{
CommunicationRelayClient client = authMethod switch
{
AuthMethod.ConnectionString => CreateClientWithConnectionString(),
AuthMethod.KeyCredential => CreateClientWithAzureKeyCredential(),
AuthMethod.TokenCredential => CreateClientWithTokenCredential(),
_ => throw new ArgumentOutOfRangeException(nameof(authMethod)),
};

Response<CommunicationRelayConfiguration> turnCredentialsResponse = await client.GetRelayConfigurationAsync();

Assert.IsNotNull(turnCredentialsResponse.Value);
Assert.IsNotNull(turnCredentialsResponse.Value.ExpiresOn);
Assert.IsNotNull(turnCredentialsResponse.Value.IceServers);
foreach (CommunicationIceServer serverCredential in turnCredentialsResponse.Value.IceServers)
{
foreach (string url in serverCredential.Urls)
{
Assert.IsFalse(string.IsNullOrWhiteSpace(url));
}
Assert.IsFalse(string.IsNullOrWhiteSpace(serverCredential.Username));
Assert.IsFalse(string.IsNullOrWhiteSpace(serverCredential.Credential));
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading