saul / demofile-net

Blazing fast cross-platform demo parser library for Counter-Strike 2 and Valve's Deadlock, written in C#.
MIT License
96 stars 8 forks source link

Add WebAssembly example #35

Open in0finite opened 8 months ago

saul commented 8 months ago

Just want to say this is great - I had no idea that C# WASM was so simple.

Rather than using the ReadAllAsync method, instead can you change to StartParsing/MoveNext and yield to the web UI every 17ms or so? That way the tab won't freeze up as it's parsing, and you get results live.

Many thanks

in0finite commented 8 months ago

Yep, wasm support is quite cool 😎

I guess "live" parsing should be simple to add. Probably a repetitive JS timer which advances demo for 17 ms.

Or you can even go step further and run the parser in Web Worker (ie. a background thread in Web) 😄

Will see tomorrow if I have time to add it.

in0finite commented 8 months ago

It's done.

I constrained it to 20 FPS, because 60 FPS increases processing time a lot. I don't know why, probably Task.Delay() has some overhead, or it's not precise to 1 ms level.