Skip to content
Merged
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
34 changes: 18 additions & 16 deletions AirplaIN/AirplaIN/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,34 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
guard let windowScene = (scene as? UIWindowScene) else { return }

// TODO: - 임시 의존성 주입
let nearbyNetworkService = NearbyNetworkService(serviceName: "airplain")

let profileRepository = ProfileRepository(persistenceService: PersistenceService())
let myProfile = profileRepository.loadProfile()
let nearbyNetworkService = NearbyNetworkService(
myPeerID: myProfile.id,
serviceName: "airplain",
serviceType: "_airplain._tcp")
let filePersistenceService = FilePersistence()
let whiteboardObjectSet = WhiteboardObjectSet()

let profileRepository = ProfileRepository(persistenceService: PersistenceService())
let whiteboardListRepository = WhiteboardListRepository(nearbyNetworkService: nearbyNetworkService)
let whiteboardRepository = WhiteboardRepository(
nearbyNetworkInterface: nearbyNetworkService,
myProfile: profileRepository.loadProfile())
let whiteboardObjectRepository = WhiteboardObjectRepository(
nearbyNetwork: nearbyNetworkService,
nearbyNetworkService: nearbyNetworkService,
filePersistence: filePersistenceService)
let photoRepository = PhotoRepository(filePersistence: filePersistenceService)
let chatRepository = ChatRepository(
nearbyNetwork: nearbyNetworkService,
nearbyNetworkService: nearbyNetworkService,
filePersistence: filePersistenceService)

