次の方法で共有


Teams 会議ロビーを管理する

重要

Azure Communication Services のこの機能は、現在プレビュー段階にあります。 プレビュー段階の機能は一般公開されており、新規および既存の Microsoft のすべてのお客様が使用できます。

このプレビュー バージョンはサービス レベル アグリーメントなしで提供されており、運用環境のワークロードに使用することは推奨されません。 特定の機能がサポートされていないか、機能が制約されている可能性があります。

詳しくは、Microsoft Azure プレビューの追加使用条件に関するページをご覧ください。

重要

Azure Communication Services のこの機能は、現在プレビュー段階にあります。 プレビュー段階の機能は一般公開されており、新規および既存の Microsoft のすべてのお客様が使用できます。

このプレビュー バージョンはサービス レベル アグリーメントなしで提供されており、運用環境のワークロードに使用することは推奨されません。 特定の機能がサポートされていないか、機能が制約されている可能性があります。

詳しくは、Microsoft Azure プレビューの追加使用条件に関するページをご覧ください。

重要

Azure Communication Services のこの機能は、現在プレビュー段階にあります。 プレビュー段階の機能は一般公開されており、新規および既存の Microsoft のすべてのお客様が使用できます。

このプレビュー バージョンはサービス レベル アグリーメントなしで提供されており、運用環境のワークロードに使用することは推奨されません。 特定の機能がサポートされていないか、機能が制約されている可能性があります。

詳しくは、Microsoft Azure プレビューの追加使用条件に関するページをご覧ください。

この記事では、Azure Communication Service Calling SDK を使用して Teams 会議ロビー機能を実装する方法について説明します。 この機能を使用すると、ユーザーは Teams 会議ロビーからの参加者の許可と拒否、ロビーへの参加通知の受信、ロビー参加者リストの取得を行うことができます。

前提条件

ユーザーは、Microsoft Teams の構成に応じてロビーで終了します。 コントロールについては、「 Teams の構成の詳細」 を参照してください。

Microsoft 365 または Azure Communication Services のユーザーは、Teams 会議に接続されていて、開催者、共同開催者、または発表者の会議の役割を持っている場合、ロビーからユーザーを許可または拒否できます。 会議の役割について詳しくは、こちらをご覧ください

Teams 管理センターで現在の会議参加ポリシーとロビー ポリシーを更新または確認するには、「 Teams ポリシーの詳細」を参照してください。

支援

次の表では、Azure Communication Services Calling SDK でのロビーのサポートを定義します。

ID と通話の種類

アイデンティティーズ Teams 会議 部屋 1 対 1 の通話 グループ通話 1:1 Teams 相互運用機能通話 グループ チームの相互運用機能通話
Communication Services ユーザー ✔️
Microsoft 365 ユーザー ✔️

オペレーション

Calling SDK Lobby 機能は、Communication Services と Microsoft 365 ユーザーの両方に対して次の API 操作をサポートします。

オペレーション Communication Services ユーザー Microsoft 365 ユーザー
認める ✔️* ✔️*
リジェクト ✔️* ✔️*
admitAll ✔️* ✔️*
getParticipants ✔️ ✔️
ロビーの参加者が更新されました ✔️ ✔️

SDK

能力 ウェブ ウェブユーザーインターフェース iOS iOS ユーザーインターフェース アンドロイド Androidのユーザーインターフェース ウィンドウズ
サポートされています ✔️ ✔️ ✔️ ✔️ ✔️ ✔️

* 開催者、共同開催者、または発表者の役割が割り当てられたのは、Communication Services ユーザーと Microsoft 365 ユーザーのみです。

重要

ここに挙げた例は、Calling SDK for JavaScript の 1.15.1-beta.1 で利用可能です。 このクイックスタートを試す際は、必ずこのバージョン以降を使用してください。

SDK をインストールする

npm install コマンドを使用して、JavaScript 用の Azure Communication Services の Common SDK と Calling SDK をインストールします。

npm install @azure/communication-common --save
npm install @azure/communication-calling --save

必要なオブジェクトを初期化する

CallClient インスタンスは、ほとんどの通話操作に必要です。 新しい CallClient インスタンスを作成する際に、Logger インスタンスなどのカスタム オプションを使用してこれを構成できます。

CallClient インスタンスでは、CallAgent を呼び出すことで createCallAgent インスタンスを作成できます。 このメソッドでは、非同期的に CallAgent インスタンス オブジェクトが返されます。

