-
Notifications
You must be signed in to change notification settings - Fork 18
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
add a full packet parser #60
Conversation
I'm really unconvinced that's the right way to do it. What's the difference between this class and the existing |
Right, this expects a chunk will never be cut, and always be a single packet. This isn't a good assumption to make. We should assume a stream is a stream, an endless series of bytes. |
this is only possible is the length is available in the buffer when it gets at the protodef serializer ( #57 (comment) ) |
No ? I believe you're constraining your view to minecraft-protocol. ProtoDef serializer is (or should be, I'm not sure where we're at at this point) able to operate on any type of data. For instance, If minecraft-protocol needs a specific serializer interface for whatever reason, it can easily use "proto.parsePacketBuffer" function to implement it. It doesn't have to use the built-in Serializer. ProtoDef API for most languages really should reduce to :
|
Yes I meant for minecraft protocol. For minecraft protocol we'd need to put the length in the buffer in order to use that same parser. (+ adding the "fixed" type, in protodef or nmp) |
If we got rid of the splitter in nmp (https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/transforms/framing.js#L62 which does basically the same thing as protodef parser (that loop)) things would be much simpler. |
Yes ProtoDef is more general than nmp now. But "more general"(/generic) doesn't only mean "less specific to a given protocol" but also "can handle any protocol especially the hard one such as minecraft protocols" |
I suppose the only problem concerning NMP is that compression is impossible to impl in ProtoDef due to its sync nature. Instead of adding a bunch of hacks, maybe we should reconsider implementing an async interface to ProtoDef ? I'm thinking maybe having an optional async interface might not be too damaging performance-wise. Then compression could be handled in protodef as well [
{ "name": "len", "type": "varint" },
{ "anon": true, "type": "compressed", typeArgs: {
"length": "$len",
"data": [
// packet here
]
}
] |
Yes having an (semi-?)async interface that would be ideal. |
Actually, we don't need stuff to be sync, just to be processed in order I think. Am I wrong ? If order is the problem, we can probably think of solutions ^^. |
I'm not sure tbh. If I really knew I would have fixed PrismarineJS/node-minecraft-protocol#309 |
So. 2 ways to go here:
I think it's useful in node-protodef because nmp is not the only thing that can assume it's not really a stream. |
let's merge this. can be removed if needed |
one way to do #57
It might make more sense to do that since it avoids the queue if we don't need it.
I'll try the "fixed" datatype option though.
(and need an example to test this)