//添加管道 private void bt_addPile_Click(object sender, EventArgs e) { int reConnectTime = 0; int pileAddCount = 0; if (int.TryParse(tb_reConTime.Text, out reConnectTime) && int.TryParse(tb_addTime.Text, out pileAddCount)) { if (reConnectTime < 0) { reConnectTime = 0; tb_reConTime.Text = "0"; ReportMyMessage("ReConTime can not less than 0 ,so we set it 0"); } if (pileAddCount < 1) { pileAddCount = 1; tb_addTime.Text = "1"; ReportMyMessage("PileAddCount can not less than 1 ,so we set it 1"); } for (int i = 0; i < pileAddCount; i++) { PipeHttp tempPipeHttp = new PipeHttp(reConnectTime, cb_responseType.SelectedIndex == 0); tempPipeHttp.OnPipeInfoReport += ph_OnPipeInfoReport; tempPipeHttp.OnPipeResponseReport += ph_OnPipeResponseReport; tempPipeHttp.OnPipeStateReport += ph_OnPipeStateReport; tempPipeHttp.pipeRequest = PipeHttp.GlobalRawRequest; AddPipeList(tempPipeHttp); } } else { MessageBox.Show("illegal reConTime or addTime text"); } }
private void reconnectAllToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem tempItem in lv_pipeList.Items) { PipeHttp tempPh = (PipeHttp)tempItem.Tag; tempPh.ReConnect(); } }
private void AddPipeList(PipeHttp ph) { pipeList.Add(ph); ListViewItem lvt = new ListViewItem(new string[] { ph.Id.ToString(), ph.GetreReconectCount.ToString() }); lvt.Tag = ph; lv_pipeList.Items.Add(lvt); }
private void reconnectThisToolStripMenuItem_Click(object sender, EventArgs e) { if (lv_pipeList.SelectedItems != null) { foreach (ListViewItem tempItem in lv_pipeList.SelectedItems) { PipeHttp tempPh = (PipeHttp)tempItem.Tag; tempPh.ReConnect(); } } }
private void removeAllToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem tempItem in lv_pipeList.Items) { PipeHttp tempPh = (PipeHttp)tempItem.Tag; tempPh.OnPipeInfoReport -= ph_OnPipeInfoReport; tempPh.OnPipeResponseReport -= ph_OnPipeResponseReport; tempPh.OnPipeStateReport -= ph_OnPipeStateReport; tempPh.Dispose(); pipeList.Remove(tempPh); lv_pipeList.Items.Remove(tempItem); } }
private void bt_connectAllPile_Click(object sender, EventArgs e) { foreach (ListViewItem tempLvt in lv_pipeList.Items) { PipeHttp tempPh = (PipeHttp)tempLvt.Tag; //tempPh.IsReportResponse = cb_isRecieve.Checked; if (tempPh.Connect()) { //tempLvt.BackColor = Color.LightGreen; //lv_pipeList.Update(); } else { ReportMyMessage(string.Format("ID:[{0}] connect fail", tempPh.Id.ToString())); } } }
private void PipeHttpRuner_Load(object sender, EventArgs e) { pipeList = new List <PipeHttp>(); return; PipeHttp.GlobalRawRequest.ConnectHost = "www.baidu.com"; PipeHttp.GlobalRawRequest.StartLine = "GET http://www.baidu.com/ HTTP/1.1"; PipeHttp.GlobalRawRequest.Headers.Add("Content-Type: application/x-www-form-urlencoded"); PipeHttp.GlobalRawRequest.Headers.Add(string.Format("Host: {0}", PipeHttp.GlobalRawRequest.ConnectHost)); PipeHttp.GlobalRawRequest.Headers.Add("Connection: Keep-Alive"); PipeHttp.GlobalRawRequest.CreateRawData(); PipeHttp ph = new PipeHttp(100, true); ph.pipeRequest = PipeHttp.GlobalRawRequest; ph.OnPipeResponseReport += ph_OnPipeResponseReport; ph.OnPipeInfoReport += ph_OnPipeInfoReport; ph.Connect(); ph.Send(100); }