Package alexiil.mc.lib.net
Class BufferedConnection
java.lang.Object
alexiil.mc.lib.net.ActiveConnection
alexiil.mc.lib.net.BufferedConnection
- Direct Known Subclasses:
ActiveMinecraftConnection
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
protected int
void
onReceiveRawData(NetByteBuf data)
protected void
sendPacket(NetByteBuf data, int packetId, NetIdBase netId, int priority)
protected abstract void
sendRawData0(NetByteBuf data)
Sends some raw data.protected void
Optional method for subclasses to send additional packet before the queue is flushed.void
setMaxBandwidth(int to)
void
tick()
Ticks this connection, flushing all queued data that needs to be sent immediately.Methods inherited from class alexiil.mc.lib.net.ActiveConnection
getMinecraftContext, getNetSide, getPlayer, postConstruct
-
Field Details
-
ENABLE_QUEUE
public static final boolean ENABLE_QUEUE- See Also:
- Constant Field Values
-
-
Constructor Details
-
BufferedConnection
-
-
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 classActiveConnection
packetId
- The packet ID that has been written out to the first int of the given buffer.netId
- TheNetIdBase
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
- Overrides:
onReceiveRawData
in classActiveConnection
- Throws:
InvalidInputDataException
-
sendRawData0
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.
-