Esempio n. 1
0
        // ============================================
        // PRIVATE (Methods) Event Handlers
        // ============================================
        private void OnReceived(object sender, PeerEventArgs args)
        {
            PeerSocket peer = sender as PeerSocket;

            // Get Response String and Check if is Valid Xml
            string xml = peer.GetResponseString();

            if (xml == null)
            {
                return;
            }

            // Remove Response Message
            peer.ResetResponse();

            // Get Xml Commands
            xml = xml.Trim();
            ArrayList xmlCmds = new ArrayList();

            lock (peer.Response) {
                int splitPos = 0;
                while ((splitPos = xml.IndexOf("><")) >= 0)
                {
                    // Add Xml Command To Cmds
                    string cmd = xml.Substring(0, splitPos + 1);
                    xmlCmds.Add(cmd);

                    // Remove Splitted Part
                    xml = xml.Remove(0, splitPos + 1);
                }

                if (XmlRequest.IsEndedXml(xml) == false)
                {
                    peer.Response.Insert(0, xml);
                }
                else
                {
                    xmlCmds.Add(xml);
                }
            }

            // Start New Command Parse Thread
            new CmdParse(peer, xmlCmds);
        }