Improve refresh discovery
- Only stop and start tcp socket when network actually changed to reduce flickering and chance of concurrent modification to
_pendingSockets - Fix not reconnecting after rejoining network while the other device thinks we are still connected by always reconnecting upon receiving identity package.
- Enable reusing LanLink to allow continuous file transfer even with new socket for every identity package
- Fix missing battery status by sending and requesting battery status after pairing succeeds
- Remove nil checking + removal if true to prevent possible concurrent modification exception
- Prevent concurrency issues on hard refresh by synchronizing access to
Device's_links.
TestFlight
Try out changes in this merge request by joining https://testflight.apple.com/join/N7gQIPan. Limited to 100 external testers, will become unavailable once this merge request is merged.
On Reachability
- We can't reliably tell "joined a new network" because NWPath doesn't have identifying information. We could integrate with Trusted Network feature later -- if the user gives precise location permission
- We can't reliably tell if the other device is still connected, as seen in all KDE Connect clients. Suppose we are device
Self, and we are connected to someOther device: If we disconnectSfrom the network:-
Owill thinkSis still connected untilOhard refreshes (disconnect from all and restart discovery) - When
Sjoins the network again whileOstill thinksSis connected, the only way forSto connect toOis forOto attempt connecting to an "already connected" device. Currently, older versions of KDE Connect iOS app doesn't. - What we want is
SO_KEEPALIVE/TCP_KEEPALIVE, I think, which someone else tried before https://blog.csdn.net/PDUnderstand/article/details/80049903 (note: blog post is in Simplified Chinese)
-
- Hard refresh still possible through Advanced Settings
- To prevent weird socket issues, we now aggressively close sockets immediately upon entering background, since we don't support background activity currently
Edited by Apollo Zhu