The current UdpLoop() method is an infinite loop and there does not appear to be a way to end this loop.
I find that if the WSJT-X application exits, crashes, or fails the UdpLoop will happily run forever and the parent caller doesn't get the opportunity to automatically re-connect.
I would two things:
- A way for the caller to pass in a CancellationToken to end the endless loop on demand
- Modify the UdpLoop with a watchdog timer such that the loop exits with an error if no heartbeat message is received in a certain time period.
For example, I would like the constructor to have this signature (or similar):
public WsjtxClient(Action<WsjtxMessage, IPEndPoint> callback, IPAddress ipAddress, int port = 2237, bool multicast = false, bool debug = false, int heartbeatWatchdogSeconds = 60, CancellationToken cancellationToken = default)