E
E
EnderBro3D2018-06-13 17:23:16
Java
EnderBro3D, 2018-06-13 17:23:16

Wrong bytes coming?

I'm doing a core on a minecraft server. The essence is simple: transferring user data, groups, etc.
An error occurred while transferring groups. IndexOutOfBoundsException.
Then comes the piece of data. Someone said that if the packet is too big, it scatters it into chunks and sends it, and when it arrives, the chunks "stick together" again. But for some reason nothing sticks to me.
Here is the error itself:
5b2128bf59399738404180.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vamp, 2018-06-14
@EnderBro3D

Since it does not stick together by itself, then you need to glue it yourself. The algorithm is quite simple - we read no more than readableBytes() bytes from the buffer. If there was not enough data to complete the packet, then we save what we read and wait for the next packet, from where we finish reading the missing one.
Typically, network protocols provide a header with the total length of the packet or end markers so that you can understand how much data needs to be read from the network.
These squares in the log are almost certainly a packet end marker or the following header:
But I think that the engine provides higher-level abstractions that themselves collect raw packets into some kind of Packet250CustomPayload, and you just have to process them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question