private void Time_Request_Tick(object sender, EventArgs e) { if (dataMessage != "0") { ProccessData(); } ThreadStart ts_1 = new ThreadStart(threadGetData); Thread thrd_1 = new Thread(ts_1); thrd_1.Start(); if (Time_Request.Interval != App_Status.time_delay) { Time_Request.Interval = App_Status.time_delay; Time_Request.Stop(); Time_Request.Start(); } }
public void ProccessData() { Time_Request.Stop(); /*List<Data_Message> list = JsonConvert.DeserializeObject<List<Data_Message>>(dataMessage); * MessageBox.Show(list.ToString());*/ //string kkdata = @"{""data"":[{""k_userID"":""518523721"",""name"":""ftyft""}, {""k_userID"":""527032438"",""name"":""ftyftyf""}, {""k_userID"":""527572047"",""name"":""ftgft""}, {""id"":""531141884"",""name"":""ftftft""}]}"; Conversation_Message dMess = new JavaScriptSerializer().Deserialize <Conversation_Message>(dataMessage); /*for(int i = 0; i < dMess.data.Count; i++) * { * dMess.data. * }*/ for (int i = dMess.data.Count - 1; i >= 0; i--) { byte[] bytes = Encoding.Default.GetBytes(dMess.data[i].Message.ToString()); dMess.data[i].Message = Encoding.UTF8.GetString(bytes); if (Convert.ToInt32(dMess.data[i].Message_id) > messIndex) { messIndex = Convert.ToInt32(dMess.data[i].Message_id); } if (dMess.data[i].User_id == User_Info.k_ID) { addInMessage(dMess.data[i].Message.ToString(), Convert.ToInt32(dMess.data[i].Message_type.ToString()), dMess.data[i].Image.ToString(), dMess.data[i].Sticker.ToString(), dMess.data[i].Time.ToString()); } else { addOutMessage(dMess.data[i].Message.ToString(), Convert.ToInt32(dMess.data[i].Message_type.ToString()), dMess.data[i].Image.ToString(), dMess.data[i].Sticker.ToString(), dMess.data[i].Time.ToString()); } } Time_Request.Start(); dataMessage = "0"; }
public chatbox() { Panel_Color_Bubble.NotifyChangeColor = new Notify(this.notifyChangeColor); if (!this.DesignMode) { InitializeComponent(); //panel2.Controls.RemoveAt(0); //panel2.Controls.RemoveAt(0); Time_Request.Interval = App_Status.time_delay; /*ThreadStart ts_1 = new ThreadStart(threadGetData); * Thread thrd_1 = new Thread(ts_1); * thrd_1.Start();*/ Time_Request.Start(); Time_Get_Message_Data.Start(); Queue_Sticker.data = new Queue <string>(); } bbl_old.Top = 0 - bbl_old.Height + 10; /*StreamReader read = new StreamReader("conversation_5.txt"); * string a1 = null; * a1 = read.ReadLine(); * * while(a1 != null) * { * dynamic data_mess = JsonConvert.DeserializeObject(a1); * string d_mess = data_mess.Message_Data; * string d_time = data_mess.Time_Data; * string d_urlPic = data_mess.urlPic; * if (d_urlPic != "") d_urlPic = urlKun + d_urlPic; * * * * string d_id = data_mess.ID; * if(d_id == id_user) { addInMessage(d_mess, d_time,d_urlPic); } * if (d_id == id_counterpart) { addOutMessage(d_mess, d_time,d_urlPic); } * * a1 = read.ReadLine(); * * } * read.Close();*/ }