davidstump / SwiftPhoenixClient

Connect your Phoenix and iOS applications through WebSockets!
MIT License
507 stars 147 forks source link

Question: Control retries with NWPathMonitor #179

Closed aj-foster closed 3 years ago

aj-foster commented 3 years ago

Hello there. I'm currently using 1.3; haven't checked out the 2.x branch. This question probably works for both, however.

I'm interested in halting connection attempts if NWPathMonitor tells me that the device has lost connection to the internet. Intuition tells me we can call disconnect(code:callback:) on the socket if that happens, and connect() when the connection returns.

Given that the socket would almost certainly be in a retry loop by the time NWPathMonitor notifies us, do you foresee any issues with this plan? disconnect(code:callback:) seems straightforward enough, but I'm not keen to see any race conditions that might pop up.

Thanks for your work on this project, and for your advice!

dsrees commented 3 years ago

disconnect() should halt the reconnect process.