Limit reconnect retries to 5
This commit is contained in:
parent
12d00b16cc
commit
c937c4a6fc
1 changed files with 11 additions and 0 deletions
|
|
@ -57,6 +57,8 @@ abstract class ChatStoreBase with Store {
|
|||
|
||||
StreamSubscription? _sevenTVChannelListener;
|
||||
|
||||
static const _maxRetries = 5;
|
||||
|
||||
// The retry counter for exponential backoff.
|
||||
var _retries = 0;
|
||||
|
||||
|
|
@ -451,6 +453,15 @@ abstract class ChatStoreBase with Store {
|
|||
onDone: () async {
|
||||
if (_channel == null) return;
|
||||
|
||||
if (_retries >= _maxRetries) {
|
||||
messageBuffer.add(
|
||||
IRCMessage.createNotice(
|
||||
message: 'Disconnected from chat',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_backoffTime > 0) {
|
||||
// Add notice that chat was disconnected and then wait the backoff time before reconnecting.
|
||||
final notice =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue