Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
25 changes: 25 additions & 0 deletions MoveParticipantsSample/MoveParticipantsSample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35728.132
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoveParticipantsSample", "MoveParticipantsSample\MoveParticipantsSample.csproj", "{006A8CF2-660F-CD4C-D92F-23DF7129C899}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{006A8CF2-660F-CD4C-D92F-23DF7129C899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{006A8CF2-660F-CD4C-D92F-23DF7129C899}.Debug|Any CPU.Build.0 = Debug|Any CPU
{006A8CF2-660F-CD4C-D92F-23DF7129C899}.Release|Any CPU.ActiveCfg = Release|Any CPU
{006A8CF2-660F-CD4C-D92F-23DF7129C899}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {99998281-4DF2-4536-B2AD-266FB84E2025}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace MoveParticipantsSample
{
public class ConfigurationRequest
{
public string AcsConnectionString { get; set; } = string.Empty;
public string AcsPhoneNumber { get; set; } = string.Empty;
// public string CongnitiveServiceEndpoint { get; set; } = string.Empty;
public string CallbackUriHost { get; set; } = string.Empty;
public string AcsInboundSender { get; set; } = string.Empty;
//public string User2 { get; set; } = string.Empty;
//public string User3 { get; set; } = string.Empty;
//public string ACSUserIdentity2 { get; set; } = string.Empty;
//public string ACSUserIdentity3 { get; set; } = string.Empty;
}
}
100 changes: 100 additions & 0 deletions MoveParticipantsSample/MoveParticipantsSample/Helper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using Azure.Communication.CallAutomation;
using System.Net.WebSockets;
using System.Text;
using System.Text.Json;

namespace MoveParticipantsSample
{
public static class Helper
{
public static async Task ProcessRequest(WebSocket webSocket)
{
try
{
var buffer = new byte[1024 * 4];
var cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(60)).Token;
WebSocketReceiveResult receiveResult = await webSocket.ReceiveAsync(new ArraySegment<byte>(buffer), cancellationToken);

while (!receiveResult.CloseStatus.HasValue)
{
string msg = Encoding.UTF8.GetString(buffer, 0, receiveResult.Count);

var response = StreamingData.Parse(msg);

if (response != null)
{
if (response is AudioMetadata audioMetadata)
{
Console.WriteLine("***************************************************************************************");
Console.WriteLine("MEDIA SUBSCRIPTION ID-->" + audioMetadata.MediaSubscriptionId);
Console.WriteLine("ENCODING-->" + audioMetadata.Encoding);
Console.WriteLine("SAMPLE RATE-->" + audioMetadata.SampleRate);
Console.WriteLine("CHANNELS-->" + audioMetadata.Channels);
//Console.WriteLine("LENGTH-->" + audioMetadata.Length);
Console.WriteLine("***************************************************************************************");
}
if (response is AudioData audioData)
{
Console.WriteLine("***************************************************************************************");
Console.WriteLine("DATA-->" + JsonSerializer.Serialize(audioData.Data));
Console.WriteLine("TIMESTAMP-->" + audioData.Timestamp);
Console.WriteLine("IS SILENT-->" + audioData.IsSilent);
if (audioData.Participant != null && audioData.Participant.RawId != null)
{
Console.WriteLine("Participant Id-->" + audioData.Participant.RawId);
}

Console.WriteLine("***************************************************************************************");
}

if (response is TranscriptionMetadata transcriptionMetadata)
{
Console.WriteLine("***************************************************************************************");
Console.WriteLine("TRANSCRIPTION SUBSCRIPTION ID-->" + transcriptionMetadata.TranscriptionSubscriptionId);
Console.WriteLine("LOCALE-->" + transcriptionMetadata.Locale);
Console.WriteLine("CALL CONNECTION ID--?" + transcriptionMetadata.CallConnectionId);
Console.WriteLine("CORRELATION ID-->" + transcriptionMetadata.CorrelationId);
Console.WriteLine("***************************************************************************************");
}
if (response is TranscriptionData transcriptionData)
{
Console.WriteLine("***************************************************************************************");
Console.WriteLine("TEXT-->" + transcriptionData.Text);
Console.WriteLine("FORMAT-->" + transcriptionData.Format);
Console.WriteLine("OFFSET-->" + transcriptionData.Offset);
Console.WriteLine("DURATION-->" + transcriptionData.Duration);
Console.WriteLine("PARTICIPANT-->" + transcriptionData.Participant.RawId);
Console.WriteLine("CONFIDENCE-->" + transcriptionData.Confidence);
Console.WriteLine("RESULT STATUS-->" + transcriptionData.ResultState);
foreach (var word in transcriptionData.Words)
{
Console.WriteLine("WORDS TEXT-->" + word.Text);
Console.WriteLine("WORDS OFFSET-->" + word.Offset);
Console.WriteLine("WORDS DURATION-->" + word.Duration);
}
Console.WriteLine("***************************************************************************************");
}
}

await webSocket.SendAsync(
new ArraySegment<byte>(buffer, 0, receiveResult.Count),
receiveResult.MessageType,
receiveResult.EndOfMessage,
CancellationToken.None);

receiveResult = await webSocket.ReceiveAsync(
new ArraySegment<byte>(buffer), CancellationToken.None);
}

await webSocket.CloseAsync(receiveResult.CloseStatus.Value, receiveResult.CloseStatusDescription, CancellationToken.None);
}
catch (Exception ex)
{
Console.WriteLine($"Exception -> {ex}");
}
finally
{
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Program1.cs" />
<Compile Remove="Program20250703.cs" />
</ItemGroup>

<ItemGroup>
<!--<PackageReference Include="Azure.Communication.CallAutomation" Version="1.2.0-alpha.20250214.1" />-->
<PackageReference Include="Azure.Communication.CallAutomation" Version="1.5.0-alpha.20250604.1" />
<PackageReference Include="Azure.Messaging.EventGrid" Version="4.31.0-alpha.20250513.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
</Project>
Loading