implement force async logic for inbound packets
This commit is contained in:
parent
1beb95115f
commit
d8cfd1e3c5
|
@ -50,6 +50,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||
public static class Client extends PacketTypeEnum {
|
||||
private final static Sender SENDER = Sender.CLIENT;
|
||||
|
||||
@ForceAsync
|
||||
public static final PacketType SET_PROTOCOL = new PacketType(PROTOCOL, SENDER, 0x00, "SetProtocol", "C00Handshake");
|
||||
|
||||
private final static Client INSTANCE = new Client();
|
||||
|
@ -457,6 +458,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||
|
||||
@ForceAsync
|
||||
public static final PacketType SERVER_INFO = new PacketType(PROTOCOL, SENDER, 0x00, "ServerInfo", "SPacketServerInfo");
|
||||
@ForceAsync
|
||||
public static final PacketType PONG = new PacketType(PROTOCOL, SENDER, 0x01, "Pong", "SPacketPong");
|
||||
|
||||
/**
|
||||
|
@ -487,6 +489,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||
private final static Sender SENDER = Sender.CLIENT;
|
||||
|
||||
public static final PacketType START = new PacketType(PROTOCOL, SENDER, 0x00, "Start", "CPacketServerQuery");
|
||||
@ForceAsync
|
||||
public static final PacketType PING = new PacketType(PROTOCOL, SENDER, 0x01, "Ping", "CPacketPing");
|
||||
|
||||
private final static Client INSTANCE = new Client();
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.comphenix.protocol.events.PacketEvent;
|
|||
import com.comphenix.protocol.injector.NetworkProcessor;
|
||||
import com.comphenix.protocol.injector.netty.ChannelListener;
|
||||
import com.comphenix.protocol.injector.netty.Injector;
|
||||
import com.comphenix.protocol.injector.packet.PacketRegistry;
|
||||
import com.comphenix.protocol.reflect.FuzzyReflection;
|
||||
import com.comphenix.protocol.reflect.accessors.Accessors;
|
||||
import com.comphenix.protocol.reflect.accessors.FieldAccessor;
|
||||
|
@ -501,7 +502,10 @@ public class NettyChannelInjector implements Injector {
|
|||
return;
|
||||
}
|
||||
|
||||
if (ctx.channel().eventLoop().inEventLoop()) {
|
||||
// check the async force status - in the context of incoming listeners this is more a "check execution should
|
||||
// be directly on calling thread" thing, but the method is already there and suits the use case the best
|
||||
PacketType packetType = PacketRegistry.getPacketType(packetClass);
|
||||
if (!packetType.isAsyncForced() && ctx.channel().eventLoop().inEventLoop()) {
|
||||
// we're in a netty event loop - prevent that from happening as it slows down netty
|
||||
// in normal cases netty only has 4 processing threads available which is *really* bad when we're
|
||||
// then blocking these (or more specifically a plugin) to process the incoming packet
|
||||
|
|
Loading…
Reference in New Issue