package com.ard.tianyu.netty.command;// RegisterMessage.java
|
|
import io.netty.buffer.ByteBuf;
|
|
/**
|
* 注册命令
|
*
|
* @author 刘苏义
|
* @date 2024/10/22 16:36
|
*/
|
public class RegisterCommand extends BaseCommand {
|
private int userId;
|
private byte[] accessToken;
|
|
public RegisterCommand(int userId, byte[] accessToken) {
|
setDataHeader((short) 0x7479); // 设置帧头
|
setDataLength((short) (5 + accessToken.length)); // 数据长度
|
setCmdCode((byte) 0x01); // 设置命令编号
|
this.userId = userId;
|
this.accessToken = accessToken;
|
}
|
|
@Override
|
public void encode(ByteBuf out) {
|
out.writeInt(userId); // 写入用户编号
|
out.writeBytes(accessToken); // 写入访问令牌
|
}
|
}
|