Skip to content

Conversation

@Kiyoung-Kim-57
Copy link
Member

🤔 배경

세션 연결을 위해 Connection Client를 구현했지만 정상적인 연결이 되는지 확인이 필요했습니다.
Feature 모듈에서 Connection Client를 사용하기 위해 Connection Client의 Interface를 구현했습니다.
closed #4

📃 작업 내역

  • Connection Client Interface 구현 및 적용
  • Signaling Client, WebRTC Client Interface 리팩토링
  • WaitingRoomDemo 앱을 이용한 세션 연결 확인
  • 카메라와 마이크를 사용하기 위한 권한 설정

✅ 리뷰 노트

1. Demo 앱에서의 의존성 관계 설정

Demo 앱에서 세션 연결을 테스트하기 위해서 기존 설계와 다르게 PhotoGetherDomain과 PhotoGetherNetwork를 Demo 앱이 의존하도록 설정했습니다.
테스트를 하기 위해서는 SceneDelegate에서 Connection Client를 생성해서 주입해줘야 됐습니다. 이를 위해 우선 PhotoGetherDomain을 의존해야 했습니다. 그리고 Connection Client를 생성하기 위해서는 WebSocketClient, SignalingClient, WebRTCClient를 생성해야 했는데 이 중에서 WebSocketClient의 구현체가 PhotoGetherNetwork에 있어서 추가적으로 의존성을 설정해줬습니다.

guard let windowScene = (scene as? UIWindowScene) else { return }
        let urlString = Bundle.main.object(forInfoDictionaryKey: "BASE_URL") as? String ?? ""
        let url = URL(string: urlString)!
        //WebSocketClientImpl은 Network 모듈에 존재
        let webScoketClient = WebSocketClientImpl(url: url)

        //SignalingClientImpl, WebRTCClientImpl, ConnectionClientImpl은 Domain 모듈에 존재
        let signalingClient = SignalingClientImpl(webSocketClient: webScoketClient)
        let webRTCClient = WebRTCClientImpl(iceServers: [ ... ])
        let connectionClient = ConnectionClientImpl(signalingClient: signalingClient, webRTCClient: webRTCClient)
        
        window = UIWindow(windowScene: windowScene)
        window?.rootViewController = WaitingRoomViewController(connectionClient: connectionClient)

image
image

2. WebRTC 프레임워크를 찾지 못하는 오류

Demo 앱을 빌드해보니 WebRTC 프레임워크를 찾지 못해 앱이 터지는 현상이 발생했습니다. 이를 해결하기 위해 Demo 앱이 있는 Feature 모듈에 직접 Package Dependency를 추가해줬습니다. WebRTC 프레임워크의 README를 읽어보니 원인을 유추해볼 수 있었습니다.

## 💡 Things to know
* Dynamic framework (xcframework format) which contains multiple binaries for macOS and iOS.

바로 WebRTC 프레임워크는 Static Library가 아닌 Dynamic framework였던 것이었습니다. SPM으로 추가한 패키지는 당연히 Static Library일 것이라고 생각했지만 그렇지 않았습니다.
GPT 선생님의 말에 따르면 결국 해결책은 필요한 곳에서 Package Dependency를 추가해줘야 한다...라는 것 같습니다.

dyld[ ] Libray not Loaded: @rpath/

image

🎨 스크린샷

iPhone SE(2세대) iPhone 14 iPhone 16 Pro Max
스샷 없음 스샷 없음

🚀 테스트 방법

WaitingRoomDemo 앱을 빌드하셔서 확인할 수 있습니다. 두 명이 앱을 실행시키고 한 명이 offer 버튼을 누르면 자동으로 answer되어 p2p 연결을 시도합니다. 연결이 되면 나와 상대방의 화면을 확인할 수 있습니다.

youn9k and others added 20 commits November 13, 2024 11:54
ConnectionClient Interface 구현 및 적용
기존 ConnectionClientImpl에서 채택하던 Delegate를 interface에서 채택

Co-Authored-By: Youngkyu Song <ace_lephant@naver.com>
기존에 Impl이 채택하던 delegate를 Interface에서 채택

Co-Authored-By: Youngkyu Song <ace_lephant@naver.com>
SignalingClient Interface에서 delegate 채택

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>
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>
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>
모든 화면에서 이걸 해줘야하는건가..?
@Kiyoung-Kim-57 Kiyoung-Kim-57 added the ✨ feat 새로운 기능 추가 label Nov 13, 2024
@Kiyoung-Kim-57 Kiyoung-Kim-57 linked an issue Nov 13, 2024 that may be closed by this pull request
3 tasks
Copy link
Collaborator

@0Hooni 0Hooni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!

저도 당연히 기본은 static이라 생각했는데 dynamic일 수도 있다는걸 이번에 처음 알게 되었네요☺️

추가로 권한 설정 관련해서도 작업이 추가된것 같은데 연관 이슈가 있는걸로 알아서 이부분 체크도 해보심 좋을거 같습니다 ㅎㅎ

수고 많으셨습니다!

@youn9k
Copy link
Member

youn9k commented Nov 14, 2024

수고하셨습니다!

저도 당연히 기본은 static이라 생각했는데 dynamic일 수도 있다는걸 이번에 처음 알게 되었네요☺️

추가로 권한 설정 관련해서도 작업이 추가된것 같은데 연관 이슈가 있는걸로 알아서 이부분 체크도 해보심 좋을거 같습니다 ㅎㅎ

수고 많으셨습니다!

아 그러네요!! 연관 이슈도 연결해둘게요!

Copy link
Collaborator

@hsw1920 hsw1920 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Secret이 Demo에도 필요하군요!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞습니다 흑흑

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저흰 모듈화 원시인이니까 필요한 곳에 한땀한땀 추가해야합니다

self.delegate?.signalClient(self, didReceiveCandidate: iceCandidate.rtcIceCandidate)
case .sdp(let sessionDescription):
self.delegate?.signalClient(self, didReceiveRemoteSdp: sessionDescription.rtcSessionDescription)
@unknown default:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@unknown 키워드 알아갑니다!

Comment on lines +6 to +10
func offer(completion: @escaping (_ sdp: RTCSessionDescription) -> Void)
func answer(completion: @escaping (_ sdp: RTCSessionDescription) -> Void)
func set(remoteSdp: RTCSessionDescription, completion: @escaping (Error?) -> Void)
func set(localSdp: RTCSessionDescription, completion: @escaping (Error?) -> Void)
func set(remoteCandidate: RTCIceCandidate, completion: @escaping (Error?) -> Void)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기가 concurrency로 바뀔 예정일까요?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 맞아요! 근데 작업 우선순위에 밀려 하고싶은 작업이 되었습니다..🥲

Comment on lines +76 to +79
private func setActions() {
offerButton.addAction(UIAction { [weak self] _ in
self?.connectionClient.sendOffer()
}, for: .touchUpInside)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UIButton에 tapPublisher가 확장되어 있습니다.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 맞네요ㅋㅋㅋㅋㅋ

@youn9k youn9k merged commit a40aab7 into develop Nov 14, 2024
1 check passed
@youn9k youn9k deleted the feat/#24-refactor-connection-client branch November 14, 2024 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feat 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

세션이 연결되는지 데모 앱을 통해 확인 세션 연결이 된다

5 participants