Skip to content

Commit

Permalink
v1.1.0 (#2)
Browse files Browse the repository at this point in the history
- Refactoring to separate the `CallAdapter` and the `CallComposite` to reflect the architecture of the Communication UI Library.
  This refactoring required now a service which will let the developer to create the `CallAdapter`.
  The events has been moved to the `CallAdapter`.
- The `CallComposite` have parameters to select the button to hide or display.
- Add the following APIs in the `CallAdapter`:
   - `LeaveCallAsync()`
   - `MuteAsync()`
   - `UnmuteAsync()`
   - `StartScreenShareAsync()`
   - `StopScreenShareAsync()`
 - Add the following events in the `CallAdapter`
   - `OnMicrophoneMuteChanged`
   - `CallEnded`
  • Loading branch information
GillesTourreau authored Jun 11, 2024
1 parent e26df03 commit 1700787
Show file tree
Hide file tree
Showing 42 changed files with 1,623 additions and 651 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/github-actions-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .NET 8.x
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/github-actions-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
type: string
description: The version of the library
required: true
default: 1.0.0
default: 1.1.0
VersionSuffix:
type: string
description: The version suffix of the library (for example rc.1)
Expand All @@ -18,10 +18,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .NET 8.x
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

Expand Down
3 changes: 3 additions & 0 deletions Communication.UI.Blazor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Communication.UI.Blazor.Demo", "tests\Communication.UI.Blazor.Demo\Communication.UI.Blazor.Demo.csproj", "{0499E905-30D5-451E-BFAE-E900E8227075}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{8A9FB002-346C-4751-A00E-158921926CB6}"
ProjectSection(SolutionItems) = preProject
docs\PortedApi.md = docs\PortedApi.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Components", "Components", "{796792A1-0557-4BCF-832C-61A698C190DD}"
ProjectSection(SolutionItems) = preProject
Expand Down
4 changes: 4 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<!-- Add the default using directive for all the code -->
Expand Down
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Azure.Communication.Identity" Version="1.3.1" />
<PackageVersion Include="bunit" Version="1.28.9" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
Expand All @@ -13,7 +14,7 @@
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48" />
<PackageVersion Include="Moq" Version="4.20.70" />
<PackageVersion Include="PosInformatique.FluentAssertions.Json" Version="1.2.0" />
<PackageVersion Include="PosInformatique.Moq.Analyzers" Version="1.4.0" />
<PackageVersion Include="PosInformatique.Moq.Analyzers" Version="1.5.0" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
<PackageVersion Include="xunit" Version="2.8.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.0" />
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ library contains some basic and composites components which use
[Azure Communication Services](https://azure.microsoft.com/fr-fr/products/communication-services) for Chat and Calling
features.

The API of the library try to match as much as possible the
[Azure Communication Services UI Library API](https://azure.github.io/communication-ui-library/?path=/story/overview--page)
with the concept of [composite adapters](https://azure.github.io/communication-ui-library/?path=/docs/composite-adapters--page).

## Demo project
Do not hesitate to run the [tests/Communication.UI.Blazor.Demo](./tests/Communication.UI.Blazor.Demo)
application which contains an example usage of the
Expand Down Expand Up @@ -60,3 +64,7 @@ library.

The library is based on the minimal ASP .NET Core Blazor version which is the 8.0.0 and
can be used for the application based on this version or higher.

## Ported APIs

The list of the ported API is available in the [Ported API](./docs/PortedApi.md) page.
96 changes: 63 additions & 33 deletions docs/Components/CallComposite.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,35 @@ This component is a wrapper of the
library.

To use the component:
- Add the `CallComposite` component.
- Define a reference to the component which allows to call the `LoadAsync()`
method to load the component with the token and ID of the Azure Communication Services to use.
- Register required services by calling the `AddCalling()` method in the main entry of the Blazor application.

```csharp
builder.Services.AddCalling();
```

- Inject the `ICallingService` dependency a use it to create an instance of `ICallAdapter`.
- Add the `CallComposite` component and bind the `Adapter` property with the `ICallAdapter` previously created.

Example:
```razor
<CallComposite @ref="this.callComposite"
OnCallEnded="this.OnCallEnded"
OnParticipantJoined="this.OnParticipantJoined"
OnParticipantLeft="this.OnParticipantLeft">
</CallComposite>
@inject ICallingService CallingService
<CallComposite Adapter="this.callAdapter"
CameraButton="true"
DevicesButton="true"
EndCallButton="true"
MicrophoneButton="true"
MoreButton="@this.moreButton"
ParticipantsButton="true"
PeopleButton="true"
RaiseHandButton="true"
ScreenShareButton="true" />
<button @onclick="this.LoadAsync">Load</button>
@{
private CallComposite? callComposite;
@code
{
private ICallAdapter? callAdapter;
private async Task LoadAsync()
{
Expand All @@ -33,32 +46,25 @@ Example:
new TokenCredential("The ACS token"))
{
DisplayName = "John doe",
Options =
{
CallControls =
{
CameraButton = true,
DevicesButton = true,
EndCallButton = true,
MicrophoneButton = true,
MoreButton = true,
ParticipantsButton = true,
PeopleButton = true,
RaiseHandButton = true,
ScreenShareButton = true,
}
}
};
await this.callComposite!.LoadAsync(args);
this.callAdapter = await this.CallingService.CreateAdapterAsync(args);
this.callAdapter.OnCallEnded += this.OnCallEnded;
this.callAdapter.OnParticipantJoined += this.OnParticipantJoined;
this.callAdapter.OnParticipantLeft += this.OnParticipantLeft;
}
}
```

### Join the call
After the component has been loaded (or after leaving a call), it is possible to join the call
by calling the `JoinCall()` method. You can define if the camera and/or the microphone have to be
activated.
You can manage the `CallComposite` component using the `ICallAdapter` associated. For example, you can
subscribe to different events using a simple delegate.

### Join/Leave the call
After the `ICallAdapter` has been associated to the `CallComposite` component
(or after leaving a call), it is possible to join the call
by calling the `JoinCall()` method on the `ICallAdapter`.
You can define if the camera and/or the microphone have to be activated.

```csharp
private async Task JoinCallAsync()
Expand All @@ -69,12 +75,36 @@ private async Task JoinCallAsync()
MicrophoneOn = true,
};

await this.callComposite!.JoinCallAsync(options);
await this.callAdapter!.JoinCallAsync(options);
}
```

To leave the call, call the `LeaveCallAsync()` method on the `ICallAdapter`. This method
take a boolean parameter `forEveryone` to remove all participants when leaving.

### Start/Stop screen share
To start sharing the screen on the current device, call the `StartScreenShare()` method on the `ICallAdapter`.

To stop sharing the screen on the current device, call the `StopScreenShare()` method on the `ICallAdapter`.

### Mute/Unmute
To mute the microphone of the current user, call the `MuteAsync()` method on the `ICallAdapter`.

To unmute the microphone of the current user, call the `UnmuteAsync()` method on the `ICallAdapter`.

### Events
You can subsribe to the following events:
You can subsribe to the following asynchronous events using a standard delegate method:
- `OnCallEnded`: Occurs then the call is ended.
- `OnMicrophoneMuteChanged`: Occurs when the microphone of a participant is mute/unmute.
- `OnParticipantJoined`: Occurs when a participant join the call.
- `OnParticipantLeft`: Occurs when a participant leave the call.
- `OnParticipantLeft`: Occurs when a participant leave the call.

### Dispose the resources
It is recommanded to implement the `IAsyncDisposable` method in the class which create
and manage the `ICallAdapter` instance.

### Unit tests
The `ICallingService.CreateAdapterAsync()` method returns an instance of `ICallAdapter`
implemented by the `CallAdapter`. By returning interface implementation, developers
have no excuses to perform some units in their code by mocking the `ICallingService`
and `ICallAdapter` interfaces.
70 changes: 70 additions & 0 deletions docs/PortedApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
## Ported API

This section contains the list of the APIs from the
[Adapters for Composites documentation](https://azure.github.io/communication-ui-library/?path=/docs/composite-adapters--page)
which has been ported to this library.

### CallAdapter

#### Methods

| Method | Available | Remarks |
|-------------------------------|------------|------------------------------------------------------|
| onStateChange | TODO | |
| offStateChange | TODO | |
| getState | TODO | |
| dispose | **Done** | |
| holdCall (Beta) | No | Currently in beta |
| joinCall (Deprecated) | No | Deprecated |
| joinCall | Partially | Need to wrap the Call returned object |
| leaveCall | **Done** | |
| resumeCall (Beta) | No | Currently in beta |
| startCamera | TODO | |
| stopCamera | TODO | |
| mute | **Done** | |
| unmute | **Done** | |
| startCall (Beta) | No | Currently in beta |
| startScreenShare | **Done** | |
| stopScreenShare | **Done** | |
| addParticipant (Beta) | No | Currently in beta |
| removeParticipant | TODO | |
| createStreamView | TODO | |
| disposeStreamView | TODO | |
| askDevicePermission | TODO | |
| queryCameras | TODO | |
| queryMicrophones | TODO | |
| querySpeakers | TODO | |
| setCamera | TODO | |
| setMicrophone | TODO | |
| setSpeaker | TODO | |
| startCaptions | TODO | |
| stopCaptions | TODO | |
| raiseHand | TODO | |
| lowerHand | TODO | |
| setCaptionLanguage | TODO | |
| setSpokenLanguage | TODO | |
| submitSurvey | TODO | |
| startVideoBackgroundEffect | TODO | |
| stopVideoBackgroundEffects | TODO | |
| updateBackgroundPickerImages | TODO | |
| updateSelectedVideoBackgroundEffect | TODO | |


#### Events
| Name | Available | Remarks |
|-----------------------------------|-----------|---------|
| participantsJoined | **Done** | |
| participantsLeft | **Done** | |
| isMutedChanged | **Done** | |
| callIdChanged | TODO | |
| isLocalScreenSharingActiveChanged | TODO | |
| displayNameChanged | TODO | |
| isSpeakingChanged | TODO | |
| callEnded | **Done** | |
| diagnosticChanged | TODO | |
| error | TODO | |
| captionsReceived | TODO | |
| isCaptionsActiveChanged | TODO | |
| transferAccepted | TODO | |
| capabilitiesChanged | TODO | |
| spotlightChanged | TODO | |
16 changes: 16 additions & 0 deletions src/Communication.UI.Blazor/AsyncEventHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//-----------------------------------------------------------------------
// <copyright file="AsyncEventHandler.cs" company="P.O.S Informatique">
// Copyright (c) P.O.S Informatique. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace PosInformatique.Azure.Communication.UI.Blazor
{
/// <summary>
/// Represents the method that will handle asynchronously an event when the event provides data.
/// </summary>
/// <typeparam name="TEvent">The type of the event data generated by the event.</typeparam>
/// <param name="event">An object that contains the event data.</param>
/// <returns>A <see cref="Task"/> which represents the asynchronous operation.</returns>
public delegate Task AsyncEventHandler<TEvent>(TEvent @event);
}
Loading

0 comments on commit 1700787

Please sign in to comment.