コード例 #1
0
        private void handleCommand(string data)
        {
            Console.WriteLine(data);
            if (data.Contains("#setname"))
            {
                _userName = data.Split('&')[1];
                UpdateChat();
                return;
            }
            if (data.Contains("#newmsg"))
            {
                string message = data.Split('&')[1];
                ChatController.AddMessage(_userName, message + "|");
                history.Load("history.xml");
                XmlNode msg = history.CreateElement("msg");
                history.DocumentElement.AppendChild(msg);

                XmlAttribute attribute = history.CreateAttribute("id");
                attribute.Value = DateTime.Now.ToString();

                XmlNode name = history.CreateElement("name");
                XmlNode info = history.CreateElement("info");
                name.InnerText = _userName;

                msg.AppendChild(name);
                info.InnerText = message;
                msg.AppendChild(info);

                history.Save("history.xml");
                return;
            }

            if (data.Contains("#gethistory"))
            {
                UpdateChat();
                return;
            }
        }
コード例 #2
0
 public void UpdateChat()
 {
     Send(ChatController.GetChat());
 }