예제 #1
0
        public static XMLPACKET ParseFromXml(string xml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            List <string> datas        = new List <string>();
            XmlElement    xml_packet   = doc.DocumentElement;
            string        user_name    = xml_packet.GetAttribute("USER_NAME");
            string        user_session = xml_packet.GetAttribute("USER_SESSION");
            string        game_key     = xml_packet.GetAttribute("GAME_KEY");
            PROTOCOL      protocol     = (PROTOCOL)int.Parse(xml_packet.GetAttribute("PROTOCOL"));
            int           data_count   = int.Parse(xml_packet.GetAttribute("DATA_COUNT"));

            foreach (XmlNode xml_data in xml_packet.SelectSingleNode("DATAS").ChildNodes)
            {
                datas.Add(xml_data.Attributes.Item(0).InnerText);
            }

            XMLPACKET v = new XMLPACKET();

            v.userName    = user_name;
            v.userSession = user_session;
            v.gameKey     = game_key;
            v.protocol    = protocol;
            v.dataCount   = data_count;
            v.datas       = datas;

            return(v);
        }
예제 #2
0
파일: CPacket.cs 프로젝트: puperBok/BTN_C
        public int DecodedPacketForXml()
        {
            if (buffer == null)
            {
                return(-1);
            }
            string xml = Encoding.Default.GetString(buffer);

            this.xmlPacket = CXmlManager.ParseFromXml(xml);

            return(buffer.Length);
        }