Closed nurmukhametdaniyar closed 3 years ago
Maybe this example helps you here on writing streams with allo-isolate https://github.com/shekohex/rustystream
Maybe this example helps you here on writing streams with allo-isolate https://github.com/shekohex/rustystream
I see how this is working and actually managed to stream data from Rust to Dart, but only when I knew that data is coming and I was just sending some arbitrary data. The thing is that I am trying to stream data from CAN protocol to Dart, but I just want to keep listening to CAN and send it whenever there is data, and when there is no data, just don't do anything.
It looks like this: 1) I open the CAN socket 2) I listen to CAN 3) Whenever there is data on CAN, I send it. If there is no data, I just wait until it comes
I want the loop to be infinite and end whenever the Dart program finishes. I tried doing infinite loops on Dart's side and calling function over and over again, but it didn't help, since there is a small-time to pass data from Rust to Dart and process it in Dart, so in that time some CAN frames are skipped
Nevermind, just spawning another thread worked out :D
I am trying to stream data from Rust to Dart. I am listening to CAN frames and when I receive one, I post it into Isolate, but the problem is that data is not streamed to Dart, instead it is sent in batch after the function is completed. Because of this kind of behavior, I am trying to use a workaround on Dart's side where I call the function over and over again after I receive data from CAN, but it leads to missing some CAN frames which are really important. Here is the code on the Rust side:
And here is the data listener class:
This is the function on the Dart's side which calls for the listenData function:
So I basically want to create an infinite loop for streaming data from Rust to Dart. Or is it even possible to do with Allo isolate?