Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix looking for peers forever in iOS #37
Right now our iOS discovery code will discover a peer via BLE exactly once. The reason is that we have suppressed multiple discovery notifications because otherwise we get hit about 1000 times a second (yes, literally) with notifications.
The problem is that once we suppress duplicates it means we will literally, never get a notification for that user again (at least as long as the app keeps running, including time in the background).
So what do we do when the user leaves the area? The answer is that we have a long poll BLE connection request to EVERYBODY we discover. And we keep this connection request indefinitely. So if the person disappears the request will fail and we will know and if they come back the request will again work and we will know they are there.
But this potentially means that our list of discovered peers can grow without bound. It's not clear in practice how big a deal this is since presumably when we put in the correct discovery framework we will only bother with the long poll for peers we have ever had anything to do with. But it's still not ideal.
It seems that if we turn discovery off and back on then the iOS device will clear the cached identities it isn't providing notifications for and we can start afresh. For security reasons (we don't want to expose our identity by constantly connecting to the same people) we probably want to periodically turn off and on discovery to clear the list.