-
Notifications
You must be signed in to change notification settings - Fork 2
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] 근거리 통신 모듈에 URL을 이용한 통신 메서드 추가 #103
Conversation
c0adb53
to
044ee71
Compare
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.
고생하셨습니다!!
swift concurrency가 알고있는 것보다 공부할 것이 더 많군요..
func nearbyNetwork( | ||
_ sender: NearbyNetworkInterface, | ||
didReceiveURL URL: URL, | ||
info: DataInformationDTO) |
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.
style: 닫히는 괄호가 밑으로 내려와야 하는 것 같습니다!
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.
요 부분은 저희 같이 이야기 나눈대로 현상유지하도록 하겠습니다 :)
toPeer: peer | ||
) { error in |
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.
style: 소괄호 올라가 있어야 할 것 같습니다ㅜㅜ
새로 생성 해 준것이라고 착각했었네요...
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.
바로 수정하겠습니다!!!!!
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.
e626d5c 반영했습니다!!
) async throws { | ||
typealias Continuation = CheckedContinuation<Void, Error> | ||
|
||
try await withCheckedThrowingContinuation { (continuation: Continuation) in |
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.
이것을 통해 swift Concurrency처럼 사용할 수 있게 해주는 군요..!
이부분은 공부를 해봐야할 것 같습니다..!ㅜㅜ
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.
꺆 !!!!!!!!!!!!!! 쏘 어렵 ... 내일 설명해주기 .......................................
await withTaskGroup(of: Void.self) { taskGroup in | ||
session.connectedPeers.forEach { peer in | ||
taskGroup.addTask { | ||
do { | ||
try await self.session.sendResource( | ||
at: fileURL, | ||
withName: infoJsonString, | ||
toPeer: peer) | ||
} catch { | ||
self.logger.log(level: .error, "\(peer)에게 file 데이터 전송 실패") | ||
} | ||
} | ||
} | ||
} |
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.
이부분도 공부해보겠습니다!
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.
다시봐도 어렵네유
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.
어푸푸 어푸푸푸 어푸푸 어푸푸푸푸 굉장히 어려운 부분 .....................................
Concurrency 공부할 기회를 주셔서 감사 ..... 😇👏🏻
@@ -8,7 +8,7 @@ | |||
import Foundation | |||
|
|||
public protocol NearbyNetworkInterface { | |||
var delegate: NearbyNetworkDelegate? { get set } | |||
var connectionDelegate: NearbyNetworkConnectionDelegate? { get set } |
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.
그러니까 근거리통신 연결 로직을 NearbyNetworkConnectionDelegate가,
근거리통신 송수신 로직을 NearbyNetworkReceiptDelegate가 담당하게 되는게 맞나요 ??
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.
똑똑한 조이 맞습니다!!
import Foundation | ||
|
||
public struct DataInformationDTO: Codable { | ||
let identifier: UUID |
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.
단순 궁금증인데 다른 Entity들은 id로 되어 있는데 이 친구는 왜 identifier로 췤 하는지 ?? 요
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.
id 로 수정하겠습니다
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.
e626d5c 반영했습니다!!
) async throws { | ||
typealias Continuation = CheckedContinuation<Void, Error> | ||
|
||
try await withCheckedThrowingContinuation { (continuation: Continuation) in |
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.
꺆 !!!!!!!!!!!!!! 쏘 어렵 ... 내일 설명해주기 .......................................
e626d5c
to
2c0bf1d
Compare
2c0bf1d
to
6db839f
Compare
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.
고생하셨씁니다!
await withTaskGroup(of: Void.self) { taskGroup in | ||
session.connectedPeers.forEach { peer in | ||
taskGroup.addTask { | ||
do { | ||
try await self.session.sendResource( | ||
at: fileURL, | ||
withName: infoJsonString, | ||
toPeer: peer) | ||
} catch { | ||
self.logger.log(level: .error, "\(peer)에게 file 데이터 전송 실패") | ||
} | ||
} | ||
} | ||
} |
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.
다시봐도 어렵네유
@@ -55,3 +55,19 @@ public protocol NearbyNetworkDelegate: AnyObject { | |||
/// 주변 기기와의 연결에 실패했을 때 실행됩니다. | |||
func nearbyNetworkCannotConnect(_ sender: NearbyNetworkInterface) | |||
} | |||
|
|||
public protocol NearbyNetworkReceiptDelegate: AnyObject { |
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.
connection, receipt 적절한 기준으로 잘 나눈거같아용
🌁 Background
👩💻 Contents
✅ Testing
📝 Review Note
MCSession
의sendResource
메서드는 완료 핸들러를 통해 비동기 이벤트를 처리하는데요, 이를 Swift Concurrency로 래핑하였습니다.sendResource
를 통해 데이터를 전송하는 방식은 일반send
와는 다르게peer
에게 1:1로 데이터를 송신합니다. 따라서 반복문으로 연결된 피어들에게 데이터를 전송해줘야 했습니다. 좀 더 효율적으로 전송하기 위해TaskGroup
을 이용하여 데이터를 병렬 전송하는 방법을 선택했습니다.📣 Related Issue
📬 Reference