RevueSDK · Swift reference Guides

Protocol

RoomDelegate

房間事件代理 — 監聽連線、通話、參與者、Track 等事件

protocol RoomDelegate : AnyObject

Overview

參與者事件兩層同步收到:同一事件會同時通知 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