59
59
// / Invalidation message field names.
60
60
static NSString *const kTemplateVersionNumberKey = @" latestTemplateVersionNumber" ;
61
61
static NSString *const kIsFeatureDisabled = @" featureDisabled" ;
62
+ static NSString *const kRealtime_Retry_Interval = @" retryIntervalSeconds" ;
62
63
63
64
static NSTimeInterval gTimeoutSeconds = 330 ;
64
65
static NSInteger const gFetchAttempts = 3 ;
@@ -521,13 +522,17 @@ - (void)autoFetch:(NSInteger)remainingAttempts targetVersion:(NSInteger)targetVe
521
522
522
523
- (void )evaluateStreamResponse : (NSDictionary *)response error : (NSError *)dataError {
523
524
NSInteger updateTemplateVersion = 1 ;
525
+ NSTimeInterval realtimeRetryInterval = 0 ;
524
526
if (dataError == nil ) {
525
527
if ([response objectForKey: kTemplateVersionNumberKey ]) {
526
528
updateTemplateVersion = [[response objectForKey: kTemplateVersionNumberKey ] integerValue ];
527
529
}
528
530
if ([response objectForKey: kIsFeatureDisabled ]) {
529
531
self->_isRealtimeDisabled = [response objectForKey: kIsFeatureDisabled ];
530
532
}
533
+ if ([response objectForKey: kRealtime_Retry_Interval ]) {
534
+ realtimeRetryInterval = [[response objectForKey: kRealtime_Retry_Interval ] integerValue ];
535
+ }
531
536
532
537
if (self->_isRealtimeDisabled ) {
533
538
[self pauseRealtimeStream ];
@@ -544,6 +549,14 @@ - (void)evaluateStreamResponse:(NSDictionary *)response error:(NSError *)dataErr
544
549
if (updateTemplateVersion > clientTemplateVersion) {
545
550
[self autoFetch: gFetchAttempts targetVersion: updateTemplateVersion];
546
551
}
552
+
553
+ // / This field in the response indicates that the realtime request should retry after the
554
+ // / specified interval to establish a long-lived connection. This interval extends the backoff
555
+ // / duration without affecting the number of retries, so it will not enter an exponential
556
+ // / backoff state.
557
+ if (realtimeRetryInterval > 0 ) {
558
+ [self ->_settings updateRealtimeBackoffTimeWithInterval: realtimeRetryInterval];
559
+ }
547
560
}
548
561
} else {
549
562
NSError *error =
0 commit comments