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

    Fields
    Modifier and Type
    Field
    Description
    A listener logger for processing incoming messages.
    private String
    Username.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MainHandler(Controller controller)
    When created, it receives a link to the application controller.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
    Reads received message objects.
    void
    exceptionCaught(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, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Field Details

    • userName

      private String userName
      Username.
    • registryHandler

      private RegistryHandler registryHandler
      A listener logger for processing incoming messages.
      See Also:
  • Constructor Details

    • MainHandler

      public MainHandler(Controller controller)
      When created, it receives a link to the application controller.
      Parameters:
      controller - Application controller.
  • Method Details

    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
      Reads received message objects. Depending on the incoming class messages are taken from HandlerRegistry processing method and stores it in the function interface variable RequestHandler. Calls this method for execution by passing parameters to it:
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - channel context.
      msg - the message object.
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
      Called when errors occur, closes the channel context.
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelHandler
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - channel context.
      cause - a variable with an exception.