Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix minor issues in sample code in README #451

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,32 +88,34 @@ class RoomViewController: UIViewController {
let url = "ws://your_host"
let token = "your_jwt_token"

do {
try await room.connect(url: url, token: token)
// Connection successful...

// Publishing camera & mic...
try await room.localParticipant.setCamera(enabled: true)
try await room.localParticipant.setMicrophone(enabled: true)
} catch let error in {
// Failed to connect
Task {
do {
try await room.connect(url: url, token: token)
// Connection successful...

// Publishing camera & mic...
try await room.localParticipant.setCamera(enabled: true)
try await room.localParticipant.setMicrophone(enabled: true)
} catch {
// Failed to connect
}
}
}
}

extension RoomViewController: RoomDelegate {

func room(_: Room, participant _: LocalParticipant, didPublishTrack publication: LocalTrackPublication) {
guard let track = publication?.track as? VideoTrack else { return }
guard let track = publication.track as? VideoTrack else { return }
DispatchQueue.main.async {
localVideoView.track = track
self.localVideoView.track = track
}
}

func room(_: Room, participant _: RemoteParticipant, didSubscribeTrack publication: RemoteTrackPublication) {
guard let track = publication?.track as? VideoTrack else { return }
guard let track = publication.track as? VideoTrack else { return }
DispatchQueue.main.async {
remoteVideoView.track = track
self.remoteVideoView.track = track
}
}
}
Expand Down