-
Notifications
You must be signed in to change notification settings - Fork 2
[FEAT/#95] 서버 방 생성 작업을 진행합니다. #99
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
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
cbd9712
feat/#95 :: Server에 Encodable Extension 추가
Kiyoung-Kim-57 a22ebf2
feat/#95 :: 서버에서 방 생성 요청 받았을 시 동작 구현
Kiyoung-Kim-57 ffa6079
feat/#95 :: ByteBuffer extension 추가
Kiyoung-Kim-57 88ce472
feat/#95 :: Server의 CreateRoomResponseDTO 수정
Kiyoung-Kim-57 412b30e
feat/#95 :: CreateRoomResponseDTO 생성
Kiyoung-Kim-57 0f2b391
feat/#95 :: Data에 toDTO extension 추가
Kiyoung-Kim-57 ab4d9de
feat/#95 :: RoomService가 서버에서 받은 Response 처리
Kiyoung-Kim-57 aa38db9
feat/#95 :: LocalVideoView 단일화
youn9k 6d8ab76
feat/#95 :: captureVideo 메소드 수정
youn9k 596dc67
chore/#95 :: CreateRoomUseCase 구현중
youn9k dc42cb6
chore/#95 :: RoomService Data->Domain으로 변경
youn9k 42dd659
feat/#95 :: ConnectionRepository에 프로퍼티 추가
youn9k 24c5a96
feat/#95 :: RoomService 인터페이스 수정
Kiyoung-Kim-57 cb67d24
fix/#95 :: Repository 수정에 따라 UseCase 수정
Kiyoung-Kim-57 4b7180d
fix/#95 :: swiftLint 오류 수정
Kiyoung-Kim-57 e6350b4
feat/#95 :: CreateRoomUseCase 수정
Kiyoung-Kim-57 af5db3c
chore/#95 :: 자잘한 오류 수정
Kiyoung-Kim-57 3112a95
style/#95 :: shareButton 이름 linkButton으로 변경
Kiyoung-Kim-57 7fb289a
feat/#95 :: CreateRoomUseCase의 execute에 discardableResult 적용
Kiyoung-Kim-57 c12e7b1
chore/#95 :: Scenedelegate에서 의존성 주입 관련 수정
Kiyoung-Kim-57 b4db373
feat/#95 :: WebSocketClient가 delegate를 여러 개 가지도록 수정
Kiyoung-Kim-57 b7b4ef2
feat/#95 :: WebSocketClientDelegate Deprecated
youn9k 7ec8a4c
feat/#95 :: CreateRoomEntity 생성
Kiyoung-Kim-57 8db283b
feat/#95 :: RoomService의 createRoom 함수 반환 타입 변경
Kiyoung-Kim-57 a445ba6
chore/#95 :: 불필요한 공백 제거
Kiyoung-Kim-57 6c798a4
feat/#95 :: CreateRoomUseCase 구현
youn9k 44ea1ce
feat/#95 :: UIActivityViewController를 통한 딥링크 uri 전달 기능 연결
youn9k 7e93cf6
style/#95 :: CreateRoomEntity -> RoomOwnerEntity로 이름 변경
Kiyoung-Kim-57 c7da50e
feat/#95 :: UserInfoEntity 생성
Kiyoung-Kim-57 77671de
feat/#95 :: ConnectionClient에 UserInfo 추가
Kiyoung-Kim-57 dbeb2f7
feat/#95 :: ParsingRoomID -> ParsingIDs 로 변경
Kiyoung-Kim-57 b9fd74f
feat/#95 :: 딥링크로 들어온 게스트가 딥링크 URL 파싱
Kiyoung-Kim-57 40b2417
feat/#95 :: JoinRoomUseCase 인터페이스 구현
youn9k 5fe7a32
feat/#95 :: 게스트 방 참가 로딩 화면 구현
youn9k 4cf7a75
feat/#95 :: JoinRoomUseCaseImpl / Mock 구현
youn9k 0854669
feat/#95 :: App SceneDelegate 호스트/게스트 화면 진입 분기 처리
youn9k b5b5578
chore/#95 :: 텍스트 정렬 수정
youn9k 232d506
chore/#95 :: CreateRoomMessage -> CreateRoomResponseMessage 이름 변경
Kiyoung-Kim-57 080cecf
feat/#95 :: JoinRoom 로직에 필요한 구조체 구현
Kiyoung-Kim-57 5e2cdb8
feat/#95 :: WebSocketRequestable의 확장 메서드를 옮겼습니다.
Kiyoung-Kim-57 bd7957e
feat/#95 :: RoomService의 joinRoom 로직 구현
Kiyoung-Kim-57 3c2a746
feat/#95 :: fullScreen으로 띄우도록 변경
youn9k 3b5c14e
feat/#95 :: Decoder를 매번 생성하지 않고 파라미터로 받을 수 있도록 변경
Kiyoung-Kim-57 d73da6a
feat/#95 :: 카메라 좌우 반전을 설정했습니다.
Kiyoung-Kim-57 97287de
style/#95 :: 각종 함수명, 변수명 Rename
Kiyoung-Kim-57 0ffc172
chore/#95 :: 커멘트 반영사항 적용
Kiyoung-Kim-57 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 15 additions & 2 deletions
17
PhotoGether/DataLayer/PhotoGetherData/PhotoGetherData/ConnectionRepositoryImpl.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,23 @@ | ||
| import Foundation | ||
| import UIKit | ||
| import PhotoGetherDomainInterface | ||
|
|
||
| public final class ConnectionRepositoryImpl: ConnectionRepository { | ||
| public var clients: [ConnectionClient] | ||
|
|
||
| public init(clients: [ConnectionClient]) { | ||
| private let _localVideoView = CapturableVideoView() | ||
|
|
||
| public var localVideoView: UIView { _localVideoView } | ||
| public var capturedLocalVideo: UIImage? { _localVideoView.capturedImage } | ||
|
|
||
| public let roomService: RoomService | ||
|
|
||
| public init(clients: [ConnectionClient], roomService: RoomService) { | ||
| self.clients = clients | ||
| self.roomService = roomService | ||
| bindLocalVideo() | ||
| } | ||
|
|
||
| private func bindLocalVideo() { | ||
| self.clients.forEach { $0.bindLocalVideo(_localVideoView) } | ||
| } | ||
| } |
4 changes: 2 additions & 2 deletions
4
PhotoGether/DataLayer/PhotoGetherData/PhotoGetherData/Extension/Data+toDTO.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import Foundation | ||
|
|
||
| public extension Data { | ||
| func toDTO(type: Decodable.Type) -> Decodable? { | ||
| return try? JSONDecoder().decode(type, from: self) | ||
| func toDTO<T: Decodable>(type: T.Type, decoder: JSONDecoder) -> T? { | ||
| return try? decoder.decode(type, from: self) | ||
| } | ||
| } |
7 changes: 7 additions & 0 deletions
7
PhotoGether/DataLayer/PhotoGetherData/PhotoGetherData/Extension/Encodable+toData.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import Foundation | ||
|
|
||
| extension Encodable { | ||
| func toData(encoder: JSONEncoder) -> Data? { | ||
| return try? encoder.encode(self) | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
...er/DataLayer/PhotoGetherData/PhotoGetherData/Interface/Delegate/RoomServiceDelegate.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
...ether/DataLayer/PhotoGetherData/PhotoGetherData/Interface/Message/CreateRoomMessage.swift
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
...taLayer/PhotoGetherData/PhotoGetherData/Interface/Message/CreateRoomResponseMessage.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import Foundation | ||
| import PhotoGetherDomainInterface | ||
|
|
||
| public struct CreateRoomResponseMessage: Decodable { | ||
| let roomID: String | ||
| let hostID: String | ||
|
|
||
| public func toEntity() -> RoomOwnerEntity { | ||
| RoomOwnerEntity(roomID: self.roomID, hostID: self.hostID) | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
.../DataLayer/PhotoGetherData/PhotoGetherData/Interface/Message/JoinRoomRequestMessage.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import Foundation | ||
|
|
||
| public struct JoinRoomRequestMessage: Encodable { | ||
| public let roomID: String | ||
| } |
16 changes: 16 additions & 0 deletions
16
...DataLayer/PhotoGetherData/PhotoGetherData/Interface/Message/JoinRoomResponseMessage.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import Foundation | ||
| import PhotoGetherDomainInterface | ||
|
|
||
| public struct JoinRoomResponseMessage: Decodable { | ||
| public let userID: String | ||
| public let clientsID: [String] | ||
|
|
||
| public init(userID: String, clientsID: [String]) { | ||
| self.userID = userID | ||
| self.clientsID = clientsID | ||
| } | ||
|
|
||
| public func toEntity() -> JoinRoomEntity { | ||
| JoinRoomEntity(userID: self.userID, clientsID: self.clientsID) | ||
| } | ||
| } |
7 changes: 0 additions & 7 deletions
7
PhotoGether/DataLayer/PhotoGetherData/PhotoGetherData/Interface/Service/RoomService.swift
This file was deleted.
Oops, something went wrong.
98 changes: 87 additions & 11 deletions
98
PhotoGether/DataLayer/PhotoGetherData/PhotoGetherData/ServiceImpl/RoomServiceImpl.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,108 @@ | ||
| import Foundation | ||
| import Combine | ||
| import PhotoGetherNetwork | ||
| import PhotoGetherDomainInterface | ||
|
|
||
| public final class RoomServiceImpl: RoomService { | ||
| public var createRoomResponsePublisher: AnyPublisher<RoomOwnerEntity, Error> { | ||
| _createRoomResponsePublisher.eraseToAnyPublisher() | ||
| } | ||
| public var joinRoomResponsePublisher: AnyPublisher<JoinRoomEntity, Error> { | ||
| _joinRoomResponsePublisher.eraseToAnyPublisher() | ||
| } | ||
| private let _createRoomResponsePublisher = PassthroughSubject<RoomOwnerEntity, Error>() | ||
| private let _joinRoomResponsePublisher = PassthroughSubject<JoinRoomEntity, Error>() | ||
| private var cancellables: Set<AnyCancellable> = [] | ||
|
|
||
| private let decoder = JSONDecoder() | ||
| private let encoder = JSONEncoder() | ||
| private var webSocketClient: WebSocketClient | ||
|
|
||
| public init(webSocketClient: WebSocketClient) { | ||
| self.webSocketClient = webSocketClient | ||
| bindWebSocketClient() | ||
| } | ||
|
|
||
| public func createRoom() -> AnyPublisher<RoomOwnerEntity, Error> { | ||
| let createRoomRequest = RoomRequestDTO(messageType: .createRoom) | ||
|
|
||
| guard let data = createRoomRequest.toData(encoder: encoder) else { | ||
| debugPrint("방 생성 요청 데이터 인코딩 실패: \(createRoomRequest)") | ||
| return Fail(error: RoomServiceError.failedToEncoding).eraseToAnyPublisher() | ||
| } | ||
|
|
||
| webSocketClient.send(data: data) | ||
| return createRoomResponsePublisher | ||
| } | ||
|
|
||
| public func send(request: any WebSocketRequestable) { | ||
| guard let data = request.toData(encoder: encoder) else { | ||
| debugPrint("방 생성 요청 데이터 인코딩 실패: \(request)") | ||
| return | ||
| public func joinRoom(to roomID: String) -> AnyPublisher<JoinRoomEntity, Error> { | ||
| let joinRoomMessage = JoinRoomRequestMessage(roomID: roomID).toData(encoder: encoder) | ||
| let joinRoomRequest = RoomRequestDTO(messageType: .joinRoom, message: joinRoomMessage) | ||
|
|
||
| guard let data = joinRoomRequest.toData(encoder: encoder) else { | ||
| debugPrint("방 참가 요청 데이터 인코딩 실패: \(joinRoomRequest)") | ||
| return Fail(error: RoomServiceError.failedToEncoding).eraseToAnyPublisher() | ||
| } | ||
|
|
||
| webSocketClient.send(data: data) | ||
| return joinRoomResponsePublisher | ||
| } | ||
|
|
||
| private func bindWebSocketClient() { | ||
| self.webSocketClient.webSocketdidReceiveDataPublisher | ||
| .sink { [weak self] data in | ||
| guard let self else { return } | ||
|
|
||
| guard let response = data.toDTO(type: RoomResponseDTO.self, decoder: decoder) else { return } | ||
|
|
||
| switch response.messageType { | ||
| case .createRoom: | ||
| guard let message = response.message else { return } | ||
| guard let message = message.toDTO( | ||
| type: CreateRoomResponseMessage.self, | ||
| decoder: decoder | ||
| ) else { | ||
| debugPrint("Decode Failed to CreateRoomMessage: \(message)") | ||
| return | ||
| } | ||
| let roomOwnerEntity = message.toEntity() | ||
| _createRoomResponsePublisher.send(roomOwnerEntity) | ||
|
|
||
| debugPrint("방 생성 성공: \(message.roomID) \n 유저 아이디: \(message.hostID)") | ||
| case .joinRoom: | ||
| guard let message = decodeMessage( | ||
| response.message, | ||
| type: JoinRoomResponseMessage.self | ||
| ) else { | ||
| debugPrint("Decode Failed to JoinRoomEntity: \(String(describing: response.message))") | ||
| return | ||
| } | ||
| let joinRoomEntity = message.toEntity() | ||
| _joinRoomResponsePublisher.send(joinRoomEntity) | ||
|
|
||
| debugPrint("방 참가 성공\n 유저 아이디: \(message.userID) \n 방 유저들 아이디: \(message.clientsID)") | ||
| } | ||
| }.store(in: &cancellables) | ||
| } | ||
|
|
||
| private func decodeMessage<T: Decodable>(_ message: Data?, type: T.Type) -> T? { | ||
| guard let message = message else { return nil } | ||
| guard let dto = message.toDTO(type: type, decoder: decoder) else { | ||
| debugPrint("Decode Failed to: \(message)") | ||
| return nil | ||
| } | ||
|
|
||
| return dto | ||
| } | ||
| } | ||
|
|
||
| // MARK: WebSocketDelegate | ||
| extension RoomServiceImpl: WebSocketClientDelegate { | ||
| public func webSocketDidConnect(_ webSocket: WebSocketClient) { } | ||
| public enum RoomServiceError: LocalizedError { | ||
| case failedToEncoding | ||
|
|
||
| public func webSocketDidDisconnect(_ webSocket: WebSocketClient) { } | ||
|
|
||
| public func webSocket(_ webSocket: WebSocketClient, didReceiveData data: Data) { | ||
| // TODO: 생성된 방번호 고유 아이디가 담긴 정보 디코딩 | ||
| public var errorDescription: String? { | ||
| switch self { | ||
| case .failedToEncoding: | ||
| return "Failed to encode room service request" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
PhotoGether/DataLayer/PhotoGetherNetwork/PhotoGetherNetwork/WebSocket/WebSocketClient.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...r/DataLayer/PhotoGetherNetwork/PhotoGetherNetwork/WebSocket/WebSocketClientDelegate.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.