Démarrage rapide : créer et gérer une ressource salle

Ce guide de démarrage rapide vous aide à démarrer avec les salles Azure Communication Services. Une salle (room) est un espace de communication géré par le serveur pour un ensemble connu et fixe de participants qui doivent collaborer pendant une durée prédéterminée. La documentation conceptuelle sur les salles couvre plus d’informations et des cas d’usage potentiels pour rooms.

Modèle objet

Le tableau suivant répertorie les principales propriétés des objets room :

Nom Description
roomId Identificateur room unique.
validFrom Première heure à laquelle une room peut être utilisée.
validUntil Dernière heure à laquelle une room peut être utilisée.
pstnDialOutEnabled Activez ou désactivez la numérotation vers un numéro RTC dans une salle.
participants Liste des participants à un room. Spécifié en tant que CommunicationIdentifier.
roleType Rôle d’un participant à la salle. Il peut être Presenter, Attendee ou Consumer.

Prérequis

Configuration

Ajouter l’extension

Ajoutez l’extension Azure Communication Services pour Azure CLI à l’aide de la commande az extension.

az extension add --name communication

Connectez-vous à Azure CLI

Connectez-vous à Azure CLI. Vous pouvez vous connecter en exécutant la commande az login à partir du terminal et en fournissant vos informations d’identification.

Stocker votre chaîne de connexion dans une variable d’environnement

Vous pouvez configurer la variable d’environnement AZURE_COMMUNICATION_CONNECTION_STRING pour utiliser les opérations de clés d’Azure CLI sans devoir utiliser --connection_string pour passer la chaîne de connexion. Pour configurer une variable d’environnement, ouvrez une fenêtre de console, puis sélectionnez votre système d’exploitation dans les onglets ci-dessous. Remplacez <connectionString> par votre chaîne de connexion.

setx AZURE_COMMUNICATION_CONNECTION_STRING "<connectionString>"

Après l’ajout de la variable d’environnement, il est possible que vous deviez redémarrer tous les programmes en cours d’exécution qui doivent lire la variable d’environnement, y compris la fenêtre de console. Par exemple, si vous utilisez Visual Studio comme éditeur, redémarrez Visual Studio avant d’exécuter l’exemple.

Opérations

Créer une salle

Utilisez la commande rooms create pour créer une salle.

az communication rooms create --presenter-participants "<participantId>" --consumer-participants "<participantId>" --attendee-participant "<participantId>" --valid-from "<valid-from>" --valid-until "<valid-until>" --pstn-dial-out-enabled "<pstn-dial-out-enabled>" --connection-string "<connection-string>"
  • Vous pouvez utiliser <participantId> pour spécifier le type de participant en tant que présentateur-participants, consommateur-participants ou participant-participants. Si vous ne spécifiez pas de valeur, la valeur par défaut est vide.
  • Remplacez <connection-string> par votre chaîne de connexion Azure Communication Services.
  • Vous pouvez utiliser <valid-from> pour spécifier l’horodatage quand la salle peut être rejointe, au format ISO8601, par exemple : 2022-07-14T10:21.
  • Vous pouvez utiliser <valid-until> pour spécifier l’horodatage quand la salle ne peut plus être rejointe, au format ISO8601, par exemple : 2022-07-14T10:21.
  • Utilisez <pstn-dial-out-enabled> au besoin en définissant cet indicateur (valeur « True » ou « False  ») pour activer ou désactiver le RTC pour une salle. Par défaut, cet indicateur est défini sur "False" pendant la création de la salle.

Si vous avez stocké la chaîne de connexion dans des variables d’environnement comme indiqué ci-dessus, vous n’avez pas besoin de les passer à la commande.

az communication rooms create 

Activer la fonctionnalité de RTC pour une salle

La numérotation RTC peut être activée lors du rooms create en définissant le paramètre --pstn-dial-out-enabled comme "True". Vous pouvez modifier cette fonctionnalité pendant rooms update en spécifiant le paramètre --pstn-dial-out-enabled.

az communication rooms create --pstn-dial-out-enabled "<pstn-dial-out-enabled>" --connection-string "<connection-string>"
az communication rooms update --pstn-dial-out-enabled "<pstn-dial-out-enabled>" --room "<roomId>"
  • Pour activer ou désactiver le RTC pour une salle, définissez l’indicateur <pstn-dial-out-enabled> (valeur « True » ou « False »).

Obtenir les salles

La commande rooms get retourne les attributs d’une salle existante.

az communication rooms get --room "<roomId>" 
  • Remplacez <roomId> par votre ID de salle.

Mettre à jour la plage de temps d’une salle

Vous pouvez mettre à jour l’horodatage d’une salle. Avant d’appeler la commande room update, vérifiez que vous avez acquis une nouvelle salle avec une plage de temps valide.

az communication rooms update --valid-from "<valid-from>" --valid-until "<valid-until>" --pstn-dial-out-enabled "<pstn-dial-out-enabled>" --room "<roomId>"
  • Remplacez <valid-from> par l’horodatage au format ISO8601, par exemple : 2022-07-14T10:21, pour spécifier quand la salle peut être rejointe. Doit être utilisé avec --valid-until.
  • Remplacez <valid-until> par l’horodatage au format ISO8601, par exemple : 2022-07-14T10:21, pour spécifier quand la salle ne peut plus être rejointe. Doit être utilisé avec --valid-from.
  • Remplacez <pstn-dial-out-enabled> définit cet indicateur (« True » ou « False ») pour activer ou désactiver la numérotation RTC pour une salle. Doit être utilisé avec --pstn-dial-out-enabled.
  • Remplacez <roomId> par votre ID de salle.

Répertorier toutes les salles actives

La commande rooms list renvoie toutes les salles actives appartenant à votre ressource Azure Communication Services.

az communication rooms list

Ajouter de nouveaux participants ou mettre à jour des participants existants

Lorsque vous créez une salle, vous pouvez mettre à jour la salle en ajoutant un nouveau participant ou en mettant à jour un participant existant. Avant d’appeler la commande room participant add-or-update, vérifiez que vous avez acquis un nouvel utilisateur.

Utilisez la commande identity user create pour créer un participant, identifié par participantId.

az communication identity user create

Ajoutez un utilisateur comme participant à la salle.

az communication rooms participant add-or-update --attendee-participant "<participantId>" --room "<roomId>"
  • Remplacez <participantId> par votre ID de participant. S’il n’existe aucun <participantId> dans la salle, le participant sera ajouté à la salle avec le rôle de participant. Sinon, le rôle du participant est mis à jour vers un rôle de participant.
  • Remplacez <roomId> par votre ID de salle.

