package com.zy.core.netty.domain;
|
|
import io.netty.buffer.ByteBuf;
|
import lombok.Data;
|
|
/**
|
* 报文模型
|
* Created by vincent on 2019-04-03
|
*/
|
@Data
|
public class ChPackage {
|
|
/**
|
* 唯一编码
|
*/
|
private String uuid;
|
|
/**
|
* 源数据包缓冲区(引用)
|
*/
|
private ByteBuf sourceBuff;
|
|
/**
|
* 原始消息对应的16进制字符串
|
*/
|
private String sourceHexStr;
|
|
/**
|
* 请求体
|
*/
|
private ByteBuf content;
|
|
private byte[] bytes;
|
|
private String ascii;
|
|
private String ip;
|
|
/**
|
* 消息的校正码
|
*/
|
private byte validCode;
|
|
/**
|
* 是否为校验异常包
|
*/
|
private boolean errorPac;
|
|
public static ChPackage valueOfEmpty(String uuid, String ip) {
|
ChPackage chPackage = new ChPackage();
|
chPackage.setUuid(uuid);
|
chPackage.setIp(ip);
|
return chPackage;
|
}
|
|
// public ByteBuf convert(ByteBuf byteBuf){
|
// byteBuf.writeBytes(this.getHeader().getStartSymbol().getBytes(Constant.CHARSET_GBK))
|
// .writeByte(this.getHeader().getCommandMark().getCode())
|
// .writeByte(this.getHeader().getAckMark().getCode())
|
// .writeBytes(this.getHeader().getUniqueNo().getBytes())
|
// .writeByte(this.getHeader().getEncryptType().getCode())
|
// .writeShort(this.getHeader().getContentLength())
|
// .writeBytes(this.getBody().getContent())
|
// .writeByte(this.getValidCode());
|
// // 计算并设置校验码
|
// this.setValidCode(ValidUtil.caculateValidByteFromBuff(byteBuf));
|
// byteBuf.resetReaderIndex();
|
// byteBuf.writerIndex(byteBuf.readableBytes() - 1).writeByte(this.getValidCode());
|
// return byteBuf;
|
// }
|
|
}
|