From 044ee71cde4059fcfc18e228df602d8e731994df Mon Sep 17 00:00:00 2001 From: taipaise Date: Wed, 20 Nov 2024 18:48:08 +0900 Subject: [PATCH] =?UTF-8?q?feature:=20=EA=B7=BC=EA=B1=B0=EB=A6=AC=20?= =?UTF-8?q?=ED=86=B5=EC=8B=A0=20=EB=AA=A8=EB=93=88=EC=97=90=20url=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=ED=95=9C=20=EC=88=98=EC=8B=A0=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80(#100)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/NearbyNetworkService.swift | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/NearbyNetwork/NearbyNetwork/Sources/NearbyNetworkService.swift b/NearbyNetwork/NearbyNetwork/Sources/NearbyNetworkService.swift index 648b43d..74612db 100644 --- a/NearbyNetwork/NearbyNetwork/Sources/NearbyNetworkService.swift +++ b/NearbyNetwork/NearbyNetwork/Sources/NearbyNetworkService.swift @@ -106,16 +106,16 @@ extension NearbyNetworkService: NearbyNetworkInterface { let infoJsonString = String(data: infoJsonData, encoding: .utf8) else { return } - await withTaskGroup(of: Void.self) { [weak self] taskGroup in - self?.session.connectedPeers.forEach { peer in + await withTaskGroup(of: Void.self) { taskGroup in + session.connectedPeers.forEach { peer in taskGroup.addTask { do { - try await self?.session.sendResource( + try await self.session.sendResource( at: fileURL, withName: infoJsonString, toPeer: peer) } catch { - self?.logger.log(level: .error, "\(peer)에게 file 데이터 전송 실패") + self.logger.log(level: .error, "\(peer)에게 file 데이터 전송 실패") } } } @@ -183,7 +183,16 @@ extension NearbyNetworkService: MCSessionDelegate { at localURL: URL?, withError error: (any Error)? ) { - logger.log(level: .error, "\(peerID.displayName)로부터 데이터 수신을 완료함") + guard + let localURL, + let jsonData = resourceName.data(using: .utf8), + let dto = try? JSONDecoder().decode(DataInformationDTO.self, from: jsonData) + else{ return } + + receiptDelegate?.nearbyNetwork( + self, + didReceiveURL: localURL, + info: dto) } }