Obtenez la liste des participants dans une salle

az communication rooms participant get --room "<roomId>"
  • Remplacez <roomId> par votre ID de salle.

Supprimer un participant d’une salle

Vous pouvez supprimer un participant d’une salle en utilisant rooms participant -remove.

az communication rooms participant remove --room "<roomId>" --participants "<participant1>" "<participant2>" "<participant3>"
  • Remplacez <roomId> par votre ID de salle.
  • Remplacez <participant1><participant2>, <participant3> par votre identifiant utilisateur obtenu précédemment en exécutant la commande identity user create.

Supprimer une salle

De façon similaire à la création d’une salle, vous pouvez aussi supprimer une salle.

Utilisez la commande room delete pour supprimer la salle existante.

az communication rooms delete --room "<roomId>"
  • Remplacez <roomId> par votre ID de salle.

Ce guide de démarrage rapide vous aide à démarrer avec les salles Azure Communication Services. Une salle (room) est un espace de communication géré par le serveur pour un ensemble connu et fixe de participants qui doivent collaborer pendant une durée prédéterminée. La documentation conceptuelle sur les salles couvre plus d’informations et des cas d’usage potentiels pour rooms.

Prérequis

Exemple de code

Vous pouvez consulter et télécharger l’exemple de code pour ce démarrage rapide sur GitHub.

Configuration

Créer une application C#

Dans une fenêtre de console (par exemple cmd, PowerShell ou Bash), utilisez la commande dotnet new pour créer une application console avec le nom RoomsQuickstart. Cette commande crée un projet C# « Hello World » simple avec un seul fichier source : Program.cs.

dotnet new console -o RoomsQuickstart

Remplacez votre répertoire par le dossier d’application que vous venez de créer, puis utilisez la commande dotnet build pour compiler votre application.

cd RoomsQuickstart
dotnet build

Installer le package

Installer la bibliothèque de client Azure Communication Rooms pour .NET avec [NuGet][https://www.nuget.org/] :

dotnet add package Azure.Communication.Rooms

Vous devez utiliser la bibliothèque de client Azure Communication Rooms pour .NET version 1.1.0 ou ultérieure.

Configurer le framework d’application

Dans le fichier Program.cs, ajoutez le code suivant pour importer les espaces de noms requis et créer la structure de programme de base.


using System;
using Azure;
using Azure.Core;
using Azure.Communication.Rooms;

namespace RoomsQuickstart
{
    class Program
    {
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            Console.WriteLine("Azure Communication Services - Rooms Quickstart");

            // Quickstart code goes here
        }
    }
}

Initialiser un client de salle

Créez un objet RoomsClient qui sera utilisé pour créer des rooms et gérer leurs propriétés et leur cycle de vie. La chaîne de connexion de votre Communications Service sera utilisée pour authentifier la demande. Pour plus d’informations sur les chaînes de connexion, consultez cette page.


// Find your Communication Services resource in the Azure portal
var connectionString = "<connection_string>";
RoomsClient roomsClient = new RoomsClient(connectionString);

Créer une salle

Configurer des participants de salle

Pour configurer qui peut rejoindre une salle, vous devez disposer de la liste des identités de ces utilisateurs. Vous pouvez suivre les instructions ici pour créer des utilisateurs et émettre des jetons d’accès. Si vous souhaitez créer les utilisateurs à la demande, vous pouvez également les créer en utilisant CommunicationIdentityClient.

Pour utiliser le CommunicationIdentityClient, installez le package suivant :

dotnet add package Azure.Communication.Identity

Importez également l’espace de noms du package en haut de votre fichier Program.cs :

using Azure.Communication.Identity;

Maintenant, le CommunicationIdentityClient peut être initialisé et utilisé pour créer des utilisateurs :

// Create identities for users who will join the room
CommunicationIdentityClient identityClient = new CommunicationIdentityClient(connectionString);
CommunicationUserIdentifier user1 = identityClient.CreateUser();
CommunicationUserIdentifier user2 = identityClient.CreateUser();

Ensuite, créez la liste des participants de la salle en référençant ces utilisateurs :

List<RoomParticipant> participants = new List<RoomParticipant>()
{
    new RoomParticipant(user1) { Role = ParticipantRole.Presenter },
    new RoomParticipant(user2) // The default participant role is ParticipantRole.Attendee
};

Initialiser la salle

Créez un nouveau room à l’aide de participants défini dans l’extrait de code ci-dessus :

// Create a room
DateTimeOffset validFrom = DateTimeOffset.UtcNow;
DateTimeOffset validUntil = validFrom.AddDays(1);
CancellationToken cancellationToken = new CancellationTokenSource().Token;

CommunicationRoom createdRoom = await roomsClient.CreateRoomAsync(validFrom, validUntil, participants, cancellationToken);

// CreateRoom or CreateRoomAsync methods can take CreateRoomOptions type as an input parameter.
bool pstnDialOutEnabled = false;
CreateRoomOptions createRoomOptions = new CreateRoomOptions()
{
    ValidFrom = validFrom,
    ValidUntil = validUntil,
    PstnDialOutEnabled = pstnDialOutEnabled,
    Participants = participants
};

createdRoom = await roomsClient.CreateRoomAsync(createRoomOptions, cancellationToken);
string roomId = createdRoom.Id;
Console.WriteLine("\nCreated room with id: " + roomId);

Étant donné que les rooms sont des entités côté serveur, vous souhaiterez peut-être en effectuer le suivi et conserver l’roomId dans le support de stockage de votre choix. Vous pouvez référencer l’roomId pour afficher ou mettre à jour les propriétés d’un objet room.

Activer la fonctionnalité de RTC pour une salle

Chaque room a sa numérotation RTC désactivée par défaut. La numérotation RTC peut être activée pour room lors de sa création en définissant le paramètre pstnDialOutEnabled comme true. Cette fonctionnalité peut également être modifiée pour room en émettant une demande de mise à jour pour le paramètre pstnDialOutEnabled.

// Create a room
CancellationToken cancellationToken = new CancellationTokenSource().Token;

// CreateRoom or CreateRoomAsync methods to create a room with PSTN dial out capability
bool pstnDialOutEnabled = true;
CreateRoomOptions createRoomOptions = new CreateRoomOptions()
{
    PstnDialOutEnabled = pstnDialOutEnabled,
};

CommunicationRoom createdRoom = await roomsClient.CreateRoomAsync(createRoomOptions, cancellationToken);
Console.WriteLine("\nCreated a room with PSTN dial out enabled: " + createdRoom.PstnDialOutEnabled);

