Example #1
0
        private void XmlRespond(byte[] buffer, int len)
        {
            if (this.cbbDeviceID.InvokeRequired)
            {
                byte[] copy = new byte[len];
                Array.Copy(buffer, copy, len);
                this.Invoke(UDPServices.GetInstance().xmlRespond_, new object[] { copy, len });
                return;
            }

            int index   = 0;
            int version = ISocket.GetInt(buffer, ref index);

            UDPServices.HCmdType cmd = (UDPServices.HCmdType)ISocket.GetShort(buffer, ref index);
            string id = ISocket.GetString(buffer, ref index, UDPServices.MAX_DEVICE_ID_LENGHT);

            if (id.IndexOf('\0') >= 0)
            {
                id = id.Remove(id.IndexOf('\0'));
            }

            if (id != this.cbbDeviceID.Text)
            {
                return;
            }

            string xml = ISocket.GetString(buffer, ref index, len - 6 - UDPServices.MAX_DEVICE_ID_LENGHT);

            this.ParseXml(xml);
        }