package com.dd.model.protocol;
public class CmdLoginDecoder
{
Field version = new Field(new TTL((short)1, DataTypeEnum.INT16), new Value<>((short)1));
Field cmd = new Field(new TTL((short)2, DataTypeEnum.INT32), new Value<>(1));
Field handle = new Field(new TTL((short)3, DataTypeEnum.FLOAT), new Value<>(-1f));
Field userName = new Field(new TTL((short)4, DataTypeEnum.STRING), new Value<>("fang"));
Field password = new Field(new TTL((short)5, DataTypeEnum.STRING), new Value<>("fang"));
CmdLogin cmdLogin = new CmdLogin( version, cmd, handle, userName, password);
String serialData;
byte serialByte[];
public CmdLoginDecoder(String serialString)
{
this.serialData = serialString;
serialByte = serialData.getBytes();
getCmdLogin();
}
public CmdLoginDecoder(byte serialByte[])
{
this.serialByte = serialByte;
serialData = new String(serialByte);
}
public CmdLogin getCmdLogin()
{
int offset = 0;
int len = 0;
CmdLogin cmdLogin = null;
if(serialData == null) return null;
if(serialByte == null) return null;
String pureString = serialData.replace(" ", "");
FieldDecoder versionFieldDecoder = new FieldDecoder(SerialDataDecoder.toByteArray(pureString.substring(0, 6*2)));
Field version = versionFieldDecoder.doDecoder();
offset += version.getTotalLen();
TTLDecoder ttlDecoder = new TTLDecoder(SerialDataDecoder.toByteArray(serialData.substring(0,6)));
System.out.println(pureString);
return cmdLogin;
}
}
阅读(859) | 评论(0) | 转发(0) |