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
S
elf, and we are connected to someO
ther device: If we disconnectS
from the network:-
O
will thinkS
is still connected untilO
hard refreshes (disconnect from all and restart discovery) - When
S
joins the network again whileO
still thinksS
is connected, the only way forS
to connect toO
is forO
to 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