// UpdateRoom or UpdateRoomAsync methods can take UpdateRoomOptions to enable or disable PSTN dial out capability
pstnDialOutEnabled = false;
UpdateRoomOptions updateRoomOptions = new UpdateRoomOptions()
{
    PstnDialOutEnabled = pstnDialOutEnabled,
};

CommunicationRoom updatedRoom = await roomsClient.UpdateRoomAsync(roomId, updateRoomOptions, cancellationToken);
Console.WriteLine("\nUpdated a room with PSTN dial out enabled: " + updatedRoom.PstnDialOutEnabled);

Obtenir les propriétés d’une salle existante

Récupérez les détails d’une room existante en référençant l’roomId :


// Retrieve the room with corresponding ID
CommunicationRoom room = await roomsClient.GetRoomAsync(roomId);
Console.WriteLine("\nRetrieved room with id: " + room.Id);

Mettre à jour la durée de vie d’une salle

La durée de vie d’une room peut être modifiée en émettant une demande de mise à jour pour les paramètres ValidFrom et ValidUntil. Une salle peut être valide pendant un maximum de six mois.


// Update room lifetime
DateTimeOffset updatedValidFrom = DateTimeOffset.UtcNow;
DateTimeOffset updatedValidUntil = DateTimeOffset.UtcNow.AddDays(10);
CommunicationRoom updatedRoom = await roomsClient.UpdateRoomAsync(roomId, updatedValidFrom, updatedValidUntil, cancellationToken);

// UpdateRoom or UpdateRoomAsync methods can take UpdateRoomOptions type as an input parameter.
bool pstnDialOutEnabled = true;
UpdateRoomOptions updateRoomOptions = new UpdateRoomOptions()
{
    ValidFrom = validFrom,
    ValidUntil = validUntil,
    PstnDialOutEnabled = pstnDialOutEnabled,
};

updatedRoom = await roomsClient.UpdateRoomAsync(roomId, updateRoomOptions, cancellationToken);
Console.WriteLine("\nUpdated room with validFrom: " + updatedRoom.ValidFrom + ", validUntil: " + updatedRoom.ValidUntil + " and pstnDialOutEnabled: " + updatedRoom.PstnDialOutEnabled);

Répertorier toutes les salles actives

Pour récupérer toutes les salles actives, utilisez la méthode GetRoomsAsync exposée sur le client.


// List all active rooms
AsyncPageable<CommunicationRoom> allRooms = roomsClient.GetRoomsAsync();
await foreach (CommunicationRoom currentRoom in allRooms)
{
    Console.WriteLine("\nFirst room id in all active rooms: " + currentRoom.Id);
    break;
}

Ajouter de nouveaux participants ou mettre à jour des participants existants

Pour ajouter de nouveaux participants à un room, utilisez la méthode AddParticipantsAsync exposée sur le client.


List<RoomParticipant> addOrUpdateParticipants = new List<RoomParticipant>();
// Update participant2 from Attendee to Consumer
RoomParticipant participant2 = new RoomParticipant(user2) { Role = ParticipantRole.Consumer };
// Add participant3
CommunicationUserIdentifier user3 = identityClient.CreateUser();
RoomParticipant participant3 = new RoomParticipant(user3) { Role = ParticipantRole.Attendee };
addOrUpdateParticipants.Add(participant2);
addOrUpdateParticipants.Add(participant3);

Response addOrUpdateParticipantsResponse = await roomsClient.AddOrUpdateParticipantsAsync(roomId, addOrUpdateParticipants);
Console.WriteLine("\nAdded or updated participants to room");

Les participants qui ont été ajoutés à une room deviennent éligibles pour prendre part aux appels. Les participants qui ont été mis à jour verront leur nouveau role dans l’appel.

Obtenir la liste des participants

Récupérez la liste des participants pour un room existant en référençant le roomId :


// Get list of participants in room
AsyncPageable<RoomParticipant> existingParticipants = roomsClient.GetParticipantsAsync(roomId);
Console.WriteLine("\nRetrieved participants from room: ");
await foreach (RoomParticipant participant in existingParticipants)
{
    Console.WriteLine($"{participant.CommunicationIdentifier.ToString()},  {participant.Role.ToString()}");
}

Supprimer des participants

Pour supprimer un participant d’une room et révoquer son accès, utilisez la méthode RemoveParticipantsAsync.


// Remove user from room
List<CommunicationIdentifier> removeParticipants = new List<CommunicationIdentifier>();
removeParticipants.Add(user2);

Response removeParticipantsResponse = await roomsClient.RemoveParticipantsAsync(roomId, removeParticipants);
Console.WriteLine("\nRemoved participants from room");

Supprimer le salon

Si vous souhaitez démanteler une room existante, vous pouvez émettre une demande de suppression explicite. Toutes les rooms et leurs ressources associées sont automatiquement supprimées à la fin de leur validité, plus une période de grâce.


// Deletes the specified room
Response deleteRoomResponse = await roomsClient.DeleteRoomAsync(roomId);
Console.WriteLine("\nDeleted room with id: " + roomId);

Exécuter le code

Pour exécuter le code, vérifiez que vous êtes dans le répertoire où se trouve votre fichier Program.cs.


dotnet run

La sortie de l’application décrit chaque action terminée :


Azure Communication Services - Rooms Quickstart

Created a room with id: 99445276259151407

Retrieved room with id: 99445276259151407

Updated room with validFrom: 2023-05-11T22:11:46.784Z, validUntil: 2023-05-21T22:16:46.784Z and pstnDialOutEnabled: true

First room id in all active rooms: 99445276259151407

Added or updated participants to room

Retrieved participants from room:
8:acs:b6aada1f-0b1d-47ac-866f-91aae00a1d01_00000018-ac89-7c76-35f3-343a0d00e901, Presenter
8:acs:b6aada1f-0b1d-47ac-866f-91aae00a1d01_00000018-f00d-aa4b-0cf9-9c3a0d00543e, Consumer
8:acs:b6aada1f-0b1d-47ac-866f-91aae00a1d01_00000018-f00d-aaf2-0cf9-9c3a0d00543f, Attendee

Removed participants from room

Deleted room with id: 99445276259151407

Documentation de référence

Découvrez l’ensemble complet de fonctionnalités des salles Azure Communication Services en consultant la référence du kit SDK .NET ou les informations de référence de l’API REST.

Ce guide de démarrage rapide vous aide à démarrer avec les salles Azure Communication Services. Une salle (room) est un espace de communication géré par le serveur pour un ensemble connu et fixe de participants qui doivent collaborer pendant une durée prédéterminée. La documentation conceptuelle sur les salles couvre plus d’informations et des cas d’usage potentiels pour rooms.

Prérequis

Exemple de code

Vous pouvez consulter et télécharger l’exemple de code pour ce démarrage rapide sur GitHub.

Configuration

Créer une application Java

Dans une fenêtre de console (par exemple cmd, PowerShell ou Bash), utilisez la commande mvn pour créer une application console avec le nom rooms-quickstart. Cette commande crée un projet Java simple nommé « Hello World » avec un seul fichier source : App.java.

mvn archetype:generate -DgroupId=com.communication.quickstart -DartifactId=communication-quickstart -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4 -DinteractiveMode=false

Inclure le package

Vous devez utiliser la bibliothèque de client Azure Communication Rooms pour Java version 1.1.0 ou ultérieure.

Inclure le fichier de nomenclature

Incluez le fichier azure-sdk-bom à votre projet pour établir une dépendance vis-à-vis de la version en disponibilité générale (GA) de la bibliothèque. Dans l’extrait de code suivant, remplacez l’espace réservé {bom_version_to_target} par le numéro de version. Pour en savoir plus sur la nomenclature, consultez le fichier Lisez-moi de la nomenclature du SDK Azure.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-sdk-bom</artifactId>
            <version>{bom_version_to_target}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Incluez ensuite la dépendance directe dans la section des dépendances sans la balise de version.

<dependencies>
  <dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-communication-rooms</artifactId>
  </dependency>
</dependencies>

Inclure une dépendance directe

Si vous voulez établir une dépendance vis-à-vis d’une version particulière de la bibliothèque qui n’est pas présente dans la nomenclature, ajoutez la dépendance directe à votre projet comme suit.

<dependency>
  <groupId>com.azure</groupId>
  <artifactId>azure-communication-rooms</artifactId>
  <version>1.0.0-beta.1</version>
</dependency>

Configurer le framework d’application

Accédez au répertoire /src/main/java/com/communication/quickstart et ouvrez le fichier App.java. Ajoutez le code suivant :


package com.communication.rooms.quickstart;

import com.azure.communication.common.*;
import com.azure.communication.identity.*;
import com.azure.communication.identity.models.*;
import com.azure.core.credential.*;
import com.azure.communication.rooms.*;

import java.io.IOException;
import java.time.*;
import java.util.*;

public class App
{
    public static void main( String[] args ) throws IOException
    {
        System.out.println("Azure Communication Services - Rooms Quickstart");
        // Quickstart code goes here
    }
}

Initialiser un client de salle

Créez un objet RoomsClient qui sera utilisé pour créer des rooms et gérer leurs propriétés et leur cycle de vie. La chaîne de connexion de votre Communications Service sera utilisée pour authentifier la demande. Pour plus d’informations sur les chaînes de connexion, consultez cette page.


// Initialize the rooms client
// Find your Communication Services resource in the Azure portal
String connectionString = "<connection string>";
RoomsClient roomsClient = new RoomsClientBuilder().connectionString(connectionString).buildClient();

Créer une salle

Configurer des participants de salle

Pour configurer qui peut rejoindre une salle, vous devez disposer de la liste des identités de ces utilisateurs. Vous pouvez suivre les instructions ici pour créer des utilisateurs et émettre des jetons d’accès. Si vous souhaitez créer les utilisateurs à la demande, vous pouvez également les créer en utilisant CommunicationIdentityClient.

Pour utiliser CommunicationIdentityClient, ajoutez le package suivant :

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-communication-identity</artifactId>
</dependency>

Importez le package en haut de votre fichier App.java :

import com.azure.communication.identity.CommunicationIdentityClient;
import com.azure.communication.identity.CommunicationIdentityClientBuilder;

Maintenant, le CommunicationIdentityClient peut être initialisé et utilisé pour créer des utilisateurs :

CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClientBuilder()
    .connectionString(connectionString)
    .buildClient();

CommunicationUserIdentifier user1 = communicationClient.createUser();
CommunicationUserIdentifier user2 = communicationClient.createUser();
CommunicationUserIdentifier user3 = communicationClient.createUser();

Ensuite, créez la liste des participants de la salle en référençant ces utilisateurs :

//The default participant role is ParticipantRole.Attendee
RoomParticipant participant_1 = new RoomParticipant(user1);
RoomParticipant participant_2 = new RoomParticipant(user2);
RoomParticipant participant_3 = new RoomParticipant(user3);

List<RoomParticipant> roomParticipants = new ArrayList<RoomParticipant>();

roomParticipants.add(participant_1);
roomParticipants.add(participant_2.setRole(ParticipantRole.CONSUMER));

Initialiser la salle

Créez un nouveau room à l’aide de roomParticipants défini dans l’extrait de code ci-dessus :

OffsetDateTime validFrom = OffsetDateTime.now();
OffsetDateTime validUntil = validFrom.plusDays(30);
boolean pstnDialOutEnabled = false;

CreateRoomOptions createRoomOptions = new CreateRoomOptions()
    .setValidFrom(validFrom)
    .setValidUntil(validUntil)
    .setPstnDialOutEnabled(pstnDialOutEnabled)
    .setParticipants(roomParticipants);

CommunicationRoom roomCreated = roomsClient.createRoom(createRoomOptions);

System.out.println("\nCreated a room with id: " + roomCreated.getRoomId());

Étant donné que les rooms sont des entités côté serveur, vous souhaiterez peut-être en effectuer le suivi et conserver l’roomId dans le support de stockage de votre choix. Vous pouvez référencer l’roomId pour afficher ou mettre à jour les propriétés d’un objet room.

Activer la fonctionnalité de RTC pour une salle

Chaque room a sa numérotation RTC désactivée par défaut. La numérotation RTC peut être activée pour room lors de sa création en définissant le paramètre pstnDialOutEnabled comme true. Cette fonctionnalité peut également être modifiée pour room en émettant une demande de mise à jour pour le paramètre pstnDialOutEnabled.

boolean pstnDialOutEnabled = true;
// Create a room with PSTN dial out capability
CreateRoomOptions createRoomOptions = new CreateRoomOptions()
    .setPstnDialOutEnabled(pstnDialOutEnabled)

CommunicationRoom roomCreated = roomsClient.createRoom(createRoomOptions);
System.out.println("\nCreated a room with PSTN dial out enabled: " + roomCreated.getPstnDialOutEnabled());

// Update a room to enable or disable PSTN dial out capability
pstnDialOutEnabled = false;
UpdateRoomOptions updateRoomOptions = new UpdateRoomOptions()
    .setPstnDialOutEnabled(pstnDialOutEnabled);

