- RevueSDK
- RoomDelegate
Protocol
RoomDelegate
房間事件代理 — 監聽連線、通話、參與者、Track 等事件
protocol RoomDelegate : AnyObjectOverview
參與者事件兩層同步收到:同一事件會同時通知 Room.shared.delegates(本協定)與該參與者的 participant.delegates(ParticipantDelegate 的對應方法)。
⚠️ 會跳出提示的事件(例如收到靜音請求就彈窗、收到訊息就推通知)只監聽其中一層, 兩層都接會提示兩次。
使用方式:
// 每次 Revue.shared.initialize() 之後註冊:destroy() 會清空 Room.shared.delegates,
// 重新 initialize 後要再註冊一次
Room.shared.delegates.add(delegate: self)
// 參與者進房(對方接受邀請後 fire)
func room(_ room: Room, participantDidConnect participant: RemoteParticipant) {
showCallScreen(for: participant)
}
// 參與者離開房間
func room(_ room: Room, participantDidDisconnect participant: RemoteParticipant) {
// 從 participant.lastDisconnectReason 區分 .leave / .networkLost
dismissCallScreen(reason: participant.lastDisconnectReason)
}
// 連線路徑變更(v0.13.0-rc1:path bitmap)
func room(_ room: Room, participant: RemoteParticipant,
didUpdatePaths paths: FriendConnectionPaths) {
if paths.contains(.udpDirect) { print("\(participant.identity) 走 UDP 直連") }
}
// 來電由 RevueDelegate.didReceiveInvitation 處理(不在 RoomDelegate)
所有方法都有預設空實作,可選擇性實作需要的事件。
Topics
Instance Methods
func room(Room, didUpdateSpeakingParticipants: [Participant])說話者列表變更(依音量由大到小,含本地自己)
func room(Room, localParticipant: LocalParticipant, didPublishTrack: LocalTrackPublication)本地 Track 已發佈
func room(Room, localParticipant: LocalParticipant, didUnpublishTrack: LocalTrackPublication)本地 Track 已取消發佈
func room(Room, participant: RemoteParticipant, didReceiveMessage: String)收到 Room 內參與者訊息
func room(Room, participant: RemoteParticipant, didReceiveMuteRequest: Bool)收到遠端靜音請求
func room(Room, participant: RemoteParticipant, didSubscribeTrack: RemoteTrackPublication)已訂閱遠端 Track(收到對方的視訊/音訊)
func room(Room, participant: RemoteParticipant, didUnsubscribeTrack: RemoteTrackPublication)已取消訂閱遠端 Track
func room(Room, participant: Participant, didUpdateConnectionQuality: ConnectionQuality)參與者連線品質變更(5 級:excellent / good / fair / poor / bad)
func room(Room, participant: Participant, didUpdateName: String?)參與者名稱已更新(本地或遠端)
func room(Room, participant: RemoteParticipant, didUpdatePaths: FriendConnectionPaths)參與者連線路徑變更(FriendConnectionPaths bitmap)
func room(Room, participant: Participant, didUpdateStatus: UserStatus)參與者使用者狀態已更新(本地或遠端)
func room(Room, participant: Participant, didUpdateStatusMessage: String?)參與者狀態訊息已更新(本地或遠端);被清空時
message為 nilfunc room(Room, participant: Participant, trackPublication: TrackPublication, didUpdateIsMuted: Bool)Track 靜音狀態變更
func room(Room, participant: Participant, trackPublication: TrackPublication, didUpdateStatistics: TrackStatistics)Track 診斷統計更新(每秒一次,僅
reportStatistics == true時 fire、且有變化才 fire)。 與ParticipantDelegate.didUpdateStatistics雙 fire、與@Published track.statistics同源。func room(Room, participantDidConnect: RemoteParticipant)參與者加入房間(對方接受邀請後 fire)
func room(Room, participantDidDisconnect: RemoteParticipant)參與者離開房間