问题描述
请原谅我的斯威夫特贵气。
我正在使用Twilio的VideoCall框架,想知道为什么我的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并尝试运行:
class AppHome: View {
var roomDelegate = myRoomDelegate()
}