저는 비교적 짧은 시간 내에 우리의 응용 프로그램에서 Multipeer Connectivity를 사용하려고 노력했습니다. 대부분의 것들이 상당히 부드럽게 진행되었지만 지금 당황스러운 문제에 직면했습니다.Multipeer Connectivity IOS : didFinishReceivingResourceWithName 오류 처리 (충돌)
오류 처리 ... 와이파이 중반 이전 .. 내 코드를 해제를 통해 이루어집니다 구현하려고 할 때 그 행복의 경로를 다음 그러나 때 우리는 모든 데이터가 잘 전달되고있다 ... :
공유기 :
func sendResource(data: Data?, name: String, fileName: String, peerId: MCPeerID){
if data != nil{
let url = createTransferFile(jsonData: data!, name: fileName)
if url != nil{
session.sendResource(at: url!, withName: name, toPeer: peerId, withCompletionHandler: { (error) -> Void in
if error != nil{
NSLog("Error in sending resource send resource: \(error!.localizedDescription)")
}
})
}
}
}
수신기 :
func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL, withError error: Error?) {
NSLog("%@", "didFinishReceivingResourceWithName: \(resourceName)")
if error != nil{
NSLog("error in receiving")
}
if resourceName.contains("clinicDetails"){
if error == nil{
if let data = self.readClinicJsonFromFile(path: localURL){
NSLog("passing to broadcast delegate")
sendDelegate?.addClinicDetails(self, clinicDetailsJSON: data)
}else{
NSLog("there was an error in finding the retrieved file in clinic retrieve finished")
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else{
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else if resourceName.contains("patients"){
//NSLog("clinicId in retrievePatient: \(json["clinicId"])")
if error == nil{
if let data = self.readPatientJsonFromFile(path: localURL){
NSLog("passing to retrieve patients delegate")
retrievePatientDelegate?.addPatients(self, patientJSON: data , clinicId: resourceName.components(separatedBy: "/")[1])
}else{
NSLog("there was an error in finding the retrieved file in patient retrieve finished")
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else{
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else if resourceName == "clinicList"{
if error == nil{
if let data = self.readClinicListJsonFromFile(path: localURL){
NSLog("passing to retrieve retrieveDelegate")
retrieveDelegate?.addClinics(self, clinicsJSON: data["jsonData"] as! [[String:Any]], passcode: data["passcode"] as! String)
}else{
NSLog("there was an error in finding the retrieved file in patient retrieve finished")
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else{
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}
}
오류 우리는 나타날 수
2017-03-06 16:52:54.416352 DC[2445:1444277] [GCKSession] Failed to send a DTLS packet with 78 bytes; sendmsg error: Can't assign requested address (49).
2017-03-06 16:52:54.416560 DC[2445:1444277] [GCKSession] SSLWrite failed, packet was not sent for participant [05280B9E] channelID [4] DTLS context [0x103043ea0] pCList [0x10e94f960]; osStatus = -9803: errno = Can't assign requested address (49).
이 행은 진행률에 따라 더 많이 인쇄됩니다.
Then we also get the following stack in xcode (아직 직접 내 게시물에 이미지를 추가 할 수 없습니다 : <)
Stack Frame from the thread causing the error이 버그 인해 didFinishReceivingResourceWithName 함수에서 localURL에 사과 프레임 워크의 버그로 연결되는 것 같다
추적에서 스택 프레임을 공유 할 수 있습니까? 그 스레드가 추락했을 때 어떤 코드가 실행되고 있었습니까? –
괜찮아요. – JoellyR
스택 프레임이란 무엇입니까? 디버거 세션의 스크린 샷을 보내시겠습니까? 아니면 더 좋은 방법으로 보낼 수 있습니까? @DaveWeston – JoellyR