dialInitial function Viam SDK
- String address,
- DialOptions? options,
- String sessionCallback()
Initial connection to a robot at the provided address with the given options, allowing for specifying of initial connection attempt count and timeout
Implementation
Future<ClientChannelBase> dialInitial(String address, DialOptions? options, String Function() sessionCallback) async {
final opts = options ?? DialOptions();
int numAttempts = opts.initialConnectionAttempts;
if (numAttempts == 0) {
numAttempts = -1;
}
final timeout = opts.timeout;
opts.timeout = opts.initialConnectionAttemptTimeout;
while (numAttempts != 0) {
try {
final channel = await dial(address, opts, sessionCallback);
opts.timeout = timeout;
return channel;
} catch (e) {
numAttempts -= 1;
if (numAttempts == 0) {
rethrow;
}
}
}
throw Exception('unreachable');
}