Class BufferedConnection

java.lang.Object
alexiil.mc.lib.net.ActiveConnection
alexiil.mc.lib.net.BufferedConnection
Direct Known Subclasses:
ActiveMinecraftConnection

public abstract class BufferedConnection
extends ActiveConnection
  • Field Details

  • Constructor Details

  • Method Details

    • setMaxBandwidth

      public void setMaxBandwidth​(int to)
    • sendPacket

      protected final void sendPacket​(NetByteBuf data, int packetId, @Nullable NetIdBase netId, int priority)
      Specified by:
      sendPacket in class ActiveConnection
      packetId - The packet ID that has been written out to the first int of the given buffer.
      netId - The NetIdBase that is being written out. Will be null if the packet ID is one of the internal packets.
      priority - The priority for the packet. Will be either 0 or a negative number.
    • maximumPacketSize

      protected int maximumPacketSize()
      Returns:
      The maximum packet size that a single output packet can be. Used to try to keep the data sent to sendRawData0(NetByteBuf) below this value when combining data into packets.
    • tick

      public void tick()
      Ticks this connection, flushing all queued data that needs to be sent immediately.
    • sendTickPacket

      protected void sendTickPacket()
      Optional method for subclasses to send additional packet before the queue is flushed.
    • hasPackets

      protected final boolean hasPackets()
    • onReceiveRawData

      public void onReceiveRawData​(NetByteBuf data) throws InvalidInputDataException
      Overrides:
      onReceiveRawData in class ActiveConnection
      Throws:
      InvalidInputDataException
    • sendRawData0

      protected abstract void sendRawData0​(NetByteBuf data)
      Sends some raw data. It might contain multiple packets, half packets, or even less. Either way the implementation should just directly send the data on to the other side, and ensure it arrives in-order.