我正在使用 twilio 作为视频聊天应用程序的服务。房间将仅包含 2 名参与者 P1 和 P2
P1
- 从后端获取生成的访问令牌(添加了房间授权)
- 从服务器获取房间名称
连接到房间
let connectOptions = TVIConnectOptions.init(token: payload.twilioAccessToken) { (builder) in builder.roomName = payload.roomName } twilioLog("Will Connect to room with name \(String(describing: payload.roomName))") self.room = TwilioVideo.connect(with: connectOptions, delegate:self)
func didConnect(to room: TVIRoom)
调用成功。
P2
- 从后端获取不同的生成访问令牌(添加了房间授权)
- 从服务器获取相同的房间名称
连接到房间
let connectOptions = TVIConnectOptions.init(token: payload.twilioAccessToken) { (builder) in builder.roomName = payload.roomName } twilioLog("Will Connect to room with name \(String(describing: payload.roomName))") self.room = TwilioVideo.connect(with: connectOptions, delegate:self)
func didConnect(to room: TVIRoom)
调用成功。
但是,func room(_ room: TVIRoom, participantDidConnect participant: TVIParticipant)
永远不会被调用。此外, room.participants 返回一个空数组。