liusuyi
2024-11-01 1cdcfa88ebbbc37fbaa03d2ab3abc6d98f727050
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.ard.tianyu.netty.command.register;// RegisterMessage.java
 
import com.ard.tianyu.netty.command.BaseCmd;
import io.netty.buffer.ByteBuf;
import lombok.Data;
 
/**
 * 注册命令
 *
 * @author 刘苏义
 * @date 2024/10/22 16:36
 */
@Data
public class RegisterReplyCmd extends BaseCmd {
    private byte success;
 
    public RegisterReplyCmd(byte success) {
        setDataHeader((short) 0x6A77); // 设置帧头
        setDataLength((short) (6)); // 数据长度
        setCmdCode((byte) 0x01); // 设置命令编号
        this.success = success;
    }
 
    @Override
    public void encode(ByteBuf out) {
        out.writeShort(getDataHeader());    // 写入数据头
        out.writeShort(getDataLength());    // 写入数据长度
        out.writeByte(getCmdCode());        // 写入命令码
        out.writeByte(success);             // 写入用户编号
    }
}