createCallAgent メソッドでは、CommunicationTokenCredential が引数として使用されます。 これは、ユーザー アクセス トークンを受け取ります。

getDeviceManager インスタンスで CallClient メソッドを使用して、deviceManager にアクセスできます。

const { CallClient } = require('@azure/communication-calling');
const { AzureCommunicationTokenCredential} = require('@azure/communication-common');
const { AzureLogger, setLogLevel } = require("@azure/logger");

// Set the logger's log level
setLogLevel('verbose');

// Redirect log output to console, file, buffer, REST API, or whatever location you want
AzureLogger.log = (...args) => {
    console.log(...args); // Redirect log output to console
};

const userToken = '<USER_TOKEN>';
callClient = new CallClient(options);
const tokenCredential = new AzureCommunicationTokenCredential(userToken);
const callAgent = await callClient.createCallAgent(tokenCredential, {displayName: 'optional Azure Communication Services user name'});
const deviceManager = await callClient.getDeviceManager()

Microsoft インフラストラクチャへの SDK 接続を管理する

Call Agent インスタンスは、(呼び出しを結合または開始するために) 呼び出しを管理するのに役立ちます。 呼び出しの SDK を機能させるには、Microsoft インフラストラクチャに接続して着信呼び出しの通知を取得し、他の呼び出しの詳細を調整する必要があります。 Call Agent には、次の 2 つの状態があります。

接続済み - Call AgentConnected connectionStatue 値は、クライアント SDK が接続されており、Microsoft インフラストラクチャから通知を受信できることを意味します。

切断済み - Call AgentDisconnected connectionStatue 値は、SDK の正常な接続を妨げる問題があることを示します。 Call Agent を再作成する必要があります。

  • invalidToken: トークンが有効期限切れであるか、無効な場合、Call Agent インスタンスがこのエラーで切断されます。
  • connectionIssue: クライアントが Microsoft インフラストラクチャに接続する際に問題が発生した場合、多数の再試行ののちに Call AgentconnectionIssue エラーが表示されます。

Call Agent プロパティの現在の値を調べて、ローカル connectionState が Microsoft インフラストラクチャに接続されているかどうかを確認できます。 アクティブな呼び出し中に、connectionStateChanged イベントをリッスンして、Call Agent の状態が接続済みから切断済みに変化したかどうかを判断できます。

const connectionState = callAgentInstance.connectionState;
console.log(connectionState); // it may return either of 'Connected' | 'Disconnected'

const connectionStateCallback = (args) => {
    console.log(args); // it will return an object with oldState and newState, each of having a value of either of 'Connected' | 'Disconnected'
    // it will also return reason, either of 'invalidToken' | 'connectionIssue'
}
callAgentInstance.on('connectionStateChanged', connectionStateCallback);

Lobby クラスまたは Call クラスのオブジェクト TeamsCall を使用すると、ユーザーは Teams 会議ロビー情報にアクセスできます。 これには、API、admitrejectadmitAll が含まれています。これにより、ユーザーは Teams 会議ロビーの参加者を許可および拒否できます。 ユーザーは、participants コレクションを取得し、lobbyParticipantsUpdated イベントをサブスクライブして通知を受信することもできます。

ロビー オブジェクトを取得する

最初に、アドミッターの Call または TeamsCall オブジェクトを取得します。 Teams 会議に参加する方法を確認してくださいLobby オブジェクトは、Call または TeamsCall オブジェクトから取得できます。

const lobby = call.lobby;

ロビー参加者のプロパティを取得する

ロビーにいるユーザーを知るために、participants オブジェクトから Lobby コレクションを取得できます。 これは、RemoteParticipant 状態の InLobby オブジェクトのコレクションです。 participants コレクションを取得するには:

let lobbyParticipants = lobby.participants; // [remoteParticipant, remoteParticipant....]

リモート参加者の識別子を取得します

ロビーから参加者を許可または拒否する前に、リモート参加者の識別子を取得できます。

if(lobbyParticipants.length !== 0){
    let remoteParticipant = lobbyParticipants[0];
}
//You could get the identifier from the Lobby.participants collection
//You could also get the identifier from the lobbyParticipantsUpdated event
const identifier = remoteParticipant.identifier;

