Skip to content

Commit

Permalink
Shortcircuit if sessions disabled (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
njooma authored Nov 13, 2024
1 parent e882c7b commit ba96ae3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/src/robot/sessions_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class SessionsClient implements ResourceRPCClient {

/// Reset the current session and re-obtain metadata
void reset() {
if (!_enabled) return;
_logger.d('Resetting current session with ID: $_currentId');
_currentId = '';
_supported = null;
Expand All @@ -90,6 +91,7 @@ class SessionsClient implements ResourceRPCClient {

/// Stop the session client and heartbeat tasks
void stop() {
if (!_enabled) return;
_logger.d('Stopping SessionClient');
_currentId = '';
_supported = null;
Expand All @@ -101,13 +103,15 @@ class SessionsClient implements ResourceRPCClient {
}

Future<void> _heartbeatTask() async {
if (!_enabled) return;
while (_supported == true) {
await _heartbeatTick();
await Future.delayed(_heartbeatInterval);
}
}

Future<void> _heartbeatTick() async {
if (!_enabled) return;
if (_supported == false) return;

final request = SendSessionHeartbeatRequest()..id = _currentId;
Expand Down

0 comments on commit ba96ae3

Please sign in to comment.