Skip to content

Commit

Permalink
Fixed apparent bug involving accepting invitations from browsers. See…
Browse files Browse the repository at this point in the history
… upstream issue jpsim#16.
  • Loading branch information
stevenbedrick committed Feb 14, 2017
1 parent 1351bce commit 7f5904b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion PeerKit/Advertiser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class Advertiser: NSObject, MCNearbyServiceAdvertiserDelegate {
// }

func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: Data?, invitationHandler: @escaping (Bool, MCSession?) -> Void) {
let accept = mcSession.myPeerID.hashValue > peerID.hashValue

// keep us from accepting our own invitation?
let accept = mcSession.myPeerID.displayName.hashValue != peerID.displayName.hashValue

invitationHandler(accept, mcSession)
if accept {
stopAdvertising()
Expand Down

0 comments on commit 7f5904b

Please sign in to comment.