Multipeer Connectivity custom connection logic
I wanted to touch back to my blog from yesterday. Staying true to my previous statement the every time I think I truly understand it I soon find out that I really don't, today I found out that my design for connection did not hold a stable connection. After going back down the rabbit hole for many hours, I was finally able to create a connection that was stable.
One big issue I saw reoccurring today was that peers would stop advertising to no reason, and this would cause their connection to the session to be lost, and would cause a domino effect of peers losing their connections. This would not be a catastrophe if I could find a sound way to reconnect the peers, but finding this solution is proving to be difficult.
After losing connection I had peers resend invitations to all connect peers, who should be only accepting the invitationHandler, but the connection was never made. From the articles I have read, as well what I have seen happening in my logs, only one user can send an invitation and one user accept it.
Using this belief i setup the logic so that when two peers meet, they are both advertising, but it takes an action of hitting a button for one user to send an invite for the session connection, and the other user is programmatically accepting this invite. After the session is established I make it so that the peer who initiated the connection is now what I refer to as the "Inviter", and all other peers are what I call the "Accepters". Basically my Inviter sends an invitation to every peer it detects advertising, and once another peer picks up the invitation they accept it automatically, and are set so they cannot invite any other peers. Since all peers are connected through the Inviter they are all therefore connected to the same session.
Now this very logic of them all being connected to the same session may be the reasoning behind the fact that I cannot reconnect after a connection is lost. I may need to tear down, and reset the entire session. This would be very bothersome, and seems unnecessary. I hope I am incorrect about this, but I am having a lot of trouble reconnecting peers. For the purpose of our demo on Thursday I believe using my current method will work, but in real world practice it is necessary for me to solve this issue.
It just seems like the issues I am having should not be issues with this technology, but for some reason they are. I am hoping after some sleep I will be able to figure this out tomorrow and find what I am looking for. Once I find the solution I will be sure to add it to this blog.