CommunicationRoom roomUpdated = roomsClient.updateRoom(roomId, updateRoomOptions);
System.out.println("\nUpdated a room with PSTN dial out enabled: " + roomUpdated.getPstnDialOutEnabled());

Obtenir les propriétés d’une salle existante

Récupérez les détails d’une room existante en référençant l’roomId :


// Retrieve the room with corresponding ID
CommunicationRoom roomResult = roomsClient.getRoom(roomId);

System.out.println("Retrieved room with id: " + roomResult.getRoomId());

Mettre à jour la durée de vie d’une salle

La durée de vie d’une room peut être modifiée en émettant une demande de mise à jour pour les paramètres ValidFrom et ValidUntil. Une salle peut être valide pendant un maximum de six mois.


OffsetDateTime validFrom = OffsetDateTime.now().plusDays(1);
OffsetDateTime validUntil = validFrom.plusDays(1);
boolean pstnDialOutEnabled = true;

UpdateRoomOptions updateRoomOptions = new UpdateRoomOptions()
    .setValidFrom(validFrom)
    .setValidUntil(validUntil)
    .setPstnDialOutEnabled(pstnDialOutEnabled);

CommunicationRoom roomResult = roomsClient.updateRoom(roomId, updateRoomOptions);

System.out.println("Updated room with validFrom: " + roomResult.getValidFrom() + ", validUntil: " + roomResult.getValidUntil() + " and pstnDialOutEnabled: " + roomResult.getPstnDialOutEnabled());

Ajouter ou mettre à jour des participants

Pour ajouter ou mettre à jour des participants dans une salle (room), utilisez la méthode addOrUpdateParticipants exposée sur le client.


List<RoomParticipant> participantsToAddAOrUpdate = new ArrayList<>();

// Adding new participant
 participantsToAddAOrUpdate.add(participant_3.setRole(ParticipantRole.CONSUMER));

// Updating current participant
participantsToAddAOrUpdate.add(participant_2.setRole(ParticipantRole.PRESENTER));

AddOrUpdateParticipantsResult addOrUpdateParticipantsResult = roomsClient.addOrUpdateParticipants(roomId, participantsToAddAOrUpdate);

System.out.println("Participant(s) added/updated");

Les participants qui ont été ajoutés à une room deviennent éligibles pour prendre part aux appels.

Obtenir la liste des participants

Récupérez la liste des participants pour un room existant en référençant le roomId :


// Get list of participants
try {

PagedIterable<RoomParticipant> participants = roomsClient.listParticipants(roomId);

System.out.println("Participants:/n");

for (RoomParticipant participant : participants) {
    System.out.println(participant.getCommunicationIdentifier().getRawId() + " (" + participant.getRole() + ")");
   }
} catch (Exception ex) {
    System.out.println(ex);
}

Supprimer des participants

Pour supprimer un participant d’une room et révoquer son accès, utilisez la méthode removeParticipants.


// Remove a participant from the room
List<CommunicationIdentifier> participantsToRemove = new ArrayList<>();

participantsToRemove.add(participant_3.getCommunicationIdentifier());

RemoveParticipantsResult removeParticipantsResult = roomsClient.removeParticipants(roomId,participantsToRemove);

System.out.println("Participant(s) removed");

Répertorier toutes les salles actives

Récupérez toutes les rooms actives sous votre ressource Azure Communication Services.

try {
    Iterable<PagedResponse<CommunicationRoom>> roomPages = roomsClient.listRooms().iterableByPage();

    System.out.println("Listing all the rooms IDs in the first two pages of the list of rooms:");

    int count = 0;
    for (PagedResponse<CommunicationRoom> page : roomPages) {
        for (CommunicationRoom room : page.getElements()) {
            System.out.println("\n" + room.getRoomId());
        }

        count++;
        if (count >= 2) {
            break;
        }
    }
} catch (Exception ex) {
    System.out.println(ex);
}

Supprimer le salon

Si vous souhaitez démanteler une room existante, vous pouvez émettre une demande de suppression explicite. Toutes les rooms et leurs ressources associées sont automatiquement supprimées à la fin de leur validité, plus une période de grâce.


// Deletes the specified room
roomsClient.deleteRoomWithResponse(roomId, Context.NONE);
System.out.println("\nDeleted the room with ID: " + roomId);

Exécuter le code

Pour exécuter le code, accédez au répertoire qui contient le fichier pom.xml et compilez le programme.


mvn compile

Ensuite, générez le package :


mvn package

Exécutez l’application.

mvn exec:java -D"exec.mainClass"="com.communication.rooms.quickstart" -D"exec.cleanupDaemonThreads"="false"

La sortie de l’application décrit chaque action terminée :


Azure Communication Services - Rooms Quickstart

Created a room with id:  99445276259151407

Retrieved room with id:  99445276259151407

Updated room with validFrom: 2023-05-11T22:11:46.784Z, validUntil: 2023-05-11T22:16:46.784Z and pstnDialOutEnabled: true

Participant(s) added/updated

Participants:
8:acs:b6aada1f-0b1d-47ac-866f-91aae00a1d01_00000018-ac89-7c76-35f3-343a0d00e901 (Attendee)
8:acs:b6aada1f-0b1d-47ac-866f-91aae00a1d01_00000018-ac89-7c76-35f3-343a0d00e902 (Consumer)

Participant(s) removed

Listing all the rooms IDs in the first two pages of the list of rooms: 
99445276259151407
99445276259151408
99445276259151409

Deleted the room with ID:  99445276259151407

Documentation de référence

Découvrez l’ensemble complet de fonctionnalités des salles Azure Communication Services en consultant la référence du kit SDK Java ou les informations de référence de l’API REST.

Ce guide de démarrage rapide vous aide à démarrer avec les salles Azure Communication Services. Une salle (room) est un espace de communication géré par le serveur pour un ensemble connu et fixe de participants qui doivent collaborer pendant une durée prédéterminée. La documentation conceptuelle sur les salles couvre plus d’informations et des cas d’usage potentiels pour rooms.

Prérequis

Exemple de code

Vous pouvez consulter et télécharger l’exemple de code pour ce démarrage rapide sur GitHub.

Configuration

Créer une application Python

Dans une fenêtre de terminal ou de console, créez un dossier pour votre application et accédez-y.

mkdir acs-rooms-quickstart
cd acs-rooms-quickstart

Installer le package

Vous devez utiliser la bibliothèque de client Azure Communication Rooms pour Python version 1.1.0 ou ultérieure.

À partir d’une invite de console, accédez au répertoire contenant le fichier rooms.py, puis exécutez la commande suivante :

pip install azure-communication-rooms

Configurer le framework d’application

Créez un nouveau fichier appelé rooms-quickstart.py et ajoutez la structure de programme de base.

import os
from datetime import datetime, timedelta
from azure.core.exceptions import HttpResponseError
from azure.communication.rooms import (
    RoomsClient,
    RoomParticipant,
    ParticipantRole
)

class RoomsQuickstart(object):
    print("Azure Communication Services - Rooms Quickstart")
    #room method implementations goes here

if __name__ == '__main__':
    rooms = RoomsQuickstart()

Initialiser un client de salle

Créez un objet RoomsClient qui sera utilisé pour créer des rooms et gérer leurs propriétés et leur cycle de vie. La chaîne de connexion de votre Communications Service sera utilisée pour authentifier la demande. Pour plus d’informations sur les chaînes de connexion, consultez cette page.

#Find your Communication Services resource in the Azure portal
connection_string = '<connection_string>'
rooms_client = RoomsClient.from_connection_string(connection_string)

Créer une salle

Configurer des participants de salle

Pour configurer qui peut rejoindre une salle, vous devez disposer de la liste des identités de ces utilisateurs. Vous pouvez suivre les instructions ici pour créer des utilisateurs et émettre des jetons d’accès. Si vous souhaitez créer les utilisateurs à la demande, vous pouvez également les créer en utilisant CommunicationIdentityClient.

Pour utiliser le CommunicationIdentityClient, installez le package suivant :

pip install azure-communication-identity

Importez également l’espace de noms du package en haut de votre fichier rooms-quickstart.py :

from azure.communication.identity import (
    CommunicationIdentityClient
)

Maintenant, le CommunicationIdentityClient peut être initialisé et utilisé pour créer des utilisateurs :

# Create identities for users who will join the room
identity_client = CommunicationIdentityClient.from_connection_string(connection_string)
user1 = identity_client.create_user()
user2 = identity_client.create_user()
user3 = identity_client.create_user()

Ensuite, créez la liste des participants de la salle en référençant ces utilisateurs :

participant_1 = RoomParticipant(communication_identifier=user1, role=ParticipantRole.PRESENTER)
participant_2 = RoomParticipant(communication_identifier=user2, role=ParticipantRole.CONSUMER)
participants = [participant_1, participant_2]

Initialiser la salle

Créez un nouveau room à l’aide de participants défini dans l’extrait de code ci-dessus :

# Create a room
valid_from = datetime.now()
valid_until = valid_from + timedelta(weeks=4)
pstn_dial_out_enabled = False

try:
    create_room = rooms_client.create_room(
        valid_from=valid_from,
        valid_until=valid_until,
        pstn_dial_out_enabled=pstn_dial_out_enabled,
        participants=participants
    )
    print("\nCreated a room with id: " + create_room.id)
except HttpResponseError as ex:
    print(ex)

Étant donné que les rooms sont des entités côté serveur, vous souhaiterez peut-être en effectuer le suivi et conserver l’room.id dans le support de stockage de votre choix. Vous pouvez référencer l’id pour afficher ou mettre à jour les propriétés d’un objet room.

Activer la fonctionnalité de RTC pour une salle

Chaque room a sa numérotation RTC désactivée par défaut. La numérotation RTC peut être activée pour room lors de sa création en définissant le paramètre pstn_dial_out_enabled comme true. Cette fonctionnalité peut également être modifiée pour room en émettant une demande de mise à jour pour le paramètre pstn_dial_out_enabled.

# Create a room with PSTN dial out capability
pstn_dial_out_enabled = True
create_room = rooms_client.create_room(pstn_dial_out_enabled=pstn_dial_out_enabled)
print("\nCreated room with pstn_dial_out_enabled: " + updated_room.pstn_dial_out_enabled)

# Update a room to enable or disable PSTN dial out capability
pstn_dial_out_enabled= False
updated_room = rooms_client.update_room(room_id=room_id, pstn_dial_out_enabled=pstn_dial_out_enabled)
print("\nUpdated room with pstn_dial_out_enabled: " + updated_room.pstn_dial_out_enabled)

Obtenir les propriétés d’une salle existante

Récupérez les détails d’une room existante en référençant l’id :

# Retrieves the room with corresponding ID
room_id = create_room.id
try:
    get_room = rooms_client.get_room(room_id=room_id)
    print("\nRetrieved room with id: ", get_room.id)
except HttpResponseError as ex:
    print(ex)

Mettre à jour la durée de vie d’une salle

La durée de vie d’une room peut être modifiée en émettant une demande de mise à jour pour les paramètres valid_from et valid_until. Une salle peut être valide pendant un maximum de six mois.

# Update the lifetime of a room
valid_from =  datetime.now()
valid_until = valid_from + timedelta(weeks=7)
pstn_dial_out_enabled=True

try:
    updated_room = rooms_client.update_room(room_id=room_id, valid_from=valid_from, valid_until=valid_until, pstn_dial_out_enabled=pstn_dial_out_enabled)
     print("\nUpdated room with validFrom: " + updated_room.valid_from + ", validUntil: " + updated_room.valid_until + " and pstn_dial_out_enabled: " + updated_room.pstn_dial_out_enabled)
except HttpResponseError as ex:
    print(ex)

Répertorier toutes les salles actives

Pour récupérer toutes les salles actives créées sous votre ressource, utilisez la méthode list_rooms exposée sur le client.

# List all active rooms
try:
    rooms = rooms_client.list_rooms()
    count = 0
    for room in rooms:
        if count == 1:
            break
        print("\nPrinting the first room in list"
            "\nRoom Id: " + room.id +
            "\nCreated date time: " + str(room.created_at) +
            "\nValid From: " + str(room.valid_from) + 
            "\nValid Until: " + str(room.valid_until) +
            "\nPSTN Dial-Out Enabled: " + str(room.pstn_dial_out_enabled))
        count += 1
except HttpResponseError as ex:
    print(ex)

Ajouter ou mettre à jour des participants

Pour ajouter de nouveaux participants ou mettre à jour des participants existants dans une salle (room), utilisez la méthode add_or_update_participants exposée sur le client.

# Add or update participants in a room
try:
    # Update existing user2 from consumer to attendee
    participants = []
    participants.append(RoomParticipant(communication_identifier=user2, role=ParticipantRole.ATTENDEE))

    # Add new participant user3
    participants.append(RoomParticipant(communication_identifier=user3, role=ParticipantRole.CONSUMER))
    rooms_client.add_or_update_participants(room_id=room_id, participants=participants)
    print("\nAdd or update participants in room")

