-
Notifications
You must be signed in to change notification settings - Fork 2
[FIX/#130] 2. 여러 사용자가 연결되지 않는 문제를 수정합니다. #131
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/#130] 2. 여러 사용자가 연결되지 않는 문제를 수정합니다. #131
Conversation
Co-Authored-By: Kiyoung <121777185+Kiyoung-Kim-57@users.noreply.github.com>
|
떳다 ㄷㄷㄷ |
Co-Authored-By: Youngkyu Song <ace_lephant@naver.com>
- Offer 보낼 때 SessionDescription에 answerID 정보를 같이 담아서 보낼 수 있도록 모델 수정 - Offer 보낼 때 answerID 정보 포함해서 보냄 Co-Authored-By: Youngkyu Song <ace_lephant@naver.com>
answerID는 Answer를 보내는 사람의 ID입니다. Offer를 보내고 Answer가 왔을 때 특정 Client에만 remoteSDP를 저장해야합니다. Co-Authored-By: Kiyoung <121777185+Kiyoung-Kim-57@users.noreply.github.com>
Co-Authored-By: Kiyoung <121777185+Kiyoung-Kim-57@users.noreply.github.com>
Co-Authored-By: Kiyoung <121777185+Kiyoung-Kim-57@users.noreply.github.com>
Co-Authored-By: Kiyoung <121777185+Kiyoung-Kim-57@users.noreply.github.com>
- OfferSdpPublisher, AnswerSdpPublisher 의 로직을 수정했습니다. Co-Authored-By: Youngkyu Song <ace_lephant@naver.com>
Co-Authored-By: Youngkyu Song <ace_lephant@naver.com>
Co-Authored-By: Youngkyu Song <ace_lephant@naver.com>
Co-Authored-By: Youngkyu Song <ace_lephant@naver.com>
UI변경을 메인스레드에서 하기 위해 receive RunLoop.main을 달아두었습니다. Co-Authored-By: Kiyoung <121777185+Kiyoung-Kim-57@users.noreply.github.com>
hsw1920
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!!! 드디어..!
| self.signalingService.didReceiveOfferSdpPublisher | ||
| .filter { [weak self] _ in self?.remoteUserInfo != nil } | ||
| .sink { [weak self] sdpMessage in | ||
| guard let self else { return } | ||
| let remoteSDP = sdpMessage.rtcSessionDescription | ||
|
|
||
| PTGDataLogger.log("didReceiveRemoteSdpPublisher sink!! \(remoteSDP)") | ||
|
|
||
| // MARK: remoteDescription이 있으면 이미 연결된 클라이언트 | ||
| guard self.webRTCService.peerConnection.remoteDescription == nil else { | ||
| PTGDataLogger.log("remoteSDP가 이미 있어요!") | ||
| return | ||
| } | ||
| PTGDataLogger.log("remoteSDP가 없어요! remoteSDP 저장하기 직전") | ||
| guard let userInfo = self.remoteUserInfo else { | ||
| PTGDataLogger.log("answer를 받을 remote User가 없어요!! 비상!!!") | ||
| return | ||
| } | ||
|
|
||
| guard userInfo.id == sdpMessage.offerID else { | ||
| PTGDataLogger.log("Offer를 보낸 유저가 일치하지 않습니다.") | ||
| return | ||
| } | ||
|
|
||
| guard self.webRTCService.peerConnection.localDescription == nil else { | ||
| PTGDataLogger.log("localSDP가 이미 있어요!") | ||
| return | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아래 set을 시키지 않기 위함이 주 목적이라면, guard 하는 부분은 따로 private 메서드로 빼주는 건 어떨까요?
| self.signalingService.didReceiveAnswerSdpPublisher | ||
| .filter { [weak self] _ in self?.remoteUserInfo != nil } | ||
| .sink { [weak self] sdpMessage in | ||
| guard let self else { return } | ||
| let remoteSDP = sdpMessage.rtcSessionDescription | ||
|
|
||
| guard let userInfo = remoteUserInfo else { | ||
| PTGDataLogger.log("UserInfo가 없어요") | ||
| return | ||
| } | ||
|
|
||
| guard userInfo.id == sdpMessage.answerID else { | ||
| return | ||
| } | ||
|
|
||
| guard self.webRTCService.peerConnection.localDescription != nil else { | ||
| PTGDataLogger.log("localDescription이 없어요") | ||
| return | ||
| } | ||
|
|
||
| guard self.webRTCService.peerConnection.remoteDescription == nil else { | ||
| PTGDataLogger.log("remoteDescription이 있어요") | ||
| return | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 마찬가지로 분리하면 가독성이 좋을 것 같아요
| self.webRTCService.set(remoteSdp: remoteSDP) { error in | ||
| PTGDataLogger.log("remoteSDP가 저장되었어요!") | ||
|
|
||
| if let error { PTGDataLogger.log(error.localizedDescription) } | ||
|
|
||
| guard self.webRTCService.peerConnection.localDescription == nil else { return } | ||
| self.webRTCService.answer { sdp in | ||
| guard let userInfo = self.remoteUserInfo else { return } | ||
| self.signalingService.send( | ||
| type: .answerSDP, | ||
| sdp: sdp, | ||
| userID: userInfo.id, | ||
| roomID: userInfo.roomID | ||
| roomID: userInfo.roomID, | ||
| offerID: userInfo.id, | ||
| answerID: sdpMessage.answerID | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이친구도 직접 webRTCService를 참조해서 set을 호출하는거보다, guard 하는부분과 set하는 부분을 명시적으로 두 함수로 분리하면 가독성이 더 좋을 것 같아요.
| enum AppPermissionManager { | ||
| static func requestCameraPermission() { | ||
| AVCaptureDevice.requestAccess(for: .video) { granted in | ||
| if granted { | ||
| print("카메라 권한 허용됨") | ||
| } else { | ||
| print("카메라 권한 거부됨") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| static func requestMicrophonePermission() { | ||
| AVCaptureDevice.requestAccess(for: .audio) { granted in | ||
| if granted { | ||
| print("마이크 권한 허용됨") | ||
| } else { | ||
| print("마이크 권한 거부됨") | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
추후 매니저에서 마이크 버튼 on/off 할때도 권한 여부를 확인할 필요가 있을 것 같아요.
0Hooni
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
라이브 코드리뷰 완
LGTM 👍
🤔 배경
📃 작업 내역
✅ 리뷰 노트
🎨 스크린샷
🚀 테스트 방법
현재 2명의 연결은 안정적으로 되는 것을 확인했으나 다수 연결은 직접 테스트해보지 못했습니다.
연결이 될 경우 WaitingRoom에서 서로의 음성이 연결됩니다. 영상은 바인딩 오류 문제 확인하여 수정이 필요합니다.