pullServer method
Future<void>
pullServer(
- PullInfoDto pullInfo, {
- required void onStart(
- PullStartDto pullStart
- required void onDownload(
- PullDownloadDto pullDownload
- required void onDone(
- PullDoneDto result
- required void onPullError(
- PullErrorDto error
- void onError(
- Object error,
- StackTrace stackTrace
POST /servers/pull
Implementation
Future<void> pullServer(
PullInfoDto pullInfo, {
required void Function(PullStartDto pullStart) onStart,
required void Function(PullDownloadDto pullDownload) onDownload,
required void Function(PullDoneDto result) onDone,
required void Function(PullErrorDto error) onPullError,
void Function(Object error, StackTrace stackTrace)? onError,
}) async {
try {
await for (final event in pullServerEvents(pullInfo)) {
switch (event) {
case PullStarted(:final data):
onStart(data);
case PullProgress(:final data):
onDownload(data);
case PullCompleted(:final data):
onDone(data);
case PullFailed(:final data):
onPullError(data);
}
}
} catch (error, stackTrace) {
final normalized = _normalizeError(error);
if (onError != null) {
onError(normalized, stackTrace);
return;
}
if (identical(normalized, error)) rethrow;
Error.throwWithStackTrace(normalized, stackTrace);
}
}