except HttpResponseError as ex:
    print('Error in adding or updating participants to room.', ex)

Les participants qui ont été ajoutés à une room deviennent éligibles pour prendre part aux appels.

Répertorier les participants dans une salle

Récupérez la liste des participants pour un room existant en référençant le room_id :

# Get list of participants in room
try:
    participants = rooms_client.list_participants(room_id)
    print('\nParticipants in Room Id :', room_id)
    for p in participants:
        print(p.communication_identifier.properties['id'], p.role)
except HttpResponseError as ex:
    print(ex)

Supprimer des participants

Pour supprimer un participant d’une room et révoquer son accès, utilisez la méthode remove_participants.

# Remove Participants
try:
    participants = [user2]
    rooms_client.remove_participants(room_id=room_id, participants=participants)
    print("\nRemoved participants from room")

except HttpResponseError as ex:
    print(ex)

Supprimer le salon

Si vous souhaitez démanteler une room existante, vous pouvez émettre une demande de suppression explicite. Toutes les rooms et leurs ressources associées sont automatiquement supprimées à la fin de leur validité, plus une période de grâce.

# Delete Room

rooms_client.delete_room(room_id=room_id)
print("\nDeleted room with id: " + room_id)

Exécuter le code

Pour exécuter le code, vérifiez que vous êtes dans le répertoire où se trouve votre fichier rooms-quickstart.py.


python rooms-quickstart.py

La sortie de l’application décrit chaque action terminée :


Azure Communication Services - Rooms Quickstart

Created a room with id:  99445276259151407

Retrieved room with id:  99445276259151407

Updated room with validFrom: 2023-05-03T00:00:00+00:00, validUntil: 2023-06-23T00:00:00+00:00 and pstn_dial_out_enabled: True

Printing the first room in list
Room Id: 99445276259151407
Created date time: 2023-05-03T00:00:00+00:00
Valid From: 2023-05-03T00:00:00+00:00
Valid Until: 2023-06-23T00:00:00+00:00
PSTN Dial-Out Enabled: True

Add or update participants in room

Participants in Room Id : 99445276259151407
8:acs:42a0ff0c-356d-4487-a288-ad0aad95d504_00000018-ef00-6042-a166-563a0d0051c1 Presenter
8:acs:42a0ff0c-356d-4487-a288-ad0aad95d504_00000018-ef00-6136-a166-563a0d0051c2 Consumer
8:acs:42a0ff0c-356d-4487-a288-ad0aad95d504_00000018-ef00-61fd-a166-563a0d0051c3 Attendee

Removed participants from room

Deleted room with id: 99445276259151407

Documentation de référence

Découvrez l’ensemble complet de fonctionnalités des salles Azure Communication Services en consultant la référence du kit SDK Python ou les informations de référence de l’API REST.

Ce guide de démarrage rapide vous aide à démarrer avec les salles Azure Communication Services. Une salle (room) est un espace de communication géré par le serveur pour un ensemble connu et fixe de participants qui doivent collaborer pendant une durée prédéterminée. La documentation conceptuelle sur les salles couvre plus d’informations et des cas d’usage potentiels pour rooms.

Prérequis

Exemple de code

Vous pouvez consulter et télécharger l’exemple de code pour ce démarrage rapide sur GitHub.

Configuration

Créer une application web

Dans une fenêtre de terminal ou de console, créez un dossier pour votre application et accédez-y.

mkdir acs-rooms-quickstart && cd acs-rooms-quickstart

Exécutez npm init pour créer un fichier package.json avec les paramètres par défaut.

npm init -y

Créez un fichier index.js dans lequel le code de ce guide de démarrage rapide sera ajouté.

Installer les packages

Vous devez utiliser la bibliothèque de client Azure Communication Rooms pour JavaScript version 1.1.0 ou ultérieure.

Utilisez la commande npm install pour installer les kits de développement logiciel (SDK) Communication Services pour JavaScript ci-dessous.

npm install @azure/communication-rooms --save

Configurer le framework d’application

Dans le fichier index.js, ajoutez le code suivant : Nous allons ajouter le code pour le démarrage rapide dans la fonction main.

const { RoomsClient } = require('@azure/communication-rooms');

const main = async () => {
  console.log("Azure Communication Services - Rooms Quickstart")

  // Quickstart code goes here

};

main().catch((error) => {
  console.log("Encountered an error");
  console.log(error);
})

Initialiser un client de salle

Créez un objet RoomsClient qui sera utilisé pour créer des rooms et gérer leurs propriétés et leur cycle de vie. La chaîne de connexion de votre Communications Service sera utilisée pour authentifier la demande. Pour plus d’informations sur les chaînes de connexion, consultez cette page.

Ajoutez le code suivant dans index.js dans la fonction main.

const connectionString =
    process.env["COMMUNICATION_CONNECTION_STRING"] ||
    "endpoint=https://<resource-name>.communication.azure.com/;<access-key>";

// create RoomsClient
const roomsClient = new RoomsClient(connectionString);

Créer une salle

Configurer des participants de salle

Pour configurer qui peut rejoindre une salle, vous devez disposer de la liste des identités de ces utilisateurs. Vous pouvez suivre les instructions ici pour créer des utilisateurs et émettre des jetons d’accès. Si vous souhaitez créer les utilisateurs à la demande, vous pouvez également les créer en utilisant CommunicationIdentityClient.

Pour utiliser CommunicationIdentityClient, installez le package npm suivant :

npm install @azure/communication-identity --save

Ajoutez également le package requis suivant en haut de votre fichier index.js :

const { CommunicationIdentityClient } = require('@azure/communication-identity');

Maintenant, le CommunicationIdentityClient peut être initialisé et utilisé pour créer des utilisateurs :

// create identities for users
const identityClient = new CommunicationIdentityClient(connectionString);
const user1 = await identityClient.createUserAndToken(["voip"]);
const user2 = await identityClient.createUserAndToken(["voip"]);

Ensuite, créez la liste des participants de la salle en référençant ces utilisateurs :

const participants = [
  {
      id: user1.user,
      role: "Presenter",
  },
  {
    id: user2.user,
    role: "Consumer",
  }
]

Initialiser la salle

Créez un nouveau room à l’aide de participants défini dans l’extrait de code ci-dessus :

// Create a room
var validFrom = new Date(Date.now());
var validUntil = new Date(validFrom.getTime() + 60 * 60 * 1000);
var pstnDialOutEnabled = false;

const createRoomOptions = {
  validFrom,
  validUntil,
  pstnDialOutEnabled,
  participants
};

const createRoom = await roomsClient.createRoom(createRoomOptions);
const roomId = createRoom.id;
console.log("\nCreated a room with id: ", roomId);

Étant donné que les rooms sont des entités côté serveur, vous souhaiterez peut-être en effectuer le suivi et conserver l’roomId dans le support de stockage de votre choix. Vous pouvez référencer l’roomId pour afficher ou mettre à jour les propriétés d’un objet room.

Activer la fonctionnalité de RTC pour une salle

Chaque room a sa numérotation RTC désactivée par défaut. La numérotation RTC peut être activée pour room lors de sa création en définissant le paramètre pstnDialOutEnabled comme true. Cette fonctionnalité peut également être modifiée pour room en émettant une demande de mise à jour pour le paramètre pstnDialOutEnabled.

// Create a room with PSTN dial out capability
var pstnDialOutEnabled = true;
const createRoomOptions = {
  pstnDialOutEnabled,
};

const createRoom = await roomsClient.createRoom(createRoomOptions);
console.log("\nCreated a room with PSTN dial out enabled: ", createRoom.pstnDialOutEnabled);

// Update a room to enable or disable PSTN dial out capability
pstnDialOutEnabled = false;
const updateRoomOptions = {
  pstnDialOutEnabled,
};

const updateRoom = await roomsClient.updateRoom(roomId, updateRoomOptions);
console.log("\nUpdated a room with PSTN dial out enabled: ", updateRoom.pstnDialOutEnabled);

Obtenir les propriétés d’une salle existante

Récupérez les détails d’une room existante en référençant l’roomId :

// Retrieve the room with corresponding ID
const getRoom = await roomsClient.getRoom(roomId);
console.log("\nRetrieved room with id: ", getRoom.id);

Mettre à jour la durée de vie d’une salle

La durée de vie d’une room peut être modifiée en émettant une demande de mise à jour pour les paramètres validFrom et validUntil. Une salle peut être valide pendant un maximum de six mois.

// Update room lifetime
validFrom.setTime(validUntil.getTime());
validUntil.setTime(validFrom.getTime() + 5 * 60 * 1000);
pstnDialOutEnabled = true;
// request payload to update a room
const updateRoomOptions = {
  validFrom,
  validUntil,
  pstnDialOutEnabled,
};

const updateRoom = await roomsClient.updateRoom(roomId, updateRoomOptions);
console.log("\nUpdated room with validFrom: ", updateRoom.validFrom, ", validUntil: ", updateRoom.validUntil, " and pstnDialOutEnabled: ", updateRoom.pstnDialOutEnabled);

Obtenir la liste des salles

Récupérez votre liste de salles à l’aide de la méthode listRooms :

const roomsList = await roomsClient.listRooms();
console.log("\nRetrieved list of rooms; printing first room:");
for await (const currentRoom of roomsList) {
  // access room data here
  console.log(currentRoom);
  break;
}

Ajouter ou mettre à jour des participants

Pour ajouter de nouveaux participants à un room, utilisez la méthode addOrUpdateParticipants exposée sur le client. Cette méthode met également à jour un participant s’il existe déjà dans la salle.

// Add and update participants
// request payload to add and update participants
const addOUpdateParticipantsList = [
  {
      id: user1.user,
      role: "Presenter",
  },
  {
    id: user2.user,
    role: "Consumer",
  }
]

// add user2 to the room and update user1 to Presenter role
await roomsClient.addOrUpdateParticipants(roomId, addOUpdateParticipantsList);
console.log("\nAdded and updated participants in the room");

Les participants qui ont été ajoutés à une room deviennent éligibles pour prendre part aux appels.

Obtenir la liste des participants

Récupérez la liste des participants pour un room existant en référençant le roomId :

const participantsList = await roomsClient.listParticipants(roomId);
console.log("\nRetrieved participants for room:");
for await (const participant of participantsList) {
  // access participant data here
  console.log(participant);
}

Supprimer des participants

Pour supprimer un participant d’une room et révoquer son accès, utilisez la méthode removeParticipants.

// Remove both users from the room
const removeParticipantsList = [user1.user, user2.user]

// remove both users from the room with the request payload
await roomsClient.removeParticipants(roomId, removeParticipantsList);
console.log("\nRemoved participants from room");

Supprimer le salon

Si vous souhaitez démanteler une room existante, vous pouvez émettre une demande de suppression explicite. Toutes les rooms et leurs ressources associées sont automatiquement supprimées à la fin de leur validité, plus une période de grâce.

// Deletes the specified room
await roomsClient.deleteRoom(roomId);
console.log("\nDeleted room with id: ", roomId)

Exécuter le code

Pour exécuter le code, vérifiez que vous êtes dans le répertoire où se trouve votre fichier index.js.

node index.js

La sortie de l’application décrit chaque action terminée :

Azure Communication Services - Rooms QuickStart

Created a room with id:  99445276259151407

Retrieved room with id:  99445276259151407

Updated room with validFrom:  2023-05-11T22:11:46.784Z, validUntil:  2023-05-11T22:16:46.784Z and pstnDialOutEnabled: true

Retrieved list of rooms; printing first room:

{
  id: "99445276259151407",
  createdAt: "2023-05-11T22:11:50.784Z",
  validFrom: "2023-05-11T22:11:46.784Z",
  validUntil: "2023-05-11T22:16:46.784Z"
}

Added and updated participants in the room

Retrieved participants for room:
{
  id: {
    kind: 'communicationUser',
    communicationUserId: '8:acs:b6aada1f-0b1d-47ac-866f-91aae00a1d01_00000018-ac89-7c76-35f3-343a0d00e901'
  },
  role: 'Presenter'
}
{
  id: {
    kind: 'communicationUser',
    communicationUserId: '8:acs:b6aada1f-0b1d-47ac-866f-91aae00a1d01_00000018-ac89-7ccc-35f3-343a0d00e902'
  },
  role: 'Consumer'
}

Removed participants from room

Deleted room with id:  99445276259151407

Documentation de référence

Découvrez l’ensemble complet de fonctionnalités des salles Azure Communication Services en consultant la référence du kit SDK JavaScript ou les informations de référence de l’API REST.

Étapes suivantes

Vous pouvez découvrir comment rejoindre un appel de salles après la création et la configuration de la salle.

Dans cette section, vous avez appris à :

  • Créer une salle
  • Obtenir les propriétés d’une salle
  • Mettre à jour les propriétés d’une salle
  • Supprimer une salle

Vous souhaiterez peut-être également :