Package net.mcbrawls.inject.api
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg) booleanisRelevant(InjectorContext ctx, PacketDirection direction) Predicate for matching if this injector is relevant to the given context.booleanonRead(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buf) Gets executed on every channel read.booleanonWrite(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buf, io.netty.channel.ChannelPromise promise) Gets executed on every channel write.voidwrite(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, readMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, 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
-
Constructor Details
-
Injector
public Injector()
-
-
Method Details
-
isRelevant
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
- Specified by:
channelReadin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadin classio.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:
writein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
writein classio.netty.channel.ChannelDuplexHandler- Throws:
Exception
-