Multipeer Connectivity Disconnect

前端 未结 1 1101
你的背包
你的背包 2021-02-08 05:04

I\'m having trouble with staying connected using the Multipeer Connectivity Framework in iOs7. Currently my app is programmatically handling the browsing and advertising using M

相关标签:
1条回答
  • 2021-02-08 05:58

    EDIT Used a support ticket with Apple and they confirmed that calling sendData with too much data or too often can cause disconnects.

    EDIT My hypothesis is that Apple has a thread or queue that is polling to check if peers are connected. If this thread / queue stalls (i.e. a breakpoint is hit or the app pegs the CPU or does something that takes a while on the main thread) it appears that this causes a disconnect.

    Creating my session without encryption seems to have helped performance and with the disconnects, although they still happen.

    MCPeerID* peerId = [[MCPeerID alloc] initWithDisplayName:self.displayName];
    self.peer = [[MultiPeerPeer alloc] initWithDisplayName:peerId.displayName andPeer:peerId];
    self.session = [[MCSession alloc] initWithPeer:peerId securityIdentity:nil encryptionPreference:MCEncryptionNone];
    

    In addition, I have found calling sendData too often (more than 30-60 times a second) can cause the framework to get in a bad state and cause freezes and disconnects.

    0 讨论(0)
提交回复
热议问题