Package net.minecraft.network
Class Connection
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<Packet<?>>
net.minecraft.network.Connection
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
- Direct Known Subclasses:
FakePlayer.FakeConnection,RateKickingConnection
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SocketAddressThe address of the remote partyprivate static final floatprivate floatprivate float(package private) BandwidthDebugMonitorprivate io.netty.channel.ChannelThe active channelprivate DisconnectionDetailsprivate DisconnectionDetailsprivate booleanprivate PacketListenerprivate booleanprivate booleanprivate ProtocolInfo<?> private static final ProtocolInfo<ServerHandshakePacketListener> static final Supplier<io.netty.channel.DefaultEventLoopGroup> private static final org.slf4j.Loggerstatic final Supplier<io.netty.channel.epoll.EpollEventLoopGroup> static final Supplier<io.netty.channel.nio.NioEventLoopGroup> static final org.slf4j.Markerstatic final org.slf4j.Markerstatic final org.slf4j.Markerprivate PacketListenerThe PacketListener instance responsible for processing received packetsprivate final Queue<Consumer<Connection>> private intprivate final PacketFlowstatic final org.slf4j.Markerprivate booleanprivate intprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.netty.channel.Channelchannel()voidchannelActive(io.netty.channel.ChannelHandlerContext pContext) voidchannelInactive(io.netty.channel.ChannelHandlerContext pContext) protected voidchannelRead0(io.netty.channel.ChannelHandlerContext pContext, Packet<?> pPacket) static voidconfigureInMemoryPipeline(io.netty.channel.ChannelPipeline pPipeline, PacketFlow pFlow) voidconfigurePacketHandler(io.netty.channel.ChannelPipeline pPipeline) static voidconfigureSerialization(io.netty.channel.ChannelPipeline pPipeline, PacketFlow pFlow, boolean pMemoryOnly, BandwidthDebugMonitor pBandwithDebugMonitor) static io.netty.channel.ChannelFutureconnect(InetSocketAddress pAddress, boolean pUseEpollIfAvailable, Connection pConnection) static ConnectionconnectToLocalServer(SocketAddress pAddress) Prepares a clientside Connection for a local in-memory connection ("single player").static ConnectionconnectToServer(InetSocketAddress pAddress, boolean pUseEpollIfAvailable, LocalSampleLogger pSampleLogger) private static io.netty.channel.ChannelInboundHandlercreateFrameDecoder(BandwidthDebugMonitor pBandwithDebugMonitor, boolean pMemoryOnly) private static io.netty.channel.ChannelOutboundHandlercreateFrameEncoder(boolean pMemoryOnly) voiddisconnect(Component pMessage) Closes the channel with a given reason.voiddisconnect(DisconnectionDetails pDisconnectionDetails) private voiddoSendPacket(Packet<?> pPacket, io.netty.channel.ChannelFutureListener pSendListener, boolean pFlush) voidexceptionCaught(io.netty.channel.ChannelHandlerContext pContext, Throwable pException) private voidflush()voidprivate voidprivate static <T extends PacketListener>
voidgenericsFtw(Packet<T> pPacket, PacketListener pListener) floatfloatProtocolInfo<?> getLoggableAddress(boolean pLogIps) voidprivate static StringinboundHandlerName(boolean pServerbound) private <S extends ServerboundPacketListener,C extends ClientboundPacketListener>
voidinitiateServerboundConnection(String pHostName, int pPort, ProtocolInfo<S> pServerboundProtocol, ProtocolInfo<C> pClientboundProtocol, C pPacketListener, ClientIntent pIntention) voidinitiateServerboundPlayConnection(String pHostName, int pPort, ClientLoginPacketListener pPacketListener) <S extends ServerboundPacketListener,C extends ClientboundPacketListener>
voidinitiateServerboundPlayConnection(String pHostName, int pPort, ProtocolInfo<S> pServerboundProtocol, ProtocolInfo<C> pClientbountProtocol, C pPacketListener, boolean pIsTransfer) voidinitiateServerboundStatusConnection(String pHostName, int pPort, ClientStatusPacketListener pPacketListener) booleanbooleanbooleanbooleanprivate static StringoutboundHandlerName(boolean pClientbound) voidrunOnceConnected(Consumer<Connection> pAction) voidvoidvoidprivate voidsendPacket(Packet<?> pPacket, io.netty.channel.ChannelFutureListener pSendListener, boolean pFlush) voidsetBandwidthLogger(LocalSampleLogger pBandwithLogger) voidsetEncryptionKey(Cipher pDecryptingCipher, Cipher pEncryptingCipher) Enables encryption for this connection using the given decrypting and encrypting ciphers.voidsetListenerForServerboundHandshake(PacketListener pPacketListener) voidvoidsetupCompression(int pThreshold, boolean pValidateDecompressed) Enables or disables compression for this connection.<T extends PacketListener>
voidsetupInboundProtocol(ProtocolInfo<T> pProtocolInfo, T pPacketInfo) voidsetupOutboundProtocol(ProtocolInfo<?> pProtocolInfo) private static voidsyncAfterConfigurationChange(io.netty.channel.ChannelFuture pFuture) voidtick()protected voidprivate voidvalidateListener(ProtocolInfo<?> pProtocolInfo, PacketListener pPacketListener) 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
-
AVERAGE_PACKETS_SMOOTHING
private static final float AVERAGE_PACKETS_SMOOTHING- See Also:
-
LOGGER
private static final org.slf4j.Logger LOGGER -
ROOT_MARKER
public static final org.slf4j.Marker ROOT_MARKER -
PACKET_MARKER
public static final org.slf4j.Marker PACKET_MARKER -
PACKET_RECEIVED_MARKER
public static final org.slf4j.Marker PACKET_RECEIVED_MARKER -
PACKET_SENT_MARKER
public static final org.slf4j.Marker PACKET_SENT_MARKER -
NETWORK_WORKER_GROUP
-
NETWORK_EPOLL_WORKER_GROUP
-
LOCAL_WORKER_GROUP
-
INITIAL_PROTOCOL
-
receiving
-
sendLoginDisconnect
private volatile boolean sendLoginDisconnect -
pendingActions
-
channel
private io.netty.channel.Channel channelThe active channel -
address
The address of the remote party -
disconnectListener
-
packetListener
The PacketListener instance responsible for processing received packets -
disconnectionDetails
-
encrypted
private boolean encrypted -
disconnectionHandled
private boolean disconnectionHandled -
receivedPackets
private int receivedPackets -
sentPackets
private int sentPackets -
averageReceivedPackets
private float averageReceivedPackets -
averageSentPackets
private float averageSentPackets -
tickCount
private int tickCount -
handlingFault
private boolean handlingFault -
delayedDisconnect
-
bandwidthDebugMonitor
-
inboundProtocol
-
-
Constructor Details
-
Connection
-
-
Method Details
-
channelActive
- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext pContext) - Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter
-
exceptionCaught
- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead0
- Specified by:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<Packet<?>>
-
genericsFtw
private static <T extends PacketListener> void genericsFtw(Packet<T> pPacket, PacketListener pListener) -
validateListener
-
syncAfterConfigurationChange
private static void syncAfterConfigurationChange(io.netty.channel.ChannelFuture pFuture) -
setupInboundProtocol
public <T extends PacketListener> void setupInboundProtocol(ProtocolInfo<T> pProtocolInfo, T pPacketInfo) -
setupOutboundProtocol
-
setListenerForServerboundHandshake
-
initiateServerboundStatusConnection
public void initiateServerboundStatusConnection(String pHostName, int pPort, ClientStatusPacketListener pPacketListener) -
initiateServerboundPlayConnection
public void initiateServerboundPlayConnection(String pHostName, int pPort, ClientLoginPacketListener pPacketListener) -
initiateServerboundPlayConnection
public <S extends ServerboundPacketListener,C extends ClientboundPacketListener> void initiateServerboundPlayConnection(String pHostName, int pPort, ProtocolInfo<S> pServerboundProtocol, ProtocolInfo<C> pClientbountProtocol, C pPacketListener, boolean pIsTransfer) -
initiateServerboundConnection
private <S extends ServerboundPacketListener,C extends ClientboundPacketListener> void initiateServerboundConnection(String pHostName, int pPort, ProtocolInfo<S> pServerboundProtocol, ProtocolInfo<C> pClientboundProtocol, C pPacketListener, ClientIntent pIntention) -
send
-
send
-
send
public void send(Packet<?> pPacket, @Nullable io.netty.channel.ChannelFutureListener pSendListener, boolean pFlush) -
runOnceConnected
-
sendPacket
private void sendPacket(Packet<?> pPacket, @Nullable io.netty.channel.ChannelFutureListener pSendListener, boolean pFlush) -
doSendPacket
private void doSendPacket(Packet<?> pPacket, @Nullable io.netty.channel.ChannelFutureListener pSendListener, boolean pFlush) -
flushChannel
public void flushChannel() -
flush
private void flush() -
flushQueue
private void flushQueue() -
tick
public void tick() -
tickSecond
protected void tickSecond() -
getRemoteAddress
-
getLoggableAddress
-
disconnect
Closes the channel with a given reason. The reason is stored for later and will be used for informational purposes (info log on server, disconnection screen on the client). This method is also called on the client when the server requests disconnection viaClientboundDisconnectPacket. Closing the channel this way does not send any disconnection packets, it simply terminates the underlying netty channel. -
disconnect
-
isMemoryConnection
public boolean isMemoryConnection() -
getReceiving
-
getSending
-
connectToServer
public static Connection connectToServer(InetSocketAddress pAddress, boolean pUseEpollIfAvailable, @Nullable LocalSampleLogger pSampleLogger) -
connect
public static io.netty.channel.ChannelFuture connect(InetSocketAddress pAddress, boolean pUseEpollIfAvailable, Connection pConnection) -
outboundHandlerName
-
inboundHandlerName
-
configurePacketHandler
public void configurePacketHandler(io.netty.channel.ChannelPipeline pPipeline) -
configureSerialization
public static void configureSerialization(io.netty.channel.ChannelPipeline pPipeline, PacketFlow pFlow, boolean pMemoryOnly, @Nullable BandwidthDebugMonitor pBandwithDebugMonitor) -
createFrameEncoder
private static io.netty.channel.ChannelOutboundHandler createFrameEncoder(boolean pMemoryOnly) -
createFrameDecoder
private static io.netty.channel.ChannelInboundHandler createFrameDecoder(@Nullable BandwidthDebugMonitor pBandwithDebugMonitor, boolean pMemoryOnly) -
configureInMemoryPipeline
public static void configureInMemoryPipeline(io.netty.channel.ChannelPipeline pPipeline, PacketFlow pFlow) -
connectToLocalServer
Prepares a clientside Connection for a local in-memory connection ("single player"). Establishes a connection to the socket supplied and configures the channel pipeline (only the packet handler is necessary, since this is for an in-memory connection). Returns the newly created instance. -
setEncryptionKey
Enables encryption for this connection using the given decrypting and encrypting ciphers. This adds new handlers to this connection's pipeline which handle the decrypting and encrypting. This happens as part of the normal network handshake.- See Also:
-
isEncrypted
public boolean isEncrypted() -
isConnected
public boolean isConnected() -
isConnecting
public boolean isConnecting() -
getPacketListener
-
getDisconnectionDetails
-
setReadOnly
public void setReadOnly() -
setupCompression
public void setupCompression(int pThreshold, boolean pValidateDecompressed) Enables or disables compression for this connection. Ifthresholdis >= 0 then aCompressionDecoderandCompressionEncoderare installed in the pipeline or updated if they already exist. Ifthresholdis invalid input: '<' 0 then any such codec are removed. Compression is enabled as part of the connection handshake when the server sendsClientboundLoginCompressionPacket. -
handleDisconnection
public void handleDisconnection() -
getAverageReceivedPackets
public float getAverageReceivedPackets() -
getAverageSentPackets
public float getAverageSentPackets() -
setBandwidthLogger
-
channel
public io.netty.channel.Channel channel() -
getDirection
-
getInboundProtocol
-