-
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
[Refactor] NearbyNetwork 데이터 송수신 기능 리팩터링 #152
Conversation
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.
고생하셨습니다!!
완벽하네요 :)
while tryCount < 3 { | ||
let result = await withCheckedContinuation { (continuation: Continuation) in | ||
connection.send( | ||
content: encodedData, | ||
contentContext: context, | ||
completion: .contentProcessed({ error in | ||
if let error { | ||
continuation.resume(returning: false) | ||
} else { | ||
continuation.resume(returning: true) | ||
} | ||
})) | ||
} | ||
|
||
if result { return true } | ||
tryCount += 1 | ||
} |
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.
withCheckedContinuation으로 클로저 내부의 error에 따른 처리를 해 주셨군요..??
다른 방법도 있을 것 같은데, 이 코드를 보니.. 이코드밖에 생각이 안날 것 같네요!(그만큼 훌륭하단 뜻) 좋습니다!
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.
우선 Continuation을 사용한 이유는 send의 결과 값을 반환하기 위해 불가피하게 wrapping 하였습니다!
저희가 고려한 다른 방법은 완료 핸들러를 통해 send 결과를 전달하는 방식이었는데요! 이 방식보다 continuation으로 감싸 결과 값을 직접 반환하는 편이 가독성과 코드 유지 보수 측면에서 더 낫다고 판단했습니다!
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.
띵쪼 고생 많으셨습니다 😄
@@ -150,6 +150,10 @@ extension NearbyNetworkService: NearbyNetworkInterface { | |||
} | |||
} | |||
|
|||
public func send(data: DataInformationDTO) async -> Bool { | |||
return true |
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.
갑자기 이거 보고 생각났는데..
저는 딴이랑 페프할 때 한줄이면 return
생략했거덩요?
별거 아니니까 그냥 무시시 고고??
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.
허얼 ~ 1줄이여도 노 생략인게 저희 컨벤션으루 기억합니다만 !!??!!!!
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.
엇.. 저희 명시적으로 작성하려구 한 줄 일때도 return 생략하지 않기로 했던 것으로 기억합니다!
🌁 Background
MPC 프레임워크를 Network 프레임 워크로 교체하며 데이터 송수신 기능을 리팩터링 하였습니다.
👩💻 Contents
📝 Review Note
데이터 송신 실패 시 반복문을 통해 3회까지 재전송하도록 하였습니다.
📣 Related Issue