Package crow.game.codec.netty
Class FrameCodec
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.ByteToMessageCodec<Packet>
crow.game.codec.netty.FrameCodec
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
The FrameCodec converts to and from
ByteBuf streams into individual Packet objects. The first two bytes of a packet determine which type of packet
it is (called the packet ID). Packets which are sized dynamically will have their lengths read
and written here as well, so individual PacketHandler implementations do not need to
worry about length.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidvoidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) protected booleanpacketRuleHasMoreData(io.netty.buffer.ByteBuf in, PacketRule pr) protected Optional<PacketRule>resolvePacketRule(Context ctx, int prefix, io.netty.buffer.ByteBuf in) Methods inherited from class io.netty.handler.codec.ByteToMessageCodec
acceptOutboundMessage, channelInactive, channelRead, channelReadComplete, decodeLast, handlerAdded, handlerRemoved, writeMethods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Field Details
-
context
-
-
Constructor Details
-
FrameCodec
-
-
Method Details
-
packetRuleHasMoreData
-
resolvePacketRule
protected Optional<PacketRule> resolvePacketRule(Context ctx, int prefix, io.netty.buffer.ByteBuf in) -
encode
protected void encode(io.netty.channel.ChannelHandlerContext ctx, Packet msg, io.netty.buffer.ByteBuf out) - Specified by:
encodein classio.netty.handler.codec.ByteToMessageCodec<Packet>
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out) - Specified by:
decodein classio.netty.handler.codec.ByteToMessageCodec<Packet>
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-