connect method
Opens a connection in the worker using connectionString.
timeoutMs is the login timeout in milliseconds (0 = driver default).
Throws AsyncError with AsyncErrorCode.connectionFailed if the
connection fails. Call initialize before connect.
Returns the native connection ID (positive integer) on success.
Implementation
Future<int> connect(String connectionString, {int timeoutMs = 0}) async {
if (!_isInitialized) {
throw const AsyncError(
code: AsyncErrorCode.notInitialized,
message: 'Environment not initialized. Call initialize() first.',
);
}
final r = await _sendRequest<ConnectResponse>(
ConnectRequest(_nextRequestId(), connectionString, timeoutMs: timeoutMs),
);
if (r.error != null) {
throw AsyncError(
code: AsyncErrorCode.connectionFailed,
message: r.error!,
);
}
return r.connectionId;
}