identifier は、次のいずれかの CommunicationIdentifier 型になります。

  • { communicationUserId: '<COMMUNICATION_SERVICES_USER_ID'> }: Azure Communication Services ユーザーを表すオブジェクト。
  • { phoneNumber: '<PHONE_NUMBER>' }: E.164 形式で電話番号を表すオブジェクト。
  • { microsoftTeamsUserId: '<MICROSOFT_TEAMS_USER_ID>', isAnonymous?: boolean; cloud?: "public" | "dod" | "gcch" }: Tems ユーザーを表すオブジェクト。
  • { id: string }: 他の識別子の種類に適合しない識別子を表すオブジェクト

ロビーからの参加者を許可、拒否、すべて許可する

ロビーからのユーザーを許可、拒否、またはすべて許可するには、admitrejectadmitAll メソッドを使用できます。 これらは非同期 API で、lobbyParticipantsUpdated リスナーを使用して結果を確認できます。

メソッド admitreject を呼び出すことによって、ロビーからの許可または拒否を行うことができます。 このメソッドは、識別子の MicrosoftTeamsUserIdentifierCommunicationUserIdentifierPhoneNumberIdentifier または UnknownIdentifier を入力として受け取ります。 また、メソッド admitAll を呼び出すことによって、ロビーからすべてのユーザーを許可することもできます。

//admit
await lobby.admit(identifier);
//reject
await lobby.reject(identifier);
//admitAll
await lobby.admitAll();

ロビー更新イベントを処理する

lobbyParticipantsUpdated コレクション内の変更を処理するために、participants イベントをサブスクライブできます。 このイベントは、参加者がロビーに追加または削除されるとトリガーされ、追加または削除された参加者リストが提供されます。

subscribeToCall = (call) => {
    try {
        //Subscribe to lobby's 'lobbyParticipantsUpdated' event for lobbyParticipants update.
        call.lobby.on('lobbyParticipantsUpdated', lobbyParticipantsUpdatedHandler);
    } catch (error) {
        console.error(error);
    }
}

const lobbyParticipantsUpdatedHandler = (event) => {
    event.added.forEach(remoteParticipant => {
        console.log(`${remoteParticipant._displayName} joins the lobby`);
    });
    event.removed.forEach(remoteParticipant => {
        console.log(`${remoteParticipant._displayName} leaves the lobby`);
    })
};

イベントとサブスクリプションの詳細を確認する

SDK をインストールする

プロジェクト レベルの build.gradle ファイルを見つけて、mavenCentral()buildscript の下のリポジトリの一覧に allprojects を追加します。

buildscript {
    repositories {
    ...
        mavenCentral()
    ...
    }
}
allprojects {
    repositories {
    ...
        mavenCentral()
    ...
    }
}

次に、モジュール レベルの build.gradle ファイルで、次の行を dependencies セクションに追加します。

dependencies {
    ...
    implementation 'com.azure.android:azure-communication-calling:1.0.0'
    ...
}

必要なオブジェクトを初期化する

CallAgent インスタンスを作成するには、createCallAgent インスタンス上で CallClient メソッドを呼び出す必要があります。 この呼び出しは、CallAgent インスタンス オブジェクトを非同期に返します。

createCallAgent メソッドは、CommunicationUserCredentialをカプセル化する を引数として受け取ります。

DeviceManager にアクセスするには、まず callAgent インスタンスを作成する必要があります。 それから、CallClient.getDeviceManager メソッドを使用して DeviceManager を取得できます。

String userToken = '<user token>';
CallClient callClient = new CallClient();
CommunicationTokenCredential tokenCredential = new CommunicationTokenCredential(userToken);
android.content.Context appContext = this.getApplicationContext(); // From within an activity, for instance
CallAgent callAgent = callClient.createCallAgent(appContext, tokenCredential).get();
DeviceManager deviceManager = callClient.getDeviceManager(appContext).get();

呼び出し元の表示名を設定するには、この代替メソッドを使用します。

String userToken = '<user token>';
CallClient callClient = new CallClient();
CommunicationTokenCredential tokenCredential = new CommunicationTokenCredential(userToken);
android.content.Context appContext = this.getApplicationContext(); // From within an activity, for instance
CallAgentOptions callAgentOptions = new CallAgentOptions();
callAgentOptions.setDisplayName("Alice Bob");
DeviceManager deviceManager = callClient.getDeviceManager(appContext).get();
CallAgent callAgent = callClient.createCallAgent(appContext, tokenCredential, callAgentOptions).get();

CallLobby クラスまたは Call クラスのオブジェクト TeamsCall を使用すると、ユーザーは Teams 会議ロビー情報にアクセスできます。 これには、API、admitrejectadmitAll が含まれています。これにより、ユーザーは Teams 会議ロビーの参加者を許可および拒否できます。 ユーザーは、participants コレクションを取得し、addOnLobbyParticipantsUpdatedListener イベント リスナーをサブスクライブして通知を受信することもできます。

CallLobby オブジェクトを取得する

最初に、呼び出しインスタンスから CallLobby オブジェクトを取得します。

private CallLobby callLobby;
callLobby = call.getCallLobby();

ロビー参加者のプロパティを取得する

ロビーにいるユーザーを知るために、participants オブジェクトから CallLobby コレクションを取得できます。 これは、RemoteParticipant 状態の InLobby オブジェクトのコレクションです。 participants コレクションを取得するには:

List<RemoteParticipant> lobbyParticipants = callLobby.getParticipants(); 

リモート参加者の識別子を取得します

ロビーから参加者を許可または拒否する前に、リモート参加者の識別子を取得する必要があります。

//You could get the identifier from the lobby participants collection
//You could also get the identifier from the addOnLobbyParticipantsUpdatedListener event
List<CommunicationIdentifier> identifiers = new ArrayList<>();
CommunicationUserIdentifier acsUser = new CommunicationUserIdentifier(<USER_ID>);
MicrosoftTeamsUserIdentifier teamsUser = new MicrosoftTeamsUserIdentifier(<USER_ID>);
identifiers.add(new CommunicationUserIdentifier("<USER_ID>"));
identifiers.add(new MicrosoftTeamsUserIdentifier("<USER_ID>"));

CallLobby からの参加者を許可する

CallLobby オブジェクトを使用すると、開催者、共同開催者、発表者の役割を持つユーザーは、Teams CallLobby の参加者を許可できます。 メソッド admit は、識別子のコレクションを入力として受け入れ、結果として AdmitParticipantsResult オブジェクトを返します。

AdmitParticipantsResult result = this.callLobby.admit(identifiers).get();
String failedParticipants = this.convertListToString("", result.getFailedParticipants());
Log.i(LOBBY_TAG, String.format("Admit result: success count: %s, failure count: %s, failure participants: %s", admitResult.getSuccessCount(), failedParticipants.length(), failedParticipants));

CallLobby からの参加者を拒否する

MeetingLobby オブジェクトを使用すると、開催者、共同開催者、発表者の役割を持つユーザーは、Teams MeetingLobby の参加者を拒否できます。 メソッド reject は、識別子を入力として受け入れます。

//To reject all participants from CallLobby:
for (CommunicationIdentifier identifier : identifiers)
{
    this.callLobby.reject(lobbyParticipantsIdentifiers.get(0)).get();
}

CallLobby からすべての参加者を許可する

MeetingLobby オブジェクトを使用すると、開催者、共同開催者、発表者の役割を持つユーザーは、Teams MeetingLobby のすべての参加者を許可できます。 メソッド admitAll は結果として AdmitAllParticipantsResult オブジェクトを返します。

AdmitAllParticipantsResult result = this.callLobby.admitAll().get();
Log.i(LOBBY_TAG, String.format("Admit result: success count: %s, failure count: %s, failure participants: %s", result.getSuccessCount(), result.getFailureCount()));

CallLobby 更新イベントを処理する

addOnLobbyParticipantsUpdatedListener コレクション内の変更を処理するために、participants イベント リスナーをサブスクライブできます。 このイベントは、参加者が CallLobby に追加または削除されるとトリガーされ、追加または削除された参加者リストが提供されます。

//To register listener:
this.callLobby.addOnLobbyParticipantsUpdatedListener(this::OnLobbyParticipantsUpdated);

private void OnLobbyParticipantsUpdated(ParticipantsUpdatedEvent args) {
    if(!args.getAddedParticipants().isEmpty()){
        for(RemoteParticipant addedParticipant : args.getAddedParticipants()){
            Log.i(TAG, String.format("Participant %s joins lobby", addedParticipant.getDisplayName()));
        }
    }

    if(!args.getRemovedParticipants().isEmpty()){
        for(RemoteParticipant removedParticipant : args.getRemovedParticipants()){
            Log.i(TAG, String.format("Participant %s leaves lobby", removedParticipant.getDisplayName()));
        }
    }
}

//To unregister listener:
lobby.removeOnLobbyParticipantsUpdatedListener(this::OnLobbyParticipantsUpdated);

イベントとサブスクリプションの詳細を確認する

システムを設定する

次の手順のようにして、システムを設定します。

Xcode プロジェクトを作成する

Xcode で、新しい iOS プロジェクトを作成し、[単一ビュー アプリ] テンプレートを選択します。 この記事では SwiftUI フレームワークを使用するので、[言語][Swift] に、[インターフェイス][SwiftUI] に設定する必要があります。

この記事では、テストは作成しません。 [テストを含める] チェック ボックスはオフにしてもかまいません。

Xcode 内にプロジェクトを作成するためのウィンドウを示すスクリーンショット。

CocoaPods を使用してパッケージと依存関係をインストールする

  1. この例のように、アプリケーション用の Podfile を作成します。

    platform :ios, '13.0'
    use_frameworks!
    target 'AzureCommunicationCallingSample' do
        pod 'AzureCommunicationCalling', '~> 1.0.0'
    end
    
  2. pod install を実行します。

  3. Xcode を使用して .xcworkspace を開きます。

マイクへのアクセスを要求する

デバイスのマイクにアクセスするには、NSMicrophoneUsageDescription を使用してアプリの情報プロパティ一覧を更新する必要があります。 関連付けられる値には、システムがユーザーにアクセスを要求するために使用するダイアログに含まれる文字列を設定します。

プロジェクト ツリーの [Info.plist] エントリを右クリックし、[形式を指定して開く]>[ソース コード] を選択します。 最上位の <dict> セクションに以下の行を追加してから、ファイルを保存します。

<key>NSMicrophoneUsageDescription</key>
<string>Need microphone access for VOIP calling.</string>

アプリのフレームワークを設定する

プロジェクトの ContentView.swift ファイルを開きます。 ファイルの先頭に import 宣言を追加して、AzureCommunicationCalling ライブラリをインポートします。 さらに、AVFoundation をインポートします。 これは、コードでのオーディオ アクセス許可の要求に必要です。

import AzureCommunicationCalling
import AVFoundation

CallAgent を初期化する

CallAgent から CallClient インスタンスを作成するには、初期化された後に callClient.createCallAgent オブジェクトを非同期に返す CallAgent メソッドを使用する必要があります。

通話クライアントを作成するには、CommunicationTokenCredential オブジェクトを渡します。

import AzureCommunication

let tokenString = "token_string"
var userCredential: CommunicationTokenCredential?
do {
    let options = CommunicationTokenRefreshOptions(initialToken: token, refreshProactively: true, tokenRefresher: self.fetchTokenSync)
    userCredential = try CommunicationTokenCredential(withOptions: options)
} catch {
    updates("Couldn't created Credential object", false)
    initializationDispatchGroup!.leave()
    return
}

// tokenProvider needs to be implemented by Contoso, which fetches a new token
public func fetchTokenSync(then onCompletion: TokenRefreshOnCompletion) {
    let newToken = self.tokenProvider!.fetchNewToken()
    onCompletion(newToken, nil)
}

作成した CommunicationTokenCredential オブジェクトを CallClient に渡し、表示名を設定します。

self.callClient = CallClient()
let callAgentOptions = CallAgentOptions()
options.displayName = " iOS Azure Communication Services User"

self.callClient!.createCallAgent(userCredential: userCredential!,
    options: callAgentOptions) { (callAgent, error) in
        if error == nil {
            print("Create agent succeeded")
            self.callAgent = callAgent
        } else {
            print("Create agent failed")
        }
})

CallLobby クラスまたは Call クラスのオブジェクト TeamsCall を使用すると、ユーザーは Teams 会議ロビー情報にアクセスできます。 これには、API、admitrejectadmitAll が含まれています。これにより、ユーザーは Teams 会議ロビーの参加者を許可および拒否できます。 ユーザーは、participants コレクションを取得し、イベント リスナーをサブスクライブして通知を受信することもできます。

CallLobby オブジェクトを取得する

最初に、呼び出しインスタンスから CallLobby オブジェクトを取得します。

@State var callLobby: CallLobby?
callLobby = self.call!.callLobby

ロビー参加者のプロパティを取得する

ロビーにいるユーザーを知るために、participants オブジェクトから CallLobby コレクションを取得できます。 これは、RemoteParticipant 状態の InLobby オブジェクトのコレクションです。 participants コレクションを取得するには:

let lobbyParticipants = callLobby.participants

リモート参加者の識別子を取得します

CallLobby から参加者を許可または拒否する前に、リモート参加者の識別子を取得する必要があります。

//You could get the identifier from the lobby participants collection
//You could also get the identifier from the addOnLobbyParticipantsUpdatedListener event
let identifiers = (call?.callLobby.participants.map {$0.identifier})!;

CallLobby からの参加者を許可する

CallLobby オブジェクトを使用すると、開催者、共同開催者、発表者の役割を持つユーザーは、Teams CallLobby の参加者を許可できます。 メソッド admit は、識別子のコレクションを入力として受け入れ、結果として AdmitParticipantsResult オブジェクトを返します。

callLobby.admit(identifiers: identifiers, completionHandler: { result, error in
    if error != nil {
        print ("Admit participant is failed %@", error! as Error)
    } else{
        print ("Admit result. success count: %s , failure count: %s, failure participants: %s", result.successCount, result.failureCount, result.failureParticipants)
    }
})

CallLobby からの参加者を拒否する

CallLobby オブジェクトを使用すると、開催者、共同開催者、発表者の役割を持つユーザーは、Teams CallLobby の参加者を拒否できます。 メソッド reject は識別子を受け入れます。

//To reject participant from CallLobby:
callLobby.reject(identifiers.first!, completionHandler: { error in
    if error != nil {
        print ("Reject all participants is failed %@", error! as Error)
    }
})

CallLobby からすべての参加者を許可する

CallLobby オブジェクトを使用すると、開催者、共同開催者、発表者の役割を持つユーザーは、すべての Teams CallLobby の参加者を許可できます。 メソッド admitAll は結果として AdmitAllParticipantsResult オブジェクトを返します。

callLobby.admitAll(completionHandler: { result, error in
    if error != nil {
        print ("Admit all participants is failed %@", error! as Error)
    } else{
        print ("AdmitAll result. success count: %s , failure count: %s", result.successCount, result.failureCount)
    }
})

CallLobby 更新イベントを処理する

participants コレクション内の変更を処理するために、イベント リスナーをサブスクライブできます。 このイベントは、参加者が CallLobby に追加または削除されるとトリガーされ、追加または削除された参加者リストが提供されます。

//To register listener:
self.callObserver = CallObserver(view:self)

callLobby = self.call!.callLobby
callLobby!.delegate = self.callObserver

public class CallObserver : NSObject, CallLobbyDelegate
{
    public func callLobby(_ callLobby: CallLobby, didUpdateLobbyParticipants args: ParticipantsUpdatedEventArgs) {
        args.removedParticipants.forEach { p in
            let mri = Utilities.toMri(p.identifier)
            os_log("==>Participants %d is removed from the lobby.", log:log, mri)
        }

        args.addedParticipants.forEach { p in
            let mri = Utilities.toMri(p.identifier)
            os_log("==>Participants %d is added to the lobby.", log:log, mri)
        }
    }
}    

//To unregister listener, you can use the `off` method.
self.callLobby?.delegate = nil

イベントとサブスクリプションの詳細を確認する

システムを設定する

次の手順のようにして、システムを設定します。

Visual Studio プロジェクトの作成

ユニバーサル Windows プラットフォーム アプリの場合は、Visual Studio 2022 で、新しい空のアプリ (ユニバーサル Windows) プロジェクトを作成します。 プロジェクト名を入力した後、10.0.17763.0 より後の Windows SDK を自由に選択できます。

WinUI 3 アプリの場合、Blank App, Packaged (WinUI 3 in Desktop) テンプレートで新しいプロジェクトを作成し、シングルページの WinUI 3 アプリを設定します。 Windows App SDK バージョン 1.3 以降が必要です。

NuGet パッケージ マネージャーを使用してパッケージと依存関係をインストールする

Calling SDK の API とライブラリは、NuGet パッケージにより一般公開されています。

Calling SDK NuGet パッケージを検索、ダウンロード、インストールするには:

  1. [ツール]>[NuGet パッケージ マネージャー]>[ソリューションの NuGet パッケージの管理] を選択して、NuGet パッケージ マネージャーを開きます。
  2. [参照] を選択してから、検索ボックスに「Azure.Communication.Calling.WindowsClient」と入力します。
  3. [プレリリースを含める] チェックボックスがオンになっていることを確認します。
  4. Azure.Communication.Calling.WindowsClient パッケージを選択し、Azure.Communication.Calling.WindowsClient1.4.0-beta.1 以降のバージョンを選択します。
  5. 右側のペインで、Azure Communication Services プロジェクトに対応するチェックボックスをオンにします。
  6. [インストール] を選択します。

CallLobby クラスまたは Call クラスのオブジェクト TeamsCall を使用すると、ユーザーは Teams 会議ロビー情報にアクセスできます。 これには、API、AdmitAsyncRejectAsyncAdmitAllAsync が含まれています。これにより、ユーザーは Teams 会議ロビーの参加者を許可および拒否できます。 ユーザーは、Participants コレクションを取得し、LobbyParticipantsUpdated イベントをサブスクライブして通知を受信することもできます。

CallLobby オブジェクトを取得する

最初に、呼び出しインスタンスから CallLobby オブジェクトを取得します。

private CallLobby callLobby;
callLobby = call.CallLobby;

ロビー参加者のプロパティを取得する

ロビーにいるユーザーを知るために、Participants オブジェクトから CallLobby コレクションを取得できます。 これは、RemoteParticipant 状態の InLobby オブジェクトのコレクションです。 Participants コレクションを取得するには:

var lobbyParticipants = callLobby.Participants; 

リモート参加者の識別子を取得します

CallLobby から参加者を許可または拒否する前に、リモート参加者の識別子を取得する必要があります。

//You could get the identifier from the CallLobby.Participants collection
//You could also get the identifier from the LobbyParticipantsUpdated event
var identifiers = lobbyParticipants.Select(p => p.Identifier).ToList().AsReadOnly();

CallLobby からの参加者を許可する

CallLobby オブジェクトを使用すると、開催者、共同開催者、発表者の役割を持つユーザーは、Teams CallLobby の参加者を許可できます。 メソッド AdmitAsync は、識別子のコレクションを入力として受け入れ、結果として AdmitParticipantsResult オブジェクトを返します。

AdmitParticipantsResult result = await callLobby?.AdmitAsync(identifiers);
Trace.WriteLine("Admit result. success count: " + result.SuccessCount + ", failure count: " + result.FailedParticipants.Count + ", failure participants: " + result.FailedParticipants);
foreach (RemoteParticipant participant in result.FailureParticipants.ToList<RemoteParticipant>())
{
    Trace.WriteLine("Admit participant: " + participant.DisplayName + " failed ");
}

CallLobby からの参加者を拒否する

CallLobby オブジェクトを使用すると、開催者、共同開催者、発表者の役割を持つユーザーは、Teams CallLobby の参加者を拒否できます。 メソッド RejectAsync は、識別子を入力として受け入れます。

//To reject all participants from CallLobby:
foreach (CallIdentifier identifier in identifiers)
{
    await callLobby?.RejectAsync(identifier);
}

CallLobby からすべての参加者を許可する

CallLobby オブジェクトを使用すると、開催者、共同開催者、発表者の役割を持つユーザーは、すべての Teams CallLobby の参加者を許可できます。 メソッド AdmitAllAsync は結果として AdmitAllParticipantsResult オブジェクトを返します。

AdmitAllParticipantsResult result = await callLobby?.AdmitAllAsync();
Trace.WriteLine("Admit all result. success count: " + result.SuccessCount + ", failure count: " + result.FailureCount);

CallLobby 更新イベントを処理する

LobbyParticipantsUpdated コレクション内の変更を処理するために、Participants イベントをサブスクライブできます。 このイベントは、参加者が CallLobby に追加または削除されるとトリガーされ、追加または削除された参加者リストが提供されます。

//When call.State == CallState.Connected
callLobby.LobbyParticipantsUpdated += CallLobby_OnLobbyParticipantsUpdated;

private async void CallLobby_OnLobbyParticipantsUpdated(object sender, ParticipantsUpdatedEventArgs args)
{
    foreach (var remoteParticipant in args.AddedParticipants.ToList<RemoteParticipant>()){
        Trace.WriteLine("Participant: " + participant.DisplayName + " joins lobby ");
    }

    foreach (var remoteParticipant in args.RemovedParticipants.ToList<RemoteParticipant>()){
        Trace.WriteLine("Participant: " + participant.DisplayName + " leaves lobby ");
    }
}

イベントとサブスクリプションの詳細を確認する

次のステップ