-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Feature/#78] 동시에 공유컨테이너로 진입하는 기능 구현 #79
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
de3bd94
[REFACTOR]: 여러 유즈케이스를 사용함으로 인한 네이밍 변경
051198Hz 67e2179
[FEAT]: 피어에게서 전송할 이벤트와 전달받은 이벤트를 방출할 NoticedEventRepository 프로토콜 및 구현…
051198Hz d19b0fc
[FEAT]: 피어들에게 공유 컨테이너를 열라는 이벤트를 알리고, 전달받는 OpenSharedContainerUseCase …
051198Hz bd45d0b
[FEAT]: 버튼이 탭 된 이벤트에 대한 입력, 공유 컨테이너를 여는 이벤트에 대한 출력을 정의
051198Hz 81100e1
[FEAT]: 편집하기 버튼을 눌러 모든 피어가 공유 컨테이너 화면으로 진환하는 기능 구현
051198Hz c87cac2
[FEAT]: DI컨테이너에 의존성 등록
051198Hz 31d8d7e
[CHORE]: 파일 추가로 인한 프로젝트 변경사항 적용
051198Hz 13d99ab
[REFACTOR]: BrowsingUserRepository로 공유컨테이너 화면 전환 코드 통합 및 수정사항 적용
051198Hz cebfe91
[REFACTOR]: EventRepository 제거
051198Hz 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 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,39 @@ | ||
// | ||
// NoticedEventRepository.swift | ||
// Data | ||
// | ||
// Created by Yune gim on 12/2/24. | ||
// | ||
|
||
import Combine | ||
import Entity | ||
import Foundation | ||
import Interfaces | ||
import P2PSocket | ||
|
||
public final class NoticedEventRepository: NoticedEventRepositoryInterface { | ||
private var cancellables: Set<AnyCancellable> = [] | ||
private let socketProvider: SocketProvidable | ||
|
||
public var receivedEvent = PassthroughSubject<Event, Never>() | ||
|
||
public init(socketProvider: SocketProvidable) { | ||
self.socketProvider = socketProvider | ||
bind() | ||
} | ||
|
||
public func notice(event: Event) { | ||
guard let eventData = try? JSONEncoder().encode(event) else { return } | ||
socketProvider.sendAll(data: eventData) | ||
} | ||
} | ||
|
||
private extension NoticedEventRepository { | ||
func bind() { | ||
socketProvider.dataShared.sink { [weak self] (data, _) in | ||
guard let event = try? JSONDecoder().decode(Event.self, from: data) else { return } | ||
self?.receivedEvent.send(event) | ||
} | ||
.store(in: &cancellables) | ||
} | ||
} | ||
This file contains 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,10 @@ | ||
// | ||
// Event.swift | ||
// Entity | ||
// | ||
// Created by Yune gim on 12/2/24. | ||
// | ||
|
||
public enum Event: Codable { | ||
case openSharedContainer | ||
} |
15 changes: 15 additions & 0 deletions
15
Domain/Interfaces/RepositoryInterface/EventRepositoryInterface.swift
This file contains 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,15 @@ | ||
// | ||
// NoticedEventRepositoryInterface.swift | ||
// Interfaces | ||
// | ||
// Created by Yune gim on 12/2/24. | ||
// | ||
|
||
import Combine | ||
import Entity | ||
|
||
public protocol NoticedEventRepositoryInterface { | ||
var receivedEvent: PassthroughSubject<Event, Never> { get } | ||
|
||
func notice(event: Event) | ||
} |
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.
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.
P2: 만약 이렇게 NoticedEventRepository를 따로 사용하게 된다면 JSONEncoder / JSONDecoder는 따로 빼서 재사용 가능하게 하면 어떨까요?
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.
좋습니다!
그리고 이렇지 않아도 Core에서 JSONEncoder/Decoder를 두고 다른데서 재사용해야 할 필요가 생긴것 같아요.
Data에서 인코딩/디코딩이 많이 일어나기 시작해 보여요