你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
重要
Azure 通信服务的这一功能目前以预览版提供。 预览版中的功能已公开发布,可供所有新客户和现有Microsoft客户使用。
预览版 API 和 SDK 在没有服务级别协议的情况下提供。 建议不要将它们用于生产工作负荷。 某些功能可能不受支持,或者功能可能受到限制。
有关详细信息,请参阅 Microsoft Azure 预览版补充使用条款。
先决条件
- 具有活动订阅的 Azure 帐户。 免费创建帐户。
- 已部署的通信服务资源。 创建通信服务资源。
- 用于启用通话客户端的用户访问令牌。 获取用户访问令牌。
- 可选:完成快速入门以开始使用 UI 库复合组件。
设置该功能
参与者加入通话
我们开放 addOnRemoteParticipantJoinedEventHandler
来监听参与者是否加入通话。
callComposite.addOnRemoteParticipantJoinedEventHandler { remoteParticipantJoinedEvent ->
remoteParticipantJoinedEvent.identifiers.forEach { identifier ->
// identifier is communication identifier
}
}
参与者离开通话
如果参与者离开通话,我们将启用 addOnRemoteParticipantLeftEventHandler
进行侦听。
参与者加入通话
我们开放 onRemoteParticipantJoined
来监听参与者是否加入通话。
let onRemoteParticipantJoinedHandler: ([CommunicationIdentifier]) -> Void = { [weak callComposite] ids in
guard let composite = callComposite else {
return
}
/// ids are the communication identifiers that has joined and are present in the meeting
}
callComposite.events.onRemoteParticipantJoined = onRemoteParticipantJoinedHandler
参与者离开通话
如果参与者离开通话,我们将启用 onRemoteParticipantLeft
进行侦听。
let onRemoteParticipantLeftHandler: ([CommunicationIdentifier]) -> Void = { [weak callComposite] ids in
guard let composite = callComposite else {
return
}
/// ids are the communication identifiers which have left the meeting just now.
}
callComposite.events.onRemoteParticipantLeft = onRemoteParticipantLeftHandler