Class Injector

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
net.mcbrawls.inject.api.Injector
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

@Sharable public abstract class Injector extends io.netty.channel.ChannelDuplexHandler
A Netty injector.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
     
    boolean
    Predicate for matching if this injector is relevant to the given context.
    boolean
    onRead(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buf)
    Gets executed on every channel read.
    boolean
    onWrite(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buf, io.netty.channel.ChannelPromise promise)
    Gets executed on every channel write.
    void
    write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
     

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, 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
  • Constructor Details

    • Injector

      public Injector()
  • Method Details

    • isRelevant

      public boolean isRelevant(InjectorContext ctx, PacketDirection direction)
      Predicate for matching if this injector is relevant to the given context.
      Parameters:
      ctx - the context.
      direction - the direction in which this packet goes.
      Returns:
      true if it is relevant and should be handled by this injector, false if not.
    • onRead

      public boolean onRead(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buf) throws Exception
      Gets executed on every channel read.
      Parameters:
      ctx - The context.
      buf - The read byte buffer.
      Returns:
      true if the channel read was handled and should not get delegated to the superclass, false if it should be delegated to the superclass.
      Throws:
      Exception
    • onWrite

      public boolean onWrite(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buf, io.netty.channel.ChannelPromise promise)
      Gets executed on every channel write.
      Parameters:
      ctx - The context.
      buf - The written byte buffer.
      promise - The mutable channel future.
      Returns:
      true if the channel write was handled and should not get delegated to the superclass, false if it should be delegated to the superclass.
    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) throws Exception
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception
    • write

      public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception
      Specified by:
      write in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      write in class io.netty.channel.ChannelDuplexHandler
      Throws:
      Exception