-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tokio + serde rewrite #11
Comments
Sounds good. I had gotten it working with mio but never got it cleaned up enough to push. I'll take a look at what you've done this weekend. |
mio is extremely low-level, and it does seem like it'd be hard for people to use. On the other hand, tokio is much more user-friendly, with all the futures-based abstractions that it offers. |
Did you make any progress on this? Sounds really promising! |
Sadly, I do not have the time to update my framework to 1.14; if you manage to get it to work, I'll publish my implementation on github so that you can make a pull request. |
I don't know if that's a good idea especially when async/await syntax will come soon |
The general structure will not change - not only that, you don't need to rewrite existing async functionality, for the most part, as |
Since async programming is getting quite popular, I decided to test out tokio's codecs and it turns out that they are very well suited for minecraft's protocol, since it's effectively length-delimited. I haven't touched encryption or compression yet, but the former seems to be quite easy to write a Read/Write adapter for and the latter should be pretty much the same as the synchronous implementation.
I also figured that it's possible to use
serde
to automatically deserialize the vast majority of packets, and use the fact that the protocol is pretty consistent with how arrays are length-prefixed, and enums are id-prefixed with varints. There will definitely be packets for which (de)serializing will be much more complex, but it's easy to simply parse the packet manually if that is the case.As a bonus, it would be much easier to translate packets between versions - all you need to do is just serialize them in a self-describing format such as CBOR and then read them back. Not foolproof, but it should work for simple cases.
I've made an initial implementation that works here: https://hyper.is-a.cat/gogs/x10A94/mcproto/ - note that most of the packets aren't implemented yet, in part due to their complexity, and are simply stubbed out.
The text was updated successfully, but these errors were encountered: