public byte[] ToBytes() { byte[] ret = new byte[header.MsgLength]; byte[] b1 = EagleProtocal.StructToBytes(header); byte[] b2 = EagleProtocal.StructToBytes(ipcount); b1.CopyTo(ret, 0); b2.CopyTo(ret, b1.Length); int start_0 = b1.Length + b2.Length; for (int i = 0; i < ipcount; ++i) { int start = i * 20 + start_0; string ip = iplist[i]; byte[] b = System.Text.Encoding.Default.GetBytes(ip.ToCharArray()); for (int j = 0; j < 20; j++) { if (j < b.Length) { ret[start + j] = b[j]; } else { ret[start + j] = 0; } } } return(ret); }
public void FromBytes(byte[] b) { this = (PACKET_IP_REGISTER_RESULT)EagleProtocal.BytesToStuct(b, this.GetType()); if (header.MsgType != (ushort)MESSAGE_TYPE.SC_IP_REGISTER) { throw new Exception(EagleProtocal.s_MsgNotFit + header.MsgType.ToString()); } }
public void FromBytes(byte[] b) { byte[] b1 = new byte[12]; for (int i = 0; i < b1.Length; ++i) { b1[i] = b[i]; } header = (Header)EagleProtocal.BytesToStuct(b1, header.GetType()); if (header.MsgType != (ushort)MESSAGE_TYPE.SC_PROMOPT_FINISH_APPLY) { throw new Exception(EagleProtocal.s_MsgNotFit + header.MsgType.ToString()); } content = System.Text.Encoding.Default.GetString(b, b1.Length, b.Length - b1.Length); }
public byte[] ToBytes() { byte[] ret = new byte[header.MsgLength]; byte[] b1 = EagleProtocal.StructToBytes(header); byte[] b2 = EagleProtocal.StructToBytes(count); b1.CopyTo(ret, 0); b2.CopyTo(ret, b1.Length); for (int i = 0; i < passport.Length; ++i) { string pspt = passport[i]; byte[] t = System.Text.Encoding.Default.GetBytes(pspt); t.CopyTo(ret, b1.Length + b2.Length + i * 32); } return(ret); }
public void FromBytes(byte[] b) { byte[] b1 = new byte[12]; for (int i = 0; i < b1.Length; ++i) { b1[i] = b[i]; } header = (Header)EagleProtocal.BytesToStuct(b1, header.GetType()); if (header.MsgType != (ushort)MESSAGE_TYPE.SC_COMMAND_BACKGROUND) { throw new Exception(EagleProtocal.s_MsgNotFit + header.MsgType.ToString()); } packet_eterm = new byte[b.Length - b1.Length]; for (int i = 0; i < packet_eterm.Length; ++i) { packet_eterm[i] = b[i + b1.Length]; } }
public byte[] ToBytes() { byte[] ret = new byte[header.MsgLength]; byte[] b1 = EagleProtocal.StructToBytes(header); byte[] b2 = EagleProtocal.StructToBytes(commandtype); byte[] b3 = EagleProtocal.StructToBytes(commandcount); byte[] b4 = System.Text.Encoding.Default.GetBytes(commands); int start = 0; b1.CopyTo(ret, start); start += b1.Length; b2.CopyTo(ret, start); start += b2.Length; b3.CopyTo(ret, start); start += b3.Length; b4.CopyTo(ret, start); return(ret); }
public void FromBytes(byte[] b) { this = (PACKET_LONELY_USE)EagleProtocal.BytesToStuct(b, this.GetType()); }
public byte[] ToBytes() { return(EagleProtocal.StructToBytes(this)); }
public void FromBytes(byte[] b) { header = (Header)EagleProtocal.BytesToStuct(b, header.GetType()); }
public byte[] ToBytes() { return(EagleProtocal.StructToBytes(header)); }
public UInt32 Extend; //扩展,保留,4字节 public void FromBytes(byte[] b) { this = (Header)EagleProtocal.BytesToStuct(b, this.GetType()); }