let whiteboardUseCase = WhiteboardUseCase(
whiteboardRepository: whiteboardRepository,
let whiteboardListUseCase = WhiteboardListUseCase(
whiteboardListRepository: whiteboardListRepository,
profileRepository: profileRepository)
let profileUseCase = ProfileUseCase(repository: profileRepository)
let manageWhiteboardObjectUseCase = ManageWhiteboardObjectUseCase(
let whiteboardUseCase = WhiteboardUseCase(
profileRepository: profileRepository,
whiteboardObjectRepository: whiteboardObjectRepository,
whiteboardRepository: whiteboardRepository,
whiteboardObjectSet: whiteboardObjectSet)
let manageWhiteboardToolUseCase = ManageWhiteboardToolUseCase()
let whiteboardToolUseCase = WhiteboardToolUseCase()
let textObjectUseCase = TextObjectUseCase(
whiteboardObjectSet: whiteboardObjectSet,
textFieldDefaultSize: CGSize(width: 200, height: 50))
Expand All @@ -60,23 +62,23 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

let whiteboardObjectViewFactory = WhiteboardObjectViewFactory()

let whiteboardListViewModel = WhiteboardListViewModel(whiteboardUseCase: whiteboardUseCase)
let whiteboardListViewModel = WhiteboardListViewModel(whiteboardListUseCase: whiteboardListUseCase)
let profileViewModel = ProfileViewModel(profileUseCase: profileUseCase)

let whiteboardListViewController = WhiteboardListViewController(
viewModel: whiteboardListViewModel,
whiteboardObjectViewFactory: whiteboardObjectViewFactory,
profileViewModel: profileViewModel,
profileRepository: profileRepository,
whiteboardUseCase: whiteboardUseCase,
whiteboardListUseCase: whiteboardListUseCase,
photoUseCase: photoUseCase,
drawObjectUseCase: drawObjectUseCase,
textObjectUseCase: textObjectUseCase,
chatUseCase: chatUseCase,
gameRepository: gameRepository,
gameObjectUseCase: gameObjectUseCase,
manageWhiteboardToolUseCase: manageWhiteboardToolUseCase,
manageWhiteboardObjectUseCase: manageWhiteboardObjectUseCase)
whiteboardToolUseCase: whiteboardToolUseCase,
whiteboardUseCase: whiteboardUseCase)

let window = UIWindow(windowScene: windowScene)
let navigationController = UINavigationController(rootViewController: whiteboardListViewController)
Expand Down
16 changes: 8 additions & 8 deletions DataSource/DataSource.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* Begin PBXBuildFile section */
00036B842CF5648A007D1244 /* PhotoRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00036B832CF5648A007D1244 /* PhotoRepository.swift */; };
00549AD02CEDBAAD00DF8F6C /* AirplaINDataType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00549ACF2CEDBA5E00DF8F6C /* AirplaINDataType.swift */; };
00549AD22CEDBB3E00DF8F6C /* DataInformationDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00549AD12CEDBB0E00DF8F6C /* DataInformationDTO.swift */; };
00549AD22CEDBB3E00DF8F6C /* AirplaINDataDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00549AD12CEDBB0E00DF8F6C /* AirplaINDataDTO.swift */; };
0080E8652CE19EC40095B958 /* NearbyNetworkInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0080E85F2CE19EC40095B958 /* NearbyNetworkInterface.swift */; };
0080E8662CE19EC40095B958 /* NetworkConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0080E8612CE19EC40095B958 /* NetworkConnection.swift */; };
5B54DECC2CEEF70000674723 /* RequestedContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B54DECB2CEEF70000674723 /* RequestedContext.swift */; };
Expand All @@ -18,7 +18,7 @@
5BDFD93D2CE2F56B00DA4F5B /* WhiteboardRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BDFD93C2CE2F56B00DA4F5B /* WhiteboardRepository.swift */; };
6F3BCDCC2CF31F5C005F6642 /* ChatRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F3BCDCB2CF31F5C005F6642 /* ChatRepository.swift */; };
6F4031422CEDDF0800948CCF /* FilePersistenceInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F4031412CEDDF0800948CCF /* FilePersistenceInterface.swift */; };
6FF51C792CEF07D2005DE9CD /* WhiteboardObjectRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6FF51C782CEF07D2005DE9CD /* WhiteboardObjectRepository.swift */; };
A807DE6D2D30B91600262974 /* WhiteboardListRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = A807DE6C2D30B91600262974 /* WhiteboardListRepository.swift */; };
A81E7BFD2CF728E6007E8414 /* GameRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81E7BFC2CF728E6007E8414 /* GameRepository.swift */; };
A8525F1E2CE326DB0089DA5E /* PersistenceInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8525F1D2CE326DB0089DA5E /* PersistenceInterface.swift */; };
A852601E2CE339E70089DA5E /* ProfileRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = A852601D2CE339E70089DA5E /* ProfileRepository.swift */; };
Expand All @@ -43,7 +43,7 @@
/* Begin PBXFileReference section */
00036B832CF5648A007D1244 /* PhotoRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoRepository.swift; sourceTree = "<group>"; };
00549ACF2CEDBA5E00DF8F6C /* AirplaINDataType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AirplaINDataType.swift; sourceTree = "<group>"; };
00549AD12CEDBB0E00DF8F6C /* DataInformationDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataInformationDTO.swift; sourceTree = "<group>"; };
00549AD12CEDBB0E00DF8F6C /* AirplaINDataDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AirplaINDataDTO.swift; sourceTree = "<group>"; };
0080E85F2CE19EC40095B958 /* NearbyNetworkInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NearbyNetworkInterface.swift; sourceTree = "<group>"; };
0080E8612CE19EC40095B958 /* NetworkConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkConnection.swift; sourceTree = "<group>"; };
5B54DECB2CEEF70000674723 /* RequestedContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestedContext.swift; sourceTree = "<group>"; };
Expand All @@ -52,7 +52,7 @@
5BDFD93C2CE2F56B00DA4F5B /* WhiteboardRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardRepository.swift; sourceTree = "<group>"; };
6F3BCDCB2CF31F5C005F6642 /* ChatRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRepository.swift; sourceTree = "<group>"; };
6F4031412CEDDF0800948CCF /* FilePersistenceInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FilePersistenceInterface.swift; sourceTree = "<group>"; };
6FF51C782CEF07D2005DE9CD /* WhiteboardObjectRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardObjectRepository.swift; sourceTree = "<group>"; };
A807DE6C2D30B91600262974 /* WhiteboardListRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardListRepository.swift; sourceTree = "<group>"; };
A81E7BFC2CF728E6007E8414 /* GameRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameRepository.swift; sourceTree = "<group>"; };
A8525F1D2CE326DB0089DA5E /* PersistenceInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistenceInterface.swift; sourceTree = "<group>"; };
A852601D2CE339E70089DA5E /* ProfileRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileRepository.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -87,7 +87,7 @@
0080E8612CE19EC40095B958 /* NetworkConnection.swift */,
5B54DECB2CEEF70000674723 /* RequestedContext.swift */,
00549ACF2CEDBA5E00DF8F6C /* AirplaINDataType.swift */,
00549AD12CEDBB0E00DF8F6C /* DataInformationDTO.swift */,
00549AD12CEDBB0E00DF8F6C /* AirplaINDataDTO.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -140,8 +140,8 @@
isa = PBXGroup;
children = (
A852601D2CE339E70089DA5E /* ProfileRepository.swift */,
A807DE6C2D30B91600262974 /* WhiteboardListRepository.swift */,
5BDFD93C2CE2F56B00DA4F5B /* WhiteboardRepository.swift */,
6FF51C782CEF07D2005DE9CD /* WhiteboardObjectRepository.swift */,
00036B832CF5648A007D1244 /* PhotoRepository.swift */,
6F3BCDCB2CF31F5C005F6642 /* ChatRepository.swift */,
A81E7BFC2CF728E6007E8414 /* GameRepository.swift */,
Expand Down Expand Up @@ -273,8 +273,8 @@
00036B842CF5648A007D1244 /* PhotoRepository.swift in Sources */,
A81E7BFD2CF728E6007E8414 /* GameRepository.swift in Sources */,
A852601E2CE339E70089DA5E /* ProfileRepository.swift in Sources */,
6FF51C792CEF07D2005DE9CD /* WhiteboardObjectRepository.swift in Sources */,
00549AD22CEDBB3E00DF8F6C /* DataInformationDTO.swift in Sources */,
A807DE6D2D30B91600262974 /* WhiteboardListRepository.swift in Sources */,
00549AD22CEDBB3E00DF8F6C /* AirplaINDataDTO.swift in Sources */,
6F4031422CEDDF0800948CCF /* FilePersistenceInterface.swift in Sources */,
6F3BCDCC2CF31F5C005F6642 /* ChatRepository.swift in Sources */,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@ import Foundation
public protocol FilePersistenceInterface {
/// 데이터를 dataInfo에 맞게 파일로 저장하고 저장위치를 반환합니다.
/// - Parameters:
/// - dataInfo: 저장할 데이터의 정보: uuid, 데이터타입
/// - data: 저장할 데이터
/// - dto: 저장할 데이터
/// - Returns: URL로 저장된 위치 반환
@discardableResult
func save(
dataInfo: DataInformationDTO,
data: Data?) -> URL?
func save(dto: AirplaINDataDTO) -> URL?

/// path위치에 있는 데이터를 가져옵니다.
/// - Parameter path: 가져올 데이터의 위치를 URL로 받습니다.
/// - Returns: 해당 위치에 존재하는 데이터를 가져옵니다.
func load(path: URL) -> Data?

/// 데이터가 저장되어 있다면, 저장되어 있는 URL을 반환합니다.
/// - Parameter dataInfo: 저장한 데이터의 정보
/// - Parameter dto: 저장한 데이터
/// - Returns: 데이터의 저장 위치
func fetchURL(dataInfo: DataInformationDTO) -> URL?
func fetchURL(dto: AirplaINDataDTO) -> URL?
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import Combine
import Foundation

public protocol NearbyNetworkInterface {
var reciptDataPublisher: AnyPublisher<Data, Never> { get }
var reciptURLPublisher: AnyPublisher<(url: URL, dataInfo: DataInformationDTO), Never> { get }
var reciptDataPublisher: AnyPublisher<AirplaINDataDTO, Never> { get }
var searchingDelegate: NearbyNetworkSearchingDelegate? { get set }
var connectionDelegate: NearbyNetworkConnectionDelegate? { get set }

/// 주변 기기 검색을 중지합니다.
Expand All @@ -19,11 +19,6 @@ public protocol NearbyNetworkInterface {
/// 주변 기기를 검색합니다.
func startSearching()

/// 주변에 내 기기를 정보와 함께 알립니다.
/// - Parameter data: 담을 정보
@available(*, deprecated, message: "이 메서드는 network framework로 리팩터링 하면서 사용되지 않을 예정입니다.")
func startPublishing(with info: [String: String])

/// 주변에 내 기기를 정보와 함께 알립니다.
/// - Parameters:
/// - hostName: 호스트의 이름
Expand All @@ -36,108 +31,48 @@ public protocol NearbyNetworkInterface {
/// 연결된 모든 피어와 연결을 끊습니다.
func disconnectAll()

/// 주변 기기와 연결을 시도합니다.
/// - Parameter connection: 연결할 기기
@available(*, deprecated, message: "이 메서드는 network framework로 리팩터링 하면서 사용되지 않을 예정입니다.")
func joinConnection(connection: NetworkConnection, context: RequestedContext) throws

/// 주변 기기와 연결을 시도합니다.
/// - Parameters:
/// - connection: 연결할 기기
/// - myConnectionInfo: 내 정보
/// - Returns: 연결 요청 성공 여부
func joinConnection(
connection: RefactoredNetworkConnection,
myConnectionInfo: RequestedContext) -> Result<Bool, Never>

/// 연결된 기기들에게 파일을 송신합니다.
/// - Parameters:
/// - fileURL: 파일의 URL
/// - info: 파일에 대한 정보
@available(*, deprecated, message: "이 메서드는 network framework로 리팩터링 하면서 사용되지 않을 예정입니다.")
func send(fileURL: URL, info: DataInformationDTO) async
connection: NetworkConnection,
myConnectionInfo: RequestedContext) async -> Bool

/// 연결된 기기들에게 데이터를 송신합니다.
/// - Parameter data: 송신할 데이터
/// - Returns: 전송 성공 여부
func send(data: DataInformationDTO) async -> Bool

/// 특정 기기에게 파일을 전송합니다.
/// - Parameters:
/// - fileURL: 파일의 URL
/// - info: 파일에 대한 정보
/// - connection: 전송할 기기 연결 정보
@available(*, deprecated, message: "이 메서드는 network framework로 리팩터링 하면서 사용되지 않을 예정입니다.")
func send(
fileURL: URL,
info: DataInformationDTO,
to connection: NetworkConnection) async
func send(data: AirplaINDataDTO) async -> Bool

/// 특정 기기에게 데이터를 전송합니다.
/// - Parameters:
/// - data: 송신할 데이터
/// - connection: 전송할 기기 연결 정보
/// - Returns: 전송 성공 여부
func send(data: DataInformationDTO, to connection: RefactoredNetworkConnection) async -> Bool
func send(data: AirplaINDataDTO, to connection: NetworkConnection) async -> Bool
}

public protocol NearbyNetworkConnectionDelegate: AnyObject {
/// 주변 기기에게 연결 요청을 받았을 때 실행됩니다.
/// - Parameters:
/// - connectionHandler: 연결 요청 처리 Handler
func nearbyNetwork(_ sender: NearbyNetworkInterface, didReceive connectionHandler: @escaping (Bool) -> Void)

public protocol NearbyNetworkSearchingDelegate: AnyObject {
/// 주변 기기가 검색됐을 때 실행됩니다.
/// - Parameters:
/// - connections: 검색된 기기들
func nearbyNetwork(_ sender: NearbyNetworkInterface, didFind connections: [NetworkConnection])
/// - connections: 검색된 기기
func nearbyNetwork(_ sender: NearbyNetworkInterface, didFind connection: NetworkConnection)

/// 검색된 기기가 사라졌을 때 실행됩니다.
/// - Parameters:
/// - connection: 사라진 기기
func nearbyNetwork(_ sender: NearbyNetworkInterface, didLost connection: NetworkConnection)
}

/// 주변 기기와의 연결에 실패했을 때 실행됩니다.
func nearbyNetworkCannotConnect(_ sender: NearbyNetworkInterface)

/// 주변 기기와 연결에 성공하였을 때 실행됩니다.
/// - Parameters:
/// - connection: 연결된 기기
/// - info: 기존 Session 정보
@available(*, deprecated, message: "이 메서드는 network framework로 리팩터링 하면서 사용되지 않을 예정입니다.")
func nearbyNetwork(
_ sender: NearbyNetworkInterface,
didConnect connection: NetworkConnection,
with info: [String: String])

/// 주변 기기와 연결에 성공하였을 때 실행됩니다.
/// - Parameters:
/// - connection: 연결된 기기
/// - context: 참여자가 보낸 정보
/// - isHost: 호스트 여부
@available(*, deprecated, message: "이 메서드는 network framework로 리팩터링 하면서 사용되지 않을 예정입니다.")
func nearbyNetwork(
_ sender: NearbyNetworkInterface,
didConnect connection: NetworkConnection,
with context: Data?,
isHost: Bool)

public protocol NearbyNetworkConnectionDelegate: AnyObject {
/// 주변 기기와 연결에 성공했을 때 실행됩니다.
/// - Parameters:
/// - didConnect: 연결된 peer
func nearbyNetwork(_ sender: NearbyNetworkInterface, didConnect connection: RefactoredNetworkConnection)

/// 연결됐던 기기와 연결이 끊어졌을 때 실행됩니다.
/// - Parameters:
/// - connection: 연결이 끊긴 기기
@available(*, deprecated, message: "이 메서드는 network framework로 리팩터링 하면서 사용되지 않을 예정입니다.")
func nearbyNetwork(
_ sender: NearbyNetworkInterface,
didDisconnect connection: NetworkConnection,
isHost: Bool)
func nearbyNetwork(_ sender: NearbyNetworkInterface, didConnect connection: NetworkConnection)

/// 연결됐던 기기와 연결이 끊어졌을 때 실행됩니다.
/// - Parameters:
/// - connection: 연결이 끊긴 기기
func nearbyNetwork(_ sender: NearbyNetworkInterface, didDisconnect connection: RefactoredNetworkConnection)
func nearbyNetwork(_ sender: NearbyNetworkInterface, didDisconnect connection: NetworkConnection)
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
//
// DataInformationDTO.swift
// AirplaINDataDTO.swift
// DataSource
//
// Created by 이동현 on 11/20/24.
//

import Foundation

public struct DataInformationDTO: Codable {
public struct AirplaINDataDTO: Codable {
public let id: UUID
public let data: Data
Copy link
Member

Choose a reason for hiding this comment

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

여기에 data를 Data타입으로 되어 있는데,
보내 줄 데이터를 인코딩하여 넣어주기만 하면 될 것 같은데, 맞을까요??

public let type: AirplaINDataType
public let isDeleted: Bool

public init(
id: UUID,
data: Data,
type: AirplaINDataType,
isDeleted: Bool
) {
self.id = id
self.data = data
self.type = type
self.isDeleted = isDeleted
}
Expand Down
Loading
Loading