Skip to content

Commit

Permalink
Improve connection freshness check
Browse files Browse the repository at this point in the history
  • Loading branch information
funkyboy committed Apr 27, 2018
1 parent 60cf4eb commit deb79a7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Source/ARTRealtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,18 @@ - (void)connect {
}

- (void)_connect {
NSTimeInterval intervalSinceLast = [[NSDate date] timeIntervalSinceDate:_lastActivity];

// We want to enforce a new connection also when there hasn't been activity for longer than (idle interval + TTL)
if(self.connection.state_nosync == ARTRealtimeClosing || intervalSinceLast > (_maxIdleInterval + _connectionStateTtl)) {
if(self.connection.state_nosync == ARTRealtimeClosing) {
// New connection
_transport = nil;
}

// We want to enforce a new connection also when there hasn't been activity for longer than (idle interval + TTL)
NSTimeInterval intervalSinceLast = [[NSDate date] timeIntervalSinceDate:_lastActivity];
if (intervalSinceLast > (_maxIdleInterval + _connectionStateTtl)) {
[self.connection setId:nil];
[self.connection setKey:nil];
[self.connection setSerial:0];
}
[self transition:ARTRealtimeConnecting];
}

Expand Down

0 comments on commit deb79a7

Please sign in to comment.