resolveFutures method

  1. @override
ProgressResult resolveFutures(
  1. int handle,
  2. String resultsJson,
  3. String errorsJson
)
override

Resolves pending futures with resultsJson and errorsJson.

resultsJson is a JSON object mapping call_id (string) to value. errorsJson is a JSON object mapping call_id (string) to error message.

Implementation

@override
ProgressResult resolveFutures(
  int handle,
  String resultsJson,
  String errorsJson,
) {
  final ptr = Pointer<ffi_native.MontyHandle>.fromAddress(handle);
  final cResults = resultsJson.toNativeUtf8().cast<Char>();
  final cErrors = errorsJson.toNativeUtf8().cast<Char>();
  final outError = calloc<Pointer<Char>>();

  try {
    final tag = ffi_native.monty_resume_futures(
      ptr,
      cResults,
      cErrors,
      outError,
    );

    return _buildProgressResult(ptr, tag, outError.value);
  } finally {
    calloc
      ..free(cResults)
      ..free(cErrors)
      ..free(outError);
  }
}