Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Try to decode multiple packets at once
Dieser Commit ist enthalten in:
Ursprung
d333eb30b8
Commit
ba8629ca0e
@ -11,33 +11,31 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
if (!in.isReadable()) {
|
read_lens: while (in.isReadable()) {
|
||||||
return;
|
int origReaderIndex = in.readerIndex();
|
||||||
}
|
for (int i = 0; i < 3; i++) {
|
||||||
|
if (!in.isReadable()) {
|
||||||
int origReaderIndex = in.readerIndex();
|
|
||||||
for (int i = 0; i < 3; i++) {
|
|
||||||
if (!in.isReadable()) {
|
|
||||||
in.readerIndex(origReaderIndex);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte read = in.readByte();
|
|
||||||
if (read >= 0) {
|
|
||||||
// Make sure reader index of length buffer is returned to the beginning
|
|
||||||
in.readerIndex(origReaderIndex);
|
|
||||||
int packetLength = ProtocolUtils.readVarInt(in);
|
|
||||||
|
|
||||||
if (in.readableBytes() >= packetLength) {
|
|
||||||
out.add(in.readRetainedSlice(packetLength));
|
|
||||||
} else {
|
|
||||||
in.readerIndex(origReaderIndex);
|
in.readerIndex(origReaderIndex);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
byte read = in.readByte();
|
||||||
}
|
if (read >= 0) {
|
||||||
}
|
// Make sure reader index of length buffer is returned to the beginning
|
||||||
|
in.readerIndex(origReaderIndex);
|
||||||
|
int packetLength = ProtocolUtils.readVarInt(in);
|
||||||
|
|
||||||
throw new CorruptedFrameException("VarInt too big");
|
if (in.readableBytes() >= packetLength) {
|
||||||
|
out.add(in.readRetainedSlice(packetLength));
|
||||||
|
continue read_lens;
|
||||||
|
} else {
|
||||||
|
in.readerIndex(origReaderIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new CorruptedFrameException("VarInt too big");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren