[英]Swift: Twilio delegate functions not being called
請原諒我的 Swift noobiness。
我正在使用 Twilio 的 VideoCall 框架並想知道為什么我的 RoomDelegate 函數沒有被調用。
在我的視圖中,我有一個 RoomDelegate 實例
struct AppHome: View {
var roomDelegate = myRoomDelegate()
當我連接到一個房間時,我傳入我的 roomDelegate:
let connectOptions = ConnectOptions(token: self.accessToken) { (builder) in
builder.roomName = self.call.call_api.room_name
builder.audioTracks = [self.roomDelegate.localAudioTrack!]
}
let room = TwilioVideoSDK.connect(options: connectOptions, delegate: self.roomDelegate)
我的 roomDelegate 類有:
class myRoomDelegate: NSObject, RoomDelegate {
...
func roomDidConnect(room: Room) {
print("Delegate " + #function)
}
func roomDidDisconnect(room: Room, error: Error?) {
print("Delegate " + #function)
}
func roomDidFailToConnect(room: Room, error: Error) {
print("Delegate " + #function)
}
func roomIsReconnecting(room: Room, error: Error) {
print("Delegate " + #function)
}
func roomDidReconnect(room: Room) {
print("Delegate " + #function)
}
func participantDidConnect(room: Room, participant: RemoteParticipant) {
print("Delegate " + #function)
}
func participantDidDisconnect(room: Room, participant: RemoteParticipant) {
print("Delegate " + #function)
}
}
我發現的所有委托示例都使用self
所以我試圖了解我所做的是否有效,如果有效,為什么我的委托回調沒有受到影響?
在我看來,您的類型有問題,因此將您的結構更改為類並嘗試運行:
class AppHome: View {
var roomDelegate = myRoomDelegate()
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.