Add retry logic to HTTP Streams

On a 0-byte read or a disconnect, optionally automatically reconnect
up to a user specified number of tries with a delay between each attempt.
This commit is contained in:
Earle F. Philhower, III committed 2017-11-22 07:20:42 -08:00
1 parent 2737dec473
commit 432f892d70
4 files changed
+59 -47

No files matched your search

+3 -2
View File
@@ -43,14 +43,15 @@ class AudioFileSourceHTTPStream : public AudioFileSource
virtual bool isOpen() override;
virtual uint32_t getSize() override;
virtual uint32_t getPos() override;
bool SetReconnect(bool val) { reconnect = val; return true; }
bool SetReconnect(int tries, int delayms) { reconnectTries = tries; reconnectDelayMs = delayms; return true; }
private:
virtual uint32_t readInternal(void *data, uint32_t len, bool nonBlock);
HTTPClient http;
int pos;
int size;
bool reconnect;
int reconnectTries;
int reconnectDelayMs;
char *saveURL;
};