Class PacketBlocker

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
org.geysermc.floodgate.core.addon.data.PacketBlocker
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class PacketBlocker extends io.netty.channel.ChannelInboundHandlerAdapter
In Floodgate the PacketBlocker is used to temporarily prevent packets from being decoded. A similar system is used to prevent packets from being handled while Floodgate is processing the login. The old system blocked the thread which was processing the Floodgate login, but that doesn't only block the packets for that specific user, it's shared between multiple users causing them to lag or sometimes timeout.
The reason why we prevent packets from being handled is because keeping the packet order is important. That is also the reason why we prevent packets from being decoded during that time. The 'login start' packet for example can only be decoded after the handshake packet has been handled, because the server can only successfully decode the packet after the handshake packet caused the server to switch to the login state.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
     
    void
     
    void
     
    boolean
     
    void
    handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
     

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerRemoved
  • Constructor Details

    • PacketBlocker

      public PacketBlocker()
  • Method Details

    • enable

      public void enable()
    • disable

      public void disable()
    • enabled

      public boolean enabled()
    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
    • handlerAdded

      public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      handlerAdded in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerAdded in class io.netty.channel.ChannelHandlerAdapter