Add flow control handler for Via

Adds missing flow control handler to ViaVersion's pipeline to fix several issues related to the configuration state
Closes https://github.com/ViaVersion/ViaFabricPlus/issues/414
This commit is contained in:
FlorianMichael 2024-05-17 22:56:27 +02:00
parent 56ee795de5
commit 1f5ac05fcf
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,34 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
* Copyright (C) 2023-2024 contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.protocoltranslator.netty;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.flow.FlowControlHandler;
public class NoReadFlowControlHandler extends FlowControlHandler {
@Override
public void read(ChannelHandlerContext ctx) throws Exception {
if (ctx.channel().config().isAutoRead()) {
super.read(ctx);
}
}
}

View File

@ -31,6 +31,8 @@ import net.raphimc.vialoader.netty.VLLegacyPipeline;
public class ViaFabricPlusVLLegacyPipeline extends VLLegacyPipeline {
public static final String VIA_FLOW_CONTROL = "via-flow-control";
public static final String VIABEDROCK_COMPRESSION_HANDLER_NAME = "viabedrock-compression";
public static final String VIABEDROCK_ENCRYPTION_HANDLER_NAME = "viabedrock-encryption";
public static final String VIABEDROCK_PING_ENCAPSULATION_HANDLER_NAME = "viabedrock-ping-encapsulation";
@ -43,6 +45,8 @@ public class ViaFabricPlusVLLegacyPipeline extends VLLegacyPipeline {
public void handlerAdded(ChannelHandlerContext ctx) {
super.handlerAdded(ctx);
ctx.pipeline().addAfter(VIA_DECODER_NAME, VIA_FLOW_CONTROL, new NoReadFlowControlHandler());
this.user.getProtocolInfo().getPipeline().add(VFPProtocol.INSTANCE);
}