[csmaild-cvs] csmaild/src/TestClient ClientHelper.cs,1.1,1.2 Main.cs,1.3,1.4 Main.resx,1.3,1.4
Brought to you by:
tamc
From: <ta...@us...> - 2003-07-26 23:09:28
|
Update of /cvsroot/csmaild/csmaild/src/TestClient In directory sc8-pr-cvs1:/tmp/cvs-serv31922/src/TestClient Modified Files: ClientHelper.cs Main.cs Main.resx Log Message: Modified network model to be asynchronous for idle times and synchronous during the processing of the command. This cleans up the code a bit, while still keeping some of the theoretical benefits of doing it asynchronously. Reworked some of the argument parsing Started work on the FETCH command The test client got some work to, nothing significant yet. Index: ClientHelper.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/TestClient/ClientHelper.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClientHelper.cs 24 Jul 2003 04:32:14 -0000 1.1 --- ClientHelper.cs 26 Jul 2003 23:09:25 -0000 1.2 *************** *** 59,62 **** --- 59,64 ---- System.Threading.Thread.Sleep(10); } + if(retval == string.Empty) + return retval; return retval.Substring(0, retval.Length-2); } Index: Main.cs =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/TestClient/Main.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Main.cs 25 Jul 2003 19:30:28 -0000 1.3 --- Main.cs 26 Jul 2003 23:09:25 -0000 1.4 *************** *** 20,24 **** private System.Windows.Forms.Button cmdChegg; private System.Windows.Forms.ListBox lstCommunicationLog; - private System.Windows.Forms.ListBox lstCommandsToProcess; private System.Windows.Forms.TextBox txtAddCommands; private System.Windows.Forms.Button cmdAdd; --- 20,23 ---- *************** *** 28,31 **** --- 27,31 ---- private System.Windows.Forms.NumericUpDown numPause; private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckedListBox lstCommandsToProcess; /// <summary> /// Required designer variable. *************** *** 72,76 **** this.cmdChegg = new System.Windows.Forms.Button(); this.lstCommunicationLog = new System.Windows.Forms.ListBox(); - this.lstCommandsToProcess = new System.Windows.Forms.ListBox(); this.txtAddCommands = new System.Windows.Forms.TextBox(); this.cmdAdd = new System.Windows.Forms.Button(); --- 72,75 ---- *************** *** 80,83 **** --- 79,83 ---- this.numPause = new System.Windows.Forms.NumericUpDown(); this.label1 = new System.Windows.Forms.Label(); + this.lstCommandsToProcess = new System.Windows.Forms.CheckedListBox(); ((System.ComponentModel.ISupportInitialize)(this.numPause)).BeginInit(); this.SuspendLayout(); *************** *** 111,127 **** this.lstCommunicationLog.Location = new System.Drawing.Point(8, 40); this.lstCommunicationLog.Name = "lstCommunicationLog"; ! this.lstCommunicationLog.Size = new System.Drawing.Size(696, 432); this.lstCommunicationLog.TabIndex = 3; // - // lstCommandsToProcess - // - this.lstCommandsToProcess.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.lstCommandsToProcess.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.lstCommandsToProcess.Location = new System.Drawing.Point(712, 40); - this.lstCommandsToProcess.Name = "lstCommandsToProcess"; - this.lstCommandsToProcess.Size = new System.Drawing.Size(208, 405); - this.lstCommandsToProcess.TabIndex = 4; - this.lstCommandsToProcess.SelectedIndexChanged += new System.EventHandler(this.lstCommandsToProcess_SelectedIndexChanged); - // // txtAddCommands // --- 111,117 ---- this.lstCommunicationLog.Location = new System.Drawing.Point(8, 40); this.lstCommunicationLog.Name = "lstCommunicationLog"; ! this.lstCommunicationLog.Size = new System.Drawing.Size(600, 432); this.lstCommunicationLog.TabIndex = 3; // // txtAddCommands // *************** *** 201,208 **** --- 191,210 ---- this.label1.Text = "Pause between commands (tenths of a second)"; // + // lstCommandsToProcess + // + this.lstCommandsToProcess.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.lstCommandsToProcess.CheckOnClick = true; + this.lstCommandsToProcess.Font = new System.Drawing.Font("Verdana", 8.25F); + this.lstCommandsToProcess.Location = new System.Drawing.Point(616, 40); + this.lstCommandsToProcess.Name = "lstCommandsToProcess"; + this.lstCommandsToProcess.Size = new System.Drawing.Size(304, 386); + this.lstCommandsToProcess.TabIndex = 12; + this.lstCommandsToProcess.SelectedIndexChanged += new System.EventHandler(this.lstCommandsToProcess_SelectedIndexChanged); + // // MainF // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(928, 485); + this.Controls.Add(this.lstCommandsToProcess); this.Controls.Add(this.label1); this.Controls.Add(this.numPause); *************** *** 212,216 **** this.Controls.Add(this.cmdAdd); this.Controls.Add(this.txtAddCommands); - this.Controls.Add(this.lstCommandsToProcess); this.Controls.Add(this.lstCommunicationLog); this.Controls.Add(this.cmdChegg); --- 214,217 ---- *************** *** 237,255 **** { string line = mHelper.ReceiveLine(); ! lstCommunicationLog.Items.Add(mCounter++.ToString().PadLeft(4, ' ') + " <- " + line); ! lstCommunicationLog.SelectedIndex = lstCommunicationLog.Items.Count-1; ! Application.DoEvents(); - return line; } private void SendReceiveCommand(string command) { string line = string.Empty; ! string tag = mCounter.ToString(); ! SendLine(tag + " " + command); ! while(!line.StartsWith(tag)) line = ReadLine(); } --- 238,274 ---- { string line = mHelper.ReceiveLine(); ! if(line != string.Empty) ! { ! lstCommunicationLog.Items.Add(mCounter++.ToString().PadLeft(4, ' ') + " <- " + line); ! lstCommunicationLog.SelectedIndex = lstCommunicationLog.Items.Count-1; ! } Application.DoEvents(); return line; } + private string mLastTag = string.Empty; + private bool mChangeLastTag = true; private void SendReceiveCommand(string command) { string line = string.Empty; ! ! if(command.IndexOf(' ') != -1 && mChangeLastTag) ! mLastTag = command.Substring(0, command.IndexOf(' ')); ! SendLine(command); ! while(true) ! { line = ReadLine(); + + if(line.StartsWith(mLastTag)) + { + mChangeLastTag = true; + break; + } + else if(line.StartsWith("+")) + { + mChangeLastTag = false; + break; + } + } } *************** *** 270,276 **** for(int idx = 0; idx < lstCommandsToProcess.Items.Count; ++idx) { ! lstCommandsToProcess.SelectedIndex = idx; ! SendReceiveCommand(lstCommandsToProcess.SelectedItem as string); ! System.Threading.Thread.Sleep((int)numPause.Value * 100); } --- 289,298 ---- for(int idx = 0; idx < lstCommandsToProcess.Items.Count; ++idx) { ! if(lstCommandsToProcess.CheckedIndices.IndexOf(idx) != -1) ! { ! lstCommandsToProcess.SelectedIndex = idx; ! SendReceiveCommand(lstCommandsToProcess.SelectedItem as string); ! System.Threading.Thread.Sleep((int)numPause.Value * 100); ! } } *************** *** 296,300 **** { foreach(DataRow r in ds.Tables[0].Rows) ! lstCommandsToProcess.Items.Add(r["Command"] as string); } catch{} --- 318,322 ---- { foreach(DataRow r in ds.Tables[0].Rows) ! lstCommandsToProcess.Items.Add(r["Command"] as string, ((r["Process"] as string) == "True" ? CheckState.Checked : CheckState.Unchecked)); } catch{} *************** *** 307,310 **** --- 329,333 ---- { mHelper = new ClientHelper("localhost", 143); + SaveCommands(); Go(); } *************** *** 313,316 **** --- 336,340 ---- { mHelper = new ClientHelper("chegg.com", 143); + SaveCommands(); Go(); } *************** *** 386,392 **** DataSet ds = new DataSet(); ds.Tables.Add("Commands").Columns.Add("Command"); ! foreach(object o in lstCommandsToProcess.Items) ! ds.Tables[0].Rows.Add(new object[]{o as String}); ds.WriteXml("..\\Commands.xml"); --- 410,417 ---- DataSet ds = new DataSet(); ds.Tables.Add("Commands").Columns.Add("Command"); + ds.Tables[0].Columns.Add("Process"); ! for(int idx = 0; idx < lstCommandsToProcess.Items.Count; ++idx) ! ds.Tables[0].Rows.Add(new object[]{lstCommandsToProcess.Items[idx] as String, (lstCommandsToProcess.CheckedIndices.IndexOf(idx) != -1 ? "True" : "False")}); ds.WriteXml("..\\Commands.xml"); Index: Main.resx =================================================================== RCS file: /cvsroot/csmaild/csmaild/src/TestClient/Main.resx,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Main.resx 25 Jul 2003 19:30:28 -0000 1.3 --- Main.resx 26 Jul 2003 23:09:25 -0000 1.4 *************** *** 125,137 **** <value>Private</value> </data> - <data name="lstCommandsToProcess.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="lstCommandsToProcess.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="lstCommandsToProcess.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> <data name="txtAddCommands.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> --- 125,128 ---- *************** *** 161,167 **** <value>Private</value> </data> - <data name="cmdMoveDown.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> <data name="cmdMoveDown.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> --- 152,155 ---- *************** *** 170,173 **** --- 158,164 ---- <value>Private</value> </data> + <data name="cmdMoveDown.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>Private</value> + </data> <data name="cmdDelete.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>False</value> *************** *** 195,198 **** --- 186,198 ---- </data> <data name="label1.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>Private</value> + </data> + <data name="lstCommandsToProcess.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>Private</value> + </data> + <data name="lstCommandsToProcess.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <value>False</value> + </data> + <data name="lstCommandsToProcess.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <value>Private</value> </data> |