Пример #1
0
        public information FromJson_leave(string json)
        {
            information jsonO = null;

            try
            {
                jsonO = (information)JsonConvert.DeserializeObject(json, typeof(information));
            }
            catch (Exception e)
            {
            }
            return(jsonO);
        }
Пример #2
0
        public void Show_List()
        {
            List <information> List_User = new List <information>();
            information        l_LAVE    = new information();

            //MessageBox.Show("lol"+hx.Receive_List());
            while (true)
            {
                try
                {
                    string[] tokens = hx.Receive_List().Split(new Char[] { '|' });
                    //MessageBox.Show("lol"+hx.Receive_List());
                    List_User = (List <information>)FromJson(tokens[1]);

                    // if (List_User != null)
                    //           {
                    if (tokens[0] == "Client")
                    {
                        foreach (information p in List_User)
                        {
                            New_User_information(p.name, p.ip);

                            thread = new Thread(new ParameterizedThreadStart(setItems));
                            thread.Start();
                        }
                        // List_User.Clear();
                    }
                    else if (tokens[0] == "Quit")
                    {
                        //
                        // MessageBox.Show(tokens[1]);
                        l_LAVE = (information)FromJson_leave(tokens[1]);

                        //MessageBox.Show("用户退出" + l_LAVE.name + "   " + l_LAVE.ip);

                        //.  List_User.Clear();
                        foreach (ListViewItem item in listView1.Items)           //索引删除
                        {
                            if (item.SubItems[1].Text == l_LAVE.name)
                            {
                                listView1.Items.Remove(item);
                            }
                        }
                    }
                }catch (Exception a) {
                }
            }
        }