Skip to content
This repository was archived by the owner on Sep 19, 2023. It is now read-only.
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Working on some connection issues (for Toya)
- Fixed issue where link and game are both open.
- Made it clear when user was invited to room.
- Fixed the status bar for stories.
Expand Down
7 changes: 6 additions & 1 deletion Sources/Room/Service/RoomClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,13 @@ extension RoomClient: WebRTCClientDelegate {
case .connected:
rtc.speakerOn()
delegate?.roomClientDidConnect(self)
case .failed, .closed:
case .closed:
delegate?.roomClientDidDisconnect(self)
case .disconnected:
rtc.offer(constraints: [kRTCMediaConstraintsIceRestart: kRTCMediaConstraintsValueTrue], completion: { result in
self.signalClient.offer(description: result)
})
debugPrint("restarting")
default:
return // @TODO
}
Expand Down
11 changes: 8 additions & 3 deletions Sources/Room/Service/WebRTCClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class WebRTCClient: NSObject {
private let mediaConstrains = [
kRTCMediaConstraintsOfferToReceiveAudio: kRTCMediaConstraintsValueTrue,
kRTCMediaConstraintsOfferToReceiveVideo: kRTCMediaConstraintsValueFalse,
kRTCMediaConstraintsVoiceActivityDetection: kRTCMediaConstraintsValueTrue,
kRTCMediaConstraintsIceRestart: kRTCMediaConstraintsValueTrue,
]

private var localDataChannels = [String: RTCDataChannel]()
Expand Down Expand Up @@ -79,8 +79,13 @@ final class WebRTCClient: NSObject {
}
}

func offer(completion: @escaping (_ sdp: RTCSessionDescription) -> Void) {
let constrains = RTCMediaConstraints(mandatoryConstraints: mediaConstrains, optionalConstraints: nil)
func offer(constraints: [String: String]? = nil, completion: @escaping (_ sdp: RTCSessionDescription) -> Void) {
var mandatoryConstraints = mediaConstrains
if let constraints = constraints {
constraints.forEach { key, value in mandatoryConstraints[key] = value }
}

let constrains = RTCMediaConstraints(mandatoryConstraints: mandatoryConstraints, optionalConstraints: nil)
peerConnection.offer(for: constrains) { sdp, _ in
guard let sdp = sdp else {
return
Expand Down