liusuyi
2024-10-25 75902fb9d5b27a440d14308ccca3c3cff32167bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.ard.tianyu.netty.command;
 
import io.netty.buffer.ByteBuf;
 
/**
 * 心跳命令
 *
 * @author 刘苏义
 * @date 2024/10/22 16:36
 */
public class HeartbeatCommand extends BaseCommand {
 
    private final long timestamp;
 
    public HeartbeatCommand(long timestamp) {
        setDataHeader((short)0x7479);
        setDataLength((short)0x09);
        setCmdCode((byte)0x02);
        this.timestamp = timestamp;
    }
    public void encode(ByteBuf out) {
        out.writeLong(timestamp); // 写入时间戳
    }
}