11

i hope all is well

please i have create app that share photos between nearby devices using the multiplier connectivity framework.

i have an issue every time i press connect when i share the session and the browser it's tell me connected but i have receive this message and the sending photos it's fail below the error message:

[ERROR] ProcessEvent:1199   Send BINDING_REQUEST failed(C01A0000).

[GCKSession] Not in connected state, so giving up for participant [7A5C490D] on channel [0].
 [GCKSession] Not in connected state, so giving up for participant [7A5C490D] on channel [1].
[ERROR] ICEStopConnectivityCheck:2688 ICEStopConnectivityCheck() found no ICE check with call id (2052868365)
[GCKSession] Not in connected state, so giving up for participant [7A5C490D] on channel [2].
[ERROR] ICEStopConnectivityCheck:2688 ICEStopConnectivityCheck() found no ICE check with call id (2052868365)

the code which i was use it below:

  override func viewDidLoad() {
        super.viewDidLoad()

        collectionView.delegate = self
        collectionView.dataSource = self

        peerID = MCPeerID(displayName: UIDevice.current.name)
        // init the session
        mcSession = MCSession(peer: peerID, securityIdentity: nil, encryptionPreference: .none)
        mcSession.delegate = self

    }

 @IBAction func showAlertForShare(_ sender: UIBarButtonItem) {

        let alertController = UIAlertController(title: "Share Photos", message: "Do You Want Share The Photo With Other User?", preferredStyle: .actionSheet)
        let alertHostSession = UIAlertAction(title: "Host A Session", style: .default) { (alertAction) in
            self.mcAdvertiserAssistant = MCAdvertiserAssistant(serviceType: "hws-desertqwert", discoveryInfo: nil, session: self.mcSession)
            self.mcAdvertiserAssistant.start()
        }

        let alertJoinSession = UIAlertAction(title: "Join A Session", style: .default) { (alertAction) in
            self.mcbrowserViewController = MCBrowserViewController(serviceType: "hws-desertqwert", session: self.mcSession)
            self.mcbrowserViewController.delegate = self
            self.present(self.mcbrowserViewController, animated: true, completion: nil)
        }

        let alertCancel = UIAlertAction(title: "Cancel", style: .cancel) { (alertAction) in
            alertController.dismiss(animated: true, completion: nil)
        }

        alertController.addAction(alertHostSession)
        alertController.addAction(alertJoinSession)
        alertController.addAction(alertCancel)

        self.present(alertController, animated: true, completion: nil)
    }



 // multipeer delegate methods
    func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {

        switch state {
        case .connected:
            print("Connected: \(peerID)")
        case .connecting:
            print("Connecting: \(peerID)")
        case .notConnected:
            print("Not Connecting: \(peerID)")
        }

    }

    func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) {

      print(data)
        if let getImage = UIImage(data: data) {

            print(self.mcSession.connectedPeers.count)
            self.arrayOfImages.append(getImage)
            DispatchQueue.main.async {
                self.collectionView.reloadData()
            }
        }
    }

    func session(_ session: MCSession, didReceive stream: InputStream, withName streamName: String, fromPeer peerID: MCPeerID) {

    }

    func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress) {

    }

    func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL?, withError error: Error?) {

    }

    func browserViewControllerDidFinish(_ browserViewController: MCBrowserViewController) {
        self.dismiss(animated: true, completion: nil)
    }

    func browserViewControllerWasCancelled(_ browserViewController: MCBrowserViewController) {
        self.dismiss(animated: true, completion: nil)
    }

so please can anyone fix this issue?

thanks a lot

Dark Knight
  • 370
  • 3
  • 13
  • I am having the same result after following Hacking with Swift Project 25 project tutorial. – NotationMaster May 06 '19 at 18:17
  • Were you able to solve it? I have almost the same issue, see: https://stackoverflow.com/questions/76656734/not-being-able-to-keep-connection-stable-and-send-data-across-devices-using-mult – oneshot Jul 10 '23 at 21:08

0 Answers0