Class NettyNetworkHandler
java.lang.Object
io.netty5.channel.SimpleChannelInboundHandler<eu.cloudnetservice.driver.network.protocol.BasePacket>
eu.cloudnetservice.driver.impl.network.netty.NettyNetworkHandler
- All Implemented Interfaces:
io.netty5.channel.ChannelHandler
- Direct Known Subclasses:
NettyNetworkClientHandler, NettyNetworkServerHandler
public abstract class NettyNetworkHandler
extends io.netty5.channel.SimpleChannelInboundHandler<eu.cloudnetservice.driver.network.protocol.BasePacket>
The default netty inbound handler used to call downstream packet listeners when receiving a packet.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NettyNetworkChannelprivate static final org.slf4j.Logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelExceptionCaught(@NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull Throwable cause) voidchannelInactive(@NonNull io.netty5.channel.ChannelHandlerContext ctx) voidchannelReadComplete(@NonNull io.netty5.channel.ChannelHandlerContext ctx) protected abstract @NonNull Collection<eu.cloudnetservice.driver.network.NetworkChannel> channels()Get all channels which are connected to the underlying network component.protected voiddoHandlePacket(@NonNull eu.cloudnetservice.driver.network.protocol.BasePacket packet) Handles the incoming packet and posts it either to the associated waiting query handler or directly into the packet registry, calling all associated handlers.private voidhandlePacket(@NonNull eu.cloudnetservice.driver.network.protocol.BasePacket packet) Handles the incoming packet and posts it either to the associated waiting query handler or directly into the packet registry, calling all associated handlers.protected voidmessageReceived(@NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull eu.cloudnetservice.driver.network.protocol.BasePacket msg) Get the packet dispatcher used to dispatch incoming packets.Methods inherited from class io.netty5.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelInboundEvent, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, handlerRemoved, isSharable, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown, write
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
channel
-
-
Constructor Details
-
NettyNetworkHandler
public NettyNetworkHandler()
-
-
Method Details
-
channelInactive
-
channelExceptionCaught
-
channelReadComplete
-
messageReceived
protected void messageReceived(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull @NonNull eu.cloudnetservice.driver.network.protocol.BasePacket msg) - Specified by:
messageReceivedin classio.netty5.channel.SimpleChannelInboundHandler<eu.cloudnetservice.driver.network.protocol.BasePacket>
-
handlePacket
private void handlePacket(@NonNull @NonNull eu.cloudnetservice.driver.network.protocol.BasePacket packet) Handles the incoming packet and posts it either to the associated waiting query handler or directly into the packet registry, calling all associated handlers. This method applies exception handling which is not done bydoHandlePacket(BasePacket).- Parameters:
packet- the packet hto handle.- Throws:
NullPointerException- if the given packet is null.
-
doHandlePacket
protected void doHandlePacket(@NonNull @NonNull eu.cloudnetservice.driver.network.protocol.BasePacket packet) throws Exception Handles the incoming packet and posts it either to the associated waiting query handler or directly into the packet registry, calling all associated handlers.- Parameters:
packet- the packet to handle.- Throws:
NullPointerException- if the given packet is null.Exception- if an exception occurs while handling the given packet.
-
channels
@NonNull protected abstract @NonNull Collection<eu.cloudnetservice.driver.network.NetworkChannel> channels()Get all channels which are connected to the underlying network component.- Returns:
- all connected channels.
-
packetDispatcher
-