public class ClientConnection extends io.netty.channel.SimpleChannelInboundHandler<Packet<?>>
Modifier and Type | Class and Description |
---|---|
(package private) static class |
ClientConnection.QueuedPacket |
Modifier and Type | Field and Description |
---|---|
private SocketAddress |
address |
static io.netty.util.AttributeKey<NetworkState> |
ATTR_KEY_PROTOCOL |
private float |
avgPacketsReceived |
private float |
avgPacketsSent |
private io.netty.channel.Channel |
channel |
static Lazy<io.netty.channel.nio.NioEventLoopGroup> |
CLIENT_IO_GROUP |
static Lazy<io.netty.channel.epoll.EpollEventLoopGroup> |
CLIENT_IO_GROUP_EPOLL |
static Lazy<io.netty.channel.DefaultEventLoopGroup> |
CLIENT_IO_GROUP_LOCAL |
private boolean |
disconnected |
private Text |
disconnectReason |
private boolean |
encrypted |
private boolean |
errored |
private static Logger |
LOGGER |
static Marker |
MARKER_NETWORK |
static Marker |
MARKER_NETWORK_PACKETS |
private PacketListener |
packetListener |
private Queue<ClientConnection.QueuedPacket> |
packetQueue |
private int |
packetsReceivedCounter |
private int |
packetsSentCounter |
private NetworkSide |
side |
private int |
ticks |
Constructor and Description |
---|
ClientConnection(NetworkSide side) |
Modifier and Type | Method and Description |
---|---|
void |
channelActive(io.netty.channel.ChannelHandlerContext channelHandlerContext) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext channelHandlerContext) |
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext channelHandlerContext,
Packet<?> packet) |
static ClientConnection |
connect(InetAddress address,
int port,
boolean shouldUseNativeTransport) |
static ClientConnection |
connectLocal(SocketAddress address) |
void |
disableAutoRead() |
void |
disconnect(Text disconnectReason) |
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext channelHandlerContext,
Throwable throwable) |
SocketAddress |
getAddress() |
float |
getAveragePacketsReceived() |
float |
getAveragePacketsSent() |
Text |
getDisconnectReason() |
PacketListener |
getPacketListener() |
void |
handleDisconnection() |
private static <T extends PacketListener> |
handlePacket(Packet<T> packet,
PacketListener listener) |
boolean |
hasChannel() |
boolean |
isEncrypted() |
boolean |
isLocal() |
boolean |
isOpen() |
void |
send(Packet<?> packet) |
void |
send(Packet<?> packet,
io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super Void>> callback) |
private void |
sendImmediately(Packet<?> packet,
io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super Void>> callback) |
private void |
sendQueuedPackets() |
void |
setCompressionThreshold(int compressionThreshold) |
void |
setPacketListener(PacketListener listener) |
void |
setState(NetworkState state) |
void |
setupEncryption(Cipher cipher,
Cipher cipher2) |
void |
tick() |
protected void |
updateStats() |
acceptInboundMessage, channelRead
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
private static final Logger LOGGER
public static final Marker MARKER_NETWORK
public static final Marker MARKER_NETWORK_PACKETS
public static final io.netty.util.AttributeKey<NetworkState> ATTR_KEY_PROTOCOL
public static final Lazy<io.netty.channel.nio.NioEventLoopGroup> CLIENT_IO_GROUP
public static final Lazy<io.netty.channel.epoll.EpollEventLoopGroup> CLIENT_IO_GROUP_EPOLL
public static final Lazy<io.netty.channel.DefaultEventLoopGroup> CLIENT_IO_GROUP_LOCAL
private final NetworkSide side
private final Queue<ClientConnection.QueuedPacket> packetQueue
private io.netty.channel.Channel channel
private SocketAddress address
private PacketListener packetListener
private Text disconnectReason
private boolean encrypted
private boolean disconnected
private int packetsReceivedCounter
private int packetsSentCounter
private float avgPacketsReceived
private float avgPacketsSent
private int ticks
private boolean errored
public ClientConnection(NetworkSide side)
public void channelActive(io.netty.channel.ChannelHandlerContext channelHandlerContext) throws Exception
channelActive
in interface io.netty.channel.ChannelInboundHandler
channelActive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void setState(NetworkState state)
public void channelInactive(io.netty.channel.ChannelHandlerContext channelHandlerContext) throws Exception
channelInactive
in interface io.netty.channel.ChannelInboundHandler
channelInactive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public void exceptionCaught(io.netty.channel.ChannelHandlerContext channelHandlerContext, Throwable throwable)
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
protected void channelRead0(io.netty.channel.ChannelHandlerContext channelHandlerContext, Packet<?> packet)
channelRead0
in class io.netty.channel.SimpleChannelInboundHandler<Packet<?>>
private static <T extends PacketListener> void handlePacket(Packet<T> packet, PacketListener listener)
public void setPacketListener(PacketListener listener)
public void send(Packet<?> packet)
public void send(Packet<?> packet, @Nullable io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super Void>> callback)
private void sendImmediately(Packet<?> packet, @Nullable io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super Void>> callback)
private void sendQueuedPackets()
public void tick()
protected void updateStats()
public SocketAddress getAddress()
public void disconnect(Text disconnectReason)
public boolean isLocal()
@Environment(value=CLIENT) public static ClientConnection connect(InetAddress address, int port, boolean shouldUseNativeTransport)
@Environment(value=CLIENT) public static ClientConnection connectLocal(SocketAddress address)
@Environment(value=CLIENT) public boolean isEncrypted()
public boolean isOpen()
public boolean hasChannel()
public PacketListener getPacketListener()
public void disableAutoRead()
public void setCompressionThreshold(int compressionThreshold)
public void handleDisconnection()
public float getAveragePacketsReceived()
@Environment(value=CLIENT) public float getAveragePacketsSent()