liusuyi
2024-10-26 f2236478e434b9d1b714b51d3586fb11a59e6f14
ard-work/src/main/java/com/ard/tianyu/netty/handler/MessageProtocolEncoder.java
@@ -1,17 +1,15 @@
package com.ard.tianyu.netty.handler;// MessageProtocolEncoder.java
import com.ard.tianyu.netty.command.BaseCommand;
import com.ard.tianyu.netty.command.BaseCmd;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import lombok.extern.slf4j.Slf4j;
import java.util.Arrays;
@Slf4j
public class MessageProtocolEncoder extends MessageToByteEncoder<BaseCommand> {
public class MessageProtocolEncoder extends MessageToByteEncoder<BaseCmd> {
    @Override
    protected void encode(ChannelHandlerContext ctx, BaseCommand command, ByteBuf out) throws Exception {
    protected void encode(ChannelHandlerContext ctx, BaseCmd command, ByteBuf out) throws Exception {
        command.encode(out); // 编码具体负载
        // 打印