Hi all,
I'm creating an app that downloads audio files from our server. In order to denote a files download status (percent), I have the app handle emit an event after each read:
// While we have a chunk that's valid coming from the stream
while let Some(chunk) = stream.next().await {
// Grab another lock on our files
let mut progress_file_lock = download_state.files.lock().await;
// Grab the bytes then write them to the file
let chunk = chunk?;
file.write_all(&chunk)?;
// Add onto the progress
progress += chunk.len() as u64;
// Store our progress as a fraction against the file
let percentage = progress as f64 / total_size as f64;
progress_file_lock[index].progress = percentage;
// Drop the progress file lock so that we can emit the change in download state
drop(progress_file_lock);
// Convert into a payload that we can use
let payload = download_state.convert_into_payload().await;
// Now that we have our converted data, emit it to the front-end
app_handle.emit_all("download_state_updated", payload).unwrap();
}
However, I found that on downloading over 100 files, I received this error when unwrapping the emit event:
Runtime(FailedToSendMessage)
Has anyone encountered this before and what it means? I haven't been able to find much in the way of documentation. Thank you!