Skip to content

Instantly share code, notes, and snippets.

@cardoso
Created May 25, 2020 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cardoso/68d386ca57e720caf3806c4d49b6fc68 to your computer and use it in GitHub Desktop.
Save cardoso/68d386ca57e720caf3806c4d49b6fc68 to your computer and use it in GitHub Desktop.
import VoxeetSDK
import ReplayKit
extension WatchViewController {
func setupStream() {
let info = VTParticipantInfo(externalID: userId, name: userId, avatarURL: nil)
voxeet.conference.delegate = self
voxeet.session.open(info: info) { error in
self.joinOrCreateConference()
}
}
func joinOrCreateConference() {
let options = VTConferenceOptions()
options.alias = channelName
voxeet.conference.create(options: options, success: { conf in
if conf.isNew {
self.shareScreen(conf: conf)
} else {
self.watch(conf: conf)
}
}, fail: { error in
// TODO: Handle errors
})
}
func shareScreen(conf: VTConference) {
self.voxeet.conference.join(conference: conf, success: { conf in
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
self.voxeet.conference.startScreenShare(broadcast: true) { error in
// TODO: Handle errors
}
}
}, fail: { error in
// TODO: Handle errors
})
}
func watch(conf: VTConference) {
self.voxeet.conference.listen(conference: conf, success: { conf in
}, fail: { error in
// TODO: Handle errors
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment