-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deterministic algorithm for invitation acceptance #4
Conversation
As recommended in WWDC 2014 session 709. Use the hash value of the MCPeerID object and whoever has the greater hash value can accept the invitation.
Actually just testing this and it looks like it invites itself possible because there are two MCSession's. One in the advertiser and one in the browser. |
Two MCSession and MCPeerID’s were being created for Browsing and Advertising which meant that a client would connect to itself.
I have noticed the problems that this pull request addresses. @jpsim, please merge this in. |
There is another improvement that I am currently doing at a higher level – which is to stop/start the transceiver and create a new session whenever there is a disconnect and zero connected clients. This is because currently the PeerKit code stops advertising (if it accepts an invitation). This makes sense if there is a cluster of PeerKit devices for perhaps only one to advertise, but maybe all devices should always be advertising. Contrary to the advice found on the interwebs. |
@@ -44,7 +44,7 @@ func didConnecting(myPeerID: MCPeerID, peer: MCPeerID) { | |||
|
|||
func didConnect(myPeerID: MCPeerID, peer: MCPeerID) { | |||
if session == nil { | |||
session = transceiver.sessionForPeer(peer) | |||
session = transceiver.session.mcSession |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well done!
Many many many thanks for this, @alexanderjarvis! |
Deterministic algorithm for invitation acceptance
@jpsim no problem :) |
As recommended in WWDC 2014 session 709. Use the hash value of the
MCPeerID object and whoever has the greater hash value can accept the
invitation.
http://asciiwwdc.com/2014/sessions/709?q=multipeer