Package com.cloud.serverpak
Class MainHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
com.cloud.serverpak.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 AuthServiceAuthorization serviceAuthService.private static List<io.netty.channel.Channel>private ExecutorServiceprivate FilesInformServiceprivate RegistryHandlerA listener logger for processing incoming messages.private String -
Constructor Summary
ConstructorsConstructorDescriptionMainHandler(AuthService authService) Receives a link to the authorization service when creating it. -
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.static List<io.netty.channel.Channel>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
-
authService
Authorization serviceAuthService. -
channels
-
userName
-
executorService
-
filesInformService
-
handlerRegistry
A listener logger for processing incoming messages.- See Also:
-
-
Constructor Details
-
MainHandler
Receives a link to the authorization service when creating it. Launches thread pool, file management service, and message listener logger.- Parameters:
authService- Authorization service.- See Also:
-
-
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.
-
getChannels
-
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.
-