| | |
| | | private long timestamp; // 时间戳 |
| | | |
| | | public HeartbeatReplyCommand(long timestamp) { |
| | | this.timestamp = timestamp; |
| | | setDataHeader((short) 0x6A77); // 设置帧头 |
| | | setCmdCode((byte) 0x02); // 设置指令编号 |
| | | setDataLength((short) (13)); // 数据长度 (指令编号 + 时间戳) |
| | | this.timestamp = timestamp; |
| | | } |
| | | |
| | | public void encode(ByteBuf out) { |
| | | out.writeShort(getDataHeader()); |
| | | out.writeShort(getDataLength()); |
| | | out.writeByte(getCmdCode()); |
| | | out.writeShort(getDataHeader()); // 写入数据头 |
| | | out.writeShort(getDataLength()); // 写入数据长度 |
| | | out.writeByte(getCmdCode()); // 写入命令码 |
| | | out.writeLong(timestamp); // 写入时间戳 |
| | | } |
| | | } |