Comments (9)
Peppi does support live matches, if you use event-based parsing and pass in a stream instead of a file. (Although the parse
wrapper in lib.rs
requires Seek
, that's just for better error reporting and I plan to relax that. In the meanwhile you can use parse::parse
directly.)
The best way to get a stream would be to talk to Slippi directly via a network connection or UNIX socket (instead of letting it write to a file and then reading that), but I don't know if there's an easy way to do that right now.
As a workaround, you can use tail
on Linux or Mac (e.g. tail -c+1 -f game.slp
), either via Command or by just piping the output of tail
to your Rust program's STDIN.
On Windows, I believe you can use something like PowerShell's Get-Content
with -Wait
and -Tail
, but I can't guarantee anything.
The error message you're getting means peppi thinks it's done reading the raw
block, which most likely means you're on a commit prior to 2ddd958. If so, can you update and let me know if that fixes things?
from peppi.
Ah, I didn't notice you're using the slp
tool. It doesn't make a lot of sense to run that on an in-progress replay.
You could still do it with tail
if you want (e.g. slp <(tail -c+1 -f game.slp)
), but that will just block until the file is complete (assuming you're on 2ddd958 or later). So there's not much point in doing that instead of just waiting until the file's complete before running slp
.
from peppi.
I tried passing a file via stdin into peppi::parse::parse
which returned an UnexpectedEof error. I believe this is coming from your read_exact in parse.rs
I believe read_exact is the problem because looking at the slippi file of a live game reveals the last event doesn't seem to have all of its bytes yet
I double checked and I am on the latest commit
from peppi.
How are you running your program? If you're using tail -f
then it shouldn't ever reach EOF.
from peppi.
I forward the live game stream into cargo:
cargo run < ~/Slippi/Game_20200826T233310.slp
And gave it to my program:
peppi::parse::parse(io::stdin(), &mut handlers)
Running with tail:
tail -f ~/Slippi/Game_20200827T125636.slp | cargo run
>expected: [123, 85, 3, 114, 97, 119, 91, 36, 85, 35, 108], got: [186, 247, 0, 14, 194, 32, 0, 0, 65, 200, 0]
from peppi.
You need to use tail -f
for live replays. Otherwise you'll run into exactly this problem— peppi hits EOF and has no way to know the file is still being written to. tail -f
creates a stream that never closes, so peppi will keep blocking on reads until it has read all the game data.
In bash, you can do this with process substitution: cargo run -- <(tail -c+1 -f game.slp)
.
Nevermind, if your command reads from STDIN you can just use a regular pipe. But don't forget the -c+1
argument to tail
so that it doesn't skip part of the file.
from peppi.
tail -c+1 -f ~/Slippi/Game_20200827T131405.slp | cargo run
did the trick. Thanks. Any suggestions for making a blocking reader so I don't have to deploy tail in my program?
from peppi.
You could look at https://github.com/uutils/coreutils/tree/master/src/uu/tail if you want to implement the same functionality natively. But if you just want to avoid having to call tail
externally, a simpler approach might be to run tail
via Command and read from its STDOUT.
from peppi.
A better approach, if possible, would be to read directly from Slippi instead of letting it append to a file over and over and then polling that file. I haven't tried to do that, but if you ask on the Slippi discord they might be able to give some advice.
from peppi.
Related Issues (20)
- Parsing replay files can panic in debug mode. HOT 2
- Add LICENSE file HOT 1
- Support parsing only final frame HOT 5
- Support v3.13.0 HOT 1
- Add support for stats HOT 3
- Specify Peppi's round-tripping guarantees/goals HOT 1
- Parse Gecko Code contents HOT 1
- offense_ratio, defense_ratio, and model_scale are parsed incorrectly! HOT 1
- Add benchmarks HOT 2
- Fails to parse replay when encountering a direction value of 0 HOT 2
- Warn user when trying to serialize replay of unsupported version HOT 1
- A single err!() macro call in hot path has 4-5% performance penalty HOT 1
- Skipping frames on streaming replay panics. HOT 2
- Items not handled correctly with option Rollback::First. HOT 1
- Action state frame index HOT 2
- Support Spectator protocol and/or Menu Frame
- Ground IDs HOT 2
- Allow games without an End event
- TrackingReader does a poor job reporting where a parse error occurred. HOT 1
- Version 1.0.0-alpha.7 not on crates.io HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from peppi.