Package net.minecraft.network
Class ClientConnection
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<Packet<?>>
net.minecraft.network.ClientConnection
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
- Direct Known Subclasses:
RateLimitedConnection
public class ClientConnection extends io.netty.channel.SimpleChannelInboundHandler<Packet<?>>
A connection backed by a netty channel. It can be one to a client on the
server or one to a server on a client.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classClientConnection.QueuedPacketNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
Fields Modifier and Type Field Description private SocketAddressaddressprivate floataveragePacketsReceivedprivate floataveragePacketsSentprivate io.netty.channel.Channelchannelstatic Lazy<io.netty.channel.nio.NioEventLoopGroup>CLIENT_IO_GROUPprivate booleandisconnectedprivate TextdisconnectReasonprivate booleanencryptedstatic Lazy<io.netty.channel.epoll.EpollEventLoopGroup>EPOLL_CLIENT_IO_GROUPprivate booleanerroredstatic Lazy<io.netty.channel.DefaultEventLoopGroup>LOCAL_CLIENT_IO_GROUPprivate static LoggerLOGGERstatic MarkerNETWORK_MARKERstatic MarkerNETWORK_PACKETS_MARKERprivate PacketListenerpacketListenerprivate Queue<ClientConnection.QueuedPacket>packetQueueprivate intpacketsReceivedCounterprivate intpacketsSentCounterstatic io.netty.util.AttributeKey<NetworkState>PROTOCOL_ATTRIBUTE_KEYThe attribute key for the current network state of the backing netty channel.private NetworkSidesideThe side this connection is to.private intticks -
Constructor Summary
Constructors Constructor Description ClientConnection(NetworkSide side) -
Method Summary
Modifier and Type Method Description voidchannelActive(io.netty.channel.ChannelHandlerContext channelHandlerContext)voidchannelInactive(io.netty.channel.ChannelHandlerContext channelHandlerContext)protected voidchannelRead0(io.netty.channel.ChannelHandlerContext channelHandlerContext, Packet<?> packet)static ClientConnectionconnect(InetAddress address, int port, boolean shouldUseNativeTransport)static ClientConnectionconnectLocal(SocketAddress address)voiddisableAutoRead()voiddisconnect(Text disconnectReason)voidexceptionCaught(io.netty.channel.ChannelHandlerContext channelHandlerContext, Throwable throwable)SocketAddressgetAddress()floatgetAveragePacketsReceived()floatgetAveragePacketsSent()TextgetDisconnectReason()PacketListenergetPacketListener()voidhandleDisconnection()private static <T extends PacketListener>
voidhandlePacket(Packet<T> packet, PacketListener listener)booleanhasChannel()booleanisEncrypted()booleanisLocal()booleanisOpen()voidsend(Packet<?> packet)voidsend(Packet<?> packet, io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super Void>> callback)private voidsendImmediately(Packet<?> packet, io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super Void>> callback)private voidsendQueuedPackets()voidsetCompressionThreshold(int compressionThreshold)voidsetPacketListener(PacketListener listener)Sets the packet listener that will handle oncoming packets, including ones that are not yet handled by the current packet listener.voidsetState(NetworkState state)voidsetupEncryption(Cipher decryptionCipher, Cipher encryptionCipher)voidtick()protected voidupdateStats()Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
LOGGER
-
NETWORK_MARKER
-
NETWORK_PACKETS_MARKER
-
PROTOCOL_ATTRIBUTE_KEY
The attribute key for the current network state of the backing netty channel. -
CLIENT_IO_GROUP
-
EPOLL_CLIENT_IO_GROUP
-
LOCAL_CLIENT_IO_GROUP
-
side
The side this connection is to. -
packetQueue
-
channel
private io.netty.channel.Channel channel -
address
-
packetListener
-
disconnectReason
-
encrypted
private boolean encrypted -
disconnected
private boolean disconnected -
packetsReceivedCounter
private int packetsReceivedCounter -
packetsSentCounter
private int packetsSentCounter -
averagePacketsReceived
private float averagePacketsReceived -
averagePacketsSent
private float averagePacketsSent -
ticks
private int ticks -
errored
private boolean errored
-
-
Constructor Details
-
ClientConnection
-
-
Method Details
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext channelHandlerContext) throws Exception- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
setState
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext channelHandlerContext) throws Exception- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext channelHandlerContext, Throwable throwable)- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext channelHandlerContext, Packet<?> packet)- Specified by:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<Packet<?>>
-
handlePacket
private static <T extends PacketListener> void handlePacket(Packet<T> packet, PacketListener listener) -
setPacketListener
Sets the packet listener that will handle oncoming packets, including ones that are not yet handled by the current packet listener. -
send
-
send
-
sendImmediately
-
sendQueuedPackets
private void sendQueuedPackets() -
tick
public void tick() -
updateStats
protected void updateStats() -
getAddress
-
disconnect
-
isLocal
public boolean isLocal() -
connect
@Environment(CLIENT) public static ClientConnection connect(InetAddress address, int port, boolean shouldUseNativeTransport) -
connectLocal
-
setupEncryption
-
isEncrypted
@Environment(CLIENT) public boolean isEncrypted() -
isOpen
public boolean isOpen() -
hasChannel
public boolean hasChannel() -
getPacketListener
-
getDisconnectReason
-
disableAutoRead
public void disableAutoRead() -
setCompressionThreshold
public void setCompressionThreshold(int compressionThreshold) -
handleDisconnection
public void handleDisconnection() -
getAveragePacketsReceived
public float getAveragePacketsReceived() -
getAveragePacketsSent
@Environment(CLIENT) public float getAveragePacketsSent()
-