コード例 #1
0
        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);
        }
コード例 #2
0
 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());
     }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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];
     }
 }
コード例 #6
0
        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);
        }
コード例 #7
0
 public void FromBytes(byte[] b)
 {
     this = (PACKET_LONELY_USE)EagleProtocal.BytesToStuct(b, this.GetType());
 }
コード例 #8
0
 public byte[] ToBytes()
 {
     return(EagleProtocal.StructToBytes(this));
 }
コード例 #9
0
 public void FromBytes(byte[] b)
 {
     header = (Header)EagleProtocal.BytesToStuct(b, header.GetType());
 }
コード例 #10
0
 public byte[] ToBytes()
 {
     return(EagleProtocal.StructToBytes(header));
 }
コード例 #11
0
 public UInt32 Extend;    //扩展,保留,4字节
 public void FromBytes(byte[] b)
 {
     this = (Header)EagleProtocal.BytesToStuct(b, this.GetType());
 }