Package com.cloud.clientpak
Class MainHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
com.cloud.clientpak.MainHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class MainHandler
extends io.netty.channel.ChannelInboundHandlerAdapter
The main listener of the Netty pipeline, extends
ChannelInboundHandlerAdapter,
the method of reading channelRead channelRead is essentially
the main point connecting the Netty kernel and the program with all its actions that will be taken to process received message.-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate RegistryHandlerA listener logger for processing incoming messages.private StringUsername. -
Constructor Summary
ConstructorsConstructorDescriptionMainHandler(Controller controller) When created, it receives a link to the application controller. -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) Reads received message objects.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) Called when errors occur, closes the channel context.Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, 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
-
userName
Username. -
registryHandler
A listener logger for processing incoming messages.- See Also:
-
-
Constructor Details
-
MainHandler
When created, it receives a link to the application controller.- Parameters:
controller- Application controller.
-
-
Method Details
-
channelRead
Reads received message objects. Depending on the incoming class messages are taken fromHandlerRegistryprocessing method and stores it in the function interface variableRequestHandler. Calls this method for execution by passing parameters to it:- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- channel context.msg- the message object.
-
exceptionCaught
Called when errors occur, closes the channel context.- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- channel context.cause- a variable with an exception.
-