* @throws Exception
*/
public byte[] toBytes(boolean rights, byte [] desKey) throws Exception{
int startIndex = 0;
SerializeBase serialize = SerializeBase.getInstance(this.getSerializeType());
CompressBase compress = CompressBase.getInstance(this.getCompressType());
this.sdpType = SDPType.getSDPType(this.sdpEntity);
byte[] sdpData = serialize.serialize(this.sdpEntity);
//数据加密
if(this.getSDPType().getNum() != 5 && rights && desKey != null){
sdpData = DESCoderHelper.getInstance().encrypt(sdpData, desKey);//DES加密数据
}
sdpData = compress.zip(sdpData);
int protocolLen = HEAD_STACK_LENGTH + sdpData.length;
this.setTotalLen(protocolLen);
byte[] data = new byte[protocolLen];
data[0] = Protocol.VERSION;