Class NettyNetworkHandler
java.lang.Object
io.netty5.channel.SimpleChannelInboundHandler<BasePacket>
eu.cloudnetservice.driver.network.netty.NettyNetworkHandler
- All Implemented Interfaces:
io.netty5.channel.ChannelHandler
- Direct Known Subclasses:
NettyNetworkClientHandler,NettyNetworkServerHandler
@Internal
public abstract class NettyNetworkHandler
extends io.netty5.channel.SimpleChannelInboundHandler<BasePacket>
The default netty inbound handler used to call downstream packet listeners when receiving a packet.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NettyNetworkChannelprotected final EventManagerprivate static final eu.cloudnetservice.common.log.Logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNettyNetworkHandler(@NonNull EventManager eventManager) Constructs a new netty network handler instance. -
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<NetworkChannel>channels()Get all channels which are connected to the underlying network component.protected voiddoHandlePacket(@NonNull 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 BasePacket msg) Get the packet dispatcher used to dispatch incoming packets.Methods inherited from class io.netty5.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class java.lang.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 eu.cloudnetservice.common.log.Logger LOGGER -
eventManager
-
channel
-
-
Constructor Details
-
NettyNetworkHandler
Constructs a new netty network handler instance.- Parameters:
eventManager- the event manager of the current component.- Throws:
NullPointerException- if the given event manager is null.
-
-
Method Details
-
channelInactive
public void channelInactive(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx) throws Exception - Throws:
Exception
-
channelExceptionCaught
-
channelReadComplete
-
messageReceived
protected void messageReceived(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull @NonNull BasePacket msg) - Specified by:
messageReceivedin classio.netty5.channel.SimpleChannelInboundHandler<BasePacket>
-
doHandlePacket
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.
-
channels
Get all channels which are connected to the underlying network component.- Returns:
- all connected channels.
-
packetDispatcher
Get the packet dispatcher used to dispatch incoming packets. Each dispatcher is normally bound to the network component which opened/received the connection and requested this handler.- Returns:
- the dispatcher used to dispatch packets.
-