Skip to content
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

Merged
merged 4 commits into from Mar 4, 2015
Merged

Deterministic algorithm for invitation acceptance #4

merged 4 commits into from Mar 4, 2015

Conversation

alexanderjarvis
Copy link
Contributor

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

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.
@alexanderjarvis
Copy link
Contributor Author

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.

Alex Jarvis added 3 commits February 8, 2015 11:47
Two MCSession and MCPeerID’s were being created for Browsing and
Advertising which meant that a client would connect to itself.
@nickswalker
Copy link
Contributor

I have noticed the problems that this pull request addresses. @jpsim, please merge this in.

@alexanderjarvis
Copy link
Contributor Author

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done!

@jpsim
Copy link
Owner

jpsim commented Mar 4, 2015

Many many many thanks for this, @alexanderjarvis!

jpsim added a commit that referenced this pull request Mar 4, 2015
Deterministic algorithm for invitation acceptance
@jpsim jpsim merged commit 4c7be30 into jpsim:master Mar 4, 2015
@alexanderjarvis
Copy link
Contributor Author

@jpsim no problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants