From: <br...@us...> - 2008-05-31 14:05:42
|
Revision: 192 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=192&view=rev Author: brus07 Date: 2008-05-31 07:05:42 -0700 (Sat, 31 May 2008) Log Message: ----------- Added new architecture of mediator (Kernel, two list of plugins...) Added status bar with count of clients status Modified Paths: -------------- ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs ACMServer/trunk/MediatorSolution/Mediator/Form1.cs ACMServer/trunk/MediatorSolution/Mediator/Form1.resx ACMServer/trunk/MediatorSolution/Mediator/Mediator.csproj Added Paths: ----------- ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/CreaterMediatorPlugin.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/CreaterMediatorPlugin.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs 2008-05-31 14:02:51 UTC (rev 191) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs 2008-05-31 14:05:42 UTC (rev 192) @@ -28,6 +28,7 @@ /// </summary> private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.button1 = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); this.button2 = new System.Windows.Forms.Button(); @@ -37,6 +38,10 @@ this.button4 = new System.Windows.Forms.Button(); this.textBox3 = new System.Windows.Forms.TextBox(); this.textBox4 = new System.Windows.Forms.TextBox(); + this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); + this.timer1 = new System.Windows.Forms.Timer(this.components); + this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // // button1 @@ -109,7 +114,7 @@ this.textBox3.Location = new System.Drawing.Point(12, 276); this.textBox3.Multiline = true; this.textBox3.Name = "textBox3"; - this.textBox3.Size = new System.Drawing.Size(574, 182); + this.textBox3.Size = new System.Drawing.Size(574, 169); this.textBox3.TabIndex = 7; // // textBox4 @@ -121,11 +126,33 @@ this.textBox4.Text = "http://acm.lviv.ua/fusion/acm/getsubmit.php?passw=master&type=GetSubmitInfo&id=35" + "000"; // + // statusStrip1 + // + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabel1}); + this.statusStrip1.Location = new System.Drawing.Point(0, 448); + this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Size = new System.Drawing.Size(598, 22); + this.statusStrip1.TabIndex = 9; + this.statusStrip1.Text = "statusStrip1"; + // + // toolStripStatusLabel1 + // + this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; + this.toolStripStatusLabel1.Size = new System.Drawing.Size(109, 17); + this.toolStripStatusLabel1.Text = "toolStripStatusLabel1"; + // + // timer1 + // + this.timer1.Enabled = true; + this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(598, 470); + this.Controls.Add(this.statusStrip1); this.Controls.Add(this.textBox4); this.Controls.Add(this.textBox3); this.Controls.Add(this.button4); @@ -138,6 +165,8 @@ this.Name = "Form1"; this.Text = "Gate"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); + this.statusStrip1.ResumeLayout(false); + this.statusStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -154,6 +183,9 @@ private System.Windows.Forms.Button button4; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.TextBox textBox4; + private System.Windows.Forms.StatusStrip statusStrip1; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; + private System.Windows.Forms.Timer timer1; } } Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.cs 2008-05-31 14:02:51 UTC (rev 191) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.cs 2008-05-31 14:05:42 UTC (rev 192) @@ -7,39 +7,43 @@ using System.Windows.Forms; using AcmContester.Library.Connector; using System.Net.Sockets; +using AcmContester.Mediator.Library.Plugins; +using AcmContester.Mediator.Library.Plugins.SocketGate; namespace Mediator { public partial class Form1 : Form { - SocketServer socket = new SocketServer(); + // SocketServer socket = new SocketServer(); public Form1() { InitializeComponent(); string s = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[0].ToString(); label1.Text += s; - socket.onDataArrived += DataArrived; + //socket.onDataArrived += DataArrived; } private void button1_Click(object sender, EventArgs e) { - if (socket.CountClients() <= 0) + //if (socket.CountClients() <= 0) MessageBox.Show("Server: Bida"); - socket.Send(textBox1.Text); + //socket.Send(textBox1.Text); } private void button2_Click(object sender, EventArgs e) { - AcmContester.Mediator.Library.SocketGate sg = new AcmContester.Mediator.Library.SocketGate(); - AcmContester.Mediator.Library.WebGate wg = new AcmContester.Mediator.Library.WebGate(); - //socket.Start(); + AcmContester.Mediator.Library.MediatorKernel kernel = new AcmContester.Mediator.Library.MediatorKernel(); + kernel.LoadLists(); + + //AcmContester.Mediator.Library.SocketGate sg = new AcmContester.Mediator.Library.SocketGate(); + //AcmContester.Mediator.Library.WebGate wg = new AcmContester.Mediator.Library.WebGate(); } private void button3_Click(object sender, EventArgs e) { - socket.Stop(); + // socket.Stop(); } private void DataArrived(string message) @@ -50,7 +54,7 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e) { - socket.Stop(); + // socket.Stop(); } private void button4_Click(object sender, EventArgs e) @@ -77,5 +81,18 @@ } } + + private void timer1_Tick(object sender, EventArgs e) + { + string mes = "CountOfClients: "; + + AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin socketCreater = new AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin(); + SocketServerPlugin b2 = (SocketServerPlugin)socketCreater.GetInstance(); + if (b2 != null) + mes += b2.CountClients().ToString(); + else + mes += "0"; + toolStripStatusLabel1.Text = mes; + } } } \ No newline at end of file Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.resx =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.resx 2008-05-31 14:02:51 UTC (rev 191) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.resx 2008-05-31 14:05:42 UTC (rev 192) @@ -117,4 +117,10 @@ <resheader name="writer"> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> + <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> + <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>127, 17</value> + </metadata> </root> \ No newline at end of file Added: ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs (rev 0) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs 2008-05-31 14:05:42 UTC (rev 192) @@ -0,0 +1,41 @@ +using System; +using System.Collections; +using AcmContester.Mediator.Library.Plugins; + +namespace AcmContester.Mediator.Library +{ + class MediatorKernel + { + ArrayList clientSideList = new ArrayList(); + ArrayList testerSideList = new ArrayList(); + + public void LoadLists() + { + //TODO: \xEF\xEE\xF2\xF0\xB3\xE1\xED\xEE \xE2\xE8\xF2\xFF\xE3\xF3\xE2\xE0\xF2\xE8 \xE4\xE0\xED\xB3 \xB3\xE7 \xEF\xE0\xEF\xEE\xEA \xF3 \xFF\xEA\xE8\xE9\xF5 \xEC\xE0\xFE\xF2\xFC \xE7\xED\xE0\xF5\xEE\xE4\xE8\xF2\xE8\xF1\xFF \xE2\xB3\xE4\xEF\xEE\xE2\xB3\xE4\xED\xB3 dll \xE4\xEE \xEA\xEE\xE6\xED\xEE\xE3\xEE \xEF\xEB\xE0\xE3\xB3\xED\xF3 + AcmContester.Mediator.Library.Plugins.WebGate.CreaterMediatorPlugin webCreater = new AcmContester.Mediator.Library.Plugins.WebGate.CreaterMediatorPlugin(); + BaseMediatorPlugin b1 = webCreater.GetInstance(); + b1.onDataArrived += DataArrivedFromClentList; + clientSideList.Add(b1); + + AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin socketCreater = new AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin(); + BaseMediatorPlugin b2 = socketCreater.GetInstance(); + b2.onDataArrived += DataArrivedFromTesterList; + testerSideList.Add(b2); + } + + private void DataArrivedFromClentList(string message) + { + for (int index = 0; index < testerSideList.Count; index++) + { + ((BaseMediatorPlugin)testerSideList[index]).Send(message); + } + } + private void DataArrivedFromTesterList(string message) + { + for (int index = 0; index < clientSideList.Count; index++) + { + ((BaseMediatorPlugin)clientSideList[index]).Send(message); + } + } + } +} Added: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs (rev 0) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs 2008-05-31 14:05:42 UTC (rev 192) @@ -0,0 +1,18 @@ +using System; + +namespace AcmContester.Mediator.Library.Plugins +{ + public abstract class BaseMediatorPlugin + { + public delegate void DataArrived_EventHandler(string message); + public event DataArrived_EventHandler onDataArrived; + + public abstract void Send(string message); + + protected void DataArrived(string message) + { + if (onDataArrived != null) + onDataArrived(message); + } + } +} Added: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/CreaterMediatorPlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/CreaterMediatorPlugin.cs (rev 0) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/CreaterMediatorPlugin.cs 2008-05-31 14:05:42 UTC (rev 192) @@ -0,0 +1,12 @@ +using System; + +namespace AcmContester.Mediator.Library.Plugins.SocketGate +{ + public class CreaterMediatorPlugin + { + public BaseMediatorPlugin GetInstance() + { + return SocketServerPlugin.GetInstance(); ; + } + } +} Added: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs (rev 0) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs 2008-05-31 14:05:42 UTC (rev 192) @@ -0,0 +1,34 @@ +using System; +using AcmContester.Mediator.Library.Plugins; +using AcmContester.Library.Connector; + +namespace AcmContester.Mediator.Library.Plugins.SocketGate +{ + class SocketServerPlugin : BaseMediatorPlugin + { + private static SocketServerPlugin instance = new SocketServerPlugin(); + + private SocketServer server = new SocketServer(); + + private SocketServerPlugin() + { + server.Start(); + server.onDataArrived += DataArrived; + } + + public static SocketServerPlugin GetInstance() + { + return instance; + } + + public override void Send(string message) + { + server.Send(message); + } + + internal int CountClients() + { + return server.CountClients(); + } + } +} Added: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/CreaterMediatorPlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/CreaterMediatorPlugin.cs (rev 0) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/CreaterMediatorPlugin.cs 2008-05-31 14:05:42 UTC (rev 192) @@ -0,0 +1,12 @@ +using System; + +namespace AcmContester.Mediator.Library.Plugins.WebGate +{ + public class CreaterMediatorPlugin + { + public BaseMediatorPlugin GetInstance() + { + return WebGatePlugin.GetInstance(); ; + } + } +} Added: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs (rev 0) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs 2008-05-31 14:05:42 UTC (rev 192) @@ -0,0 +1,28 @@ +using System; +using AcmContester.Mediator.Library.Plugins; +using AcmContester.Library.Connector; + +namespace AcmContester.Mediator.Library.Plugins.WebGate +{ + class WebGatePlugin: BaseMediatorPlugin + { + private static WebGatePlugin instance = new WebGatePlugin(); + + private WebConnector connector = new WebConnector(); + + private WebGatePlugin() + { + connector.onDataArrived += DataArrived; + } + + public static WebGatePlugin GetInstance() + { + return instance; + } + + public override void Send(string message) + { + connector.Send(message); + } + } +} Modified: ACMServer/trunk/MediatorSolution/Mediator/Mediator.csproj =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Mediator.csproj 2008-05-31 14:02:51 UTC (rev 191) +++ ACMServer/trunk/MediatorSolution/Mediator/Mediator.csproj 2008-05-31 14:05:42 UTC (rev 192) @@ -47,6 +47,12 @@ <Compile Include="Library\Data\DataMediator.cs" /> <Compile Include="Library\Data\Result.cs" /> <Compile Include="Library\Data\Submit.cs" /> + <Compile Include="Library\MediatorKernel.cs" /> + <Compile Include="Library\Plugins\BaseMediatorPlugin.cs" /> + <Compile Include="Library\Plugins\SocketGate\CreaterMediatorPlugin.cs" /> + <Compile Include="Library\Plugins\SocketGate\SocketServerPlugin.cs" /> + <Compile Include="Library\Plugins\WebGate\CreaterMediatorPlugin.cs" /> + <Compile Include="Library\Plugins\WebGate\WebGatePlugin.cs" /> <Compile Include="Library\SocketGate.cs" /> <Compile Include="Library\WebGate.cs" /> <Compile Include="Program.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-06-02 21:02:20
|
Revision: 202 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=202&view=rev Author: brus07 Date: 2008-06-02 14:02:17 -0700 (Mon, 02 Jun 2008) Log Message: ----------- Delete old element from form Modified Paths: -------------- ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs ACMServer/trunk/MediatorSolution/Mediator/Form1.cs Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs 2008-06-02 20:20:15 UTC (rev 201) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs 2008-06-02 21:02:17 UTC (rev 202) @@ -29,39 +29,15 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.button1 = new System.Windows.Forms.Button(); - this.textBox1 = new System.Windows.Forms.TextBox(); this.button2 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.button3 = new System.Windows.Forms.Button(); - this.textBox2 = new System.Windows.Forms.TextBox(); - this.button4 = new System.Windows.Forms.Button(); - this.textBox3 = new System.Windows.Forms.TextBox(); - this.textBox4 = new System.Windows.Forms.TextBox(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // - // button1 - // - this.button1.Location = new System.Drawing.Point(202, 41); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); - this.button1.TabIndex = 0; - this.button1.Text = "Send"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // textBox1 - // - this.textBox1.Location = new System.Drawing.Point(12, 81); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(290, 160); - this.textBox1.TabIndex = 1; - // // button2 // this.button2.Location = new System.Drawing.Point(12, 12); @@ -75,7 +51,7 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(199, 9); + this.label1.Location = new System.Drawing.Point(12, 76); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(23, 13); this.label1.TabIndex = 3; @@ -91,48 +67,13 @@ this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // - // textBox2 - // - this.textBox2.Location = new System.Drawing.Point(318, 81); - this.textBox2.Multiline = true; - this.textBox2.Name = "textBox2"; - this.textBox2.Size = new System.Drawing.Size(268, 160); - this.textBox2.TabIndex = 5; - // - // button4 - // - this.button4.Location = new System.Drawing.Point(12, 247); - this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(75, 23); - this.button4.TabIndex = 6; - this.button4.Text = "GetWeb"; - this.button4.UseVisualStyleBackColor = true; - this.button4.Click += new System.EventHandler(this.button4_Click); - // - // textBox3 - // - this.textBox3.Location = new System.Drawing.Point(12, 276); - this.textBox3.Multiline = true; - this.textBox3.Name = "textBox3"; - this.textBox3.Size = new System.Drawing.Size(574, 169); - this.textBox3.TabIndex = 7; - // - // textBox4 - // - this.textBox4.Location = new System.Drawing.Point(93, 250); - this.textBox4.Name = "textBox4"; - this.textBox4.Size = new System.Drawing.Size(493, 20); - this.textBox4.TabIndex = 8; - this.textBox4.Text = "http://acm.lviv.ua/fusion/acm/getsubmit.php?passw=master&type=GetSubmitInfo&id=35" + - "000"; - // // statusStrip1 // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1}); - this.statusStrip1.Location = new System.Drawing.Point(0, 448); + this.statusStrip1.Location = new System.Drawing.Point(0, 138); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(598, 22); + this.statusStrip1.Size = new System.Drawing.Size(262, 22); this.statusStrip1.TabIndex = 9; this.statusStrip1.Text = "statusStrip1"; // @@ -151,17 +92,11 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(598, 470); + this.ClientSize = new System.Drawing.Size(262, 160); this.Controls.Add(this.statusStrip1); - this.Controls.Add(this.textBox4); - this.Controls.Add(this.textBox3); - this.Controls.Add(this.button4); - this.Controls.Add(this.textBox2); this.Controls.Add(this.button3); this.Controls.Add(this.label1); this.Controls.Add(this.button2); - this.Controls.Add(this.textBox1); - this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Gate"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); @@ -174,15 +109,9 @@ #endregion - private System.Windows.Forms.Button button1; - private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button button3; - private System.Windows.Forms.TextBox textBox2; - private System.Windows.Forms.Button button4; - private System.Windows.Forms.TextBox textBox3; - private System.Windows.Forms.TextBox textBox4; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.Timer timer1; Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.cs 2008-06-02 20:20:15 UTC (rev 201) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.cs 2008-06-02 21:02:17 UTC (rev 202) @@ -14,31 +14,18 @@ { public partial class Form1 : Form { - // SocketServer socket = new SocketServer(); public Form1() { InitializeComponent(); string s = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())[0].ToString(); label1.Text += s; - //socket.onDataArrived += DataArrived; } - - private void button1_Click(object sender, EventArgs e) - { - //if (socket.CountClients() <= 0) - MessageBox.Show("Server: Bida"); - //socket.Send(textBox1.Text); - } - private void button2_Click(object sender, EventArgs e) { AcmContester.Mediator.Library.MediatorKernel kernel = new AcmContester.Mediator.Library.MediatorKernel(); kernel.LoadLists(); - - //AcmContester.Mediator.Library.SocketGate sg = new AcmContester.Mediator.Library.SocketGate(); - //AcmContester.Mediator.Library.WebGate wg = new AcmContester.Mediator.Library.WebGate(); } private void button3_Click(object sender, EventArgs e) @@ -46,12 +33,6 @@ Disconnnect(); } - private void DataArrived(string message) - { - textBox2.Text += "\r\n" + message; - //TODO: doOther - } - private void Disconnnect() { AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin socketCreater = new AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin(); @@ -64,31 +45,6 @@ Disconnnect(); } - private void button4_Click(object sender, EventArgs e) - { - //AcmContester.Mediator.Library.Data.DataMediator d = AcmContester.Mediator.Library.Data.DataMediator.GetMediator(); - //d.DeleteOld(); - - TcpClient tcpClient = new TcpClient(); - tcpClient.Connect(textBox4.Text, 80); - NetworkStream netStream = tcpClient.GetStream(); - if (netStream.CanRead) - { - // Reads NetworkStream into a byte buffer. - byte[] bytes = new byte[tcpClient.ReceiveBufferSize]; - - // Read can return anything from 0 to numBytesToRead. - // This method blocks until at least one byte is read. - netStream.Read(bytes, 0, (int)tcpClient.ReceiveBufferSize); - - // Returns the data received from the host to the console. - string returndata = Encoding.UTF8.GetString(bytes); - - textBox3.Text = returndata; - - } - } - private void timer1_Tick(object sender, EventArgs e) { string mes = "CountOfClients: "; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <br...@us...> - 2008-06-09 13:19:25
|
Revision: 232 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=232&view=rev Author: brus07 Date: 2008-06-09 06:19:32 -0700 (Mon, 09 Jun 2008) Log Message: ----------- WorkingData event. When do something call this event. WorkingData append text to TextLog in main form. Scroll to end TextLog when change text. Modified Paths: -------------- ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs ACMServer/trunk/MediatorSolution/Mediator/Form1.cs ACMServer/trunk/MediatorSolution/Mediator/Form1.resx ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.Designer.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -34,9 +34,11 @@ this.button3 = new System.Windows.Forms.Button(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); - this.timer1 = new System.Windows.Forms.Timer(this.components); + this.timerCountSocketClients = new System.Windows.Forms.Timer(this.components); this.textBox1 = new System.Windows.Forms.TextBox(); this.textBox2 = new System.Windows.Forms.TextBox(); + this.textBox3 = new System.Windows.Forms.TextBox(); + this.timerUpdateTextLog = new System.Windows.Forms.Timer(this.components); this.statusStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -75,9 +77,9 @@ // this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1}); - this.statusStrip1.Location = new System.Drawing.Point(0, 138); + this.statusStrip1.Location = new System.Drawing.Point(0, 295); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(262, 22); + this.statusStrip1.Size = new System.Drawing.Size(369, 22); this.statusStrip1.TabIndex = 9; this.statusStrip1.Text = "statusStrip1"; // @@ -87,10 +89,10 @@ this.toolStripStatusLabel1.Size = new System.Drawing.Size(109, 17); this.toolStripStatusLabel1.Text = "toolStripStatusLabel1"; // - // timer1 + // timerCountSocketClients // - this.timer1.Enabled = true; - this.timer1.Tick += new System.EventHandler(this.timer1_Tick); + this.timerCountSocketClients.Enabled = true; + this.timerCountSocketClients.Tick += new System.EventHandler(this.timer1_Tick); // // textBox1 // @@ -109,11 +111,30 @@ this.textBox2.Size = new System.Drawing.Size(110, 20); this.textBox2.TabIndex = 11; // + // textBox3 + // + this.textBox3.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBox3.Location = new System.Drawing.Point(12, 121); + this.textBox3.Multiline = true; + this.textBox3.Name = "textBox3"; + this.textBox3.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.textBox3.Size = new System.Drawing.Size(345, 171); + this.textBox3.TabIndex = 12; + // + // timerUpdateTextLog + // + this.timerUpdateTextLog.Enabled = true; + this.timerUpdateTextLog.Interval = 2000; + this.timerUpdateTextLog.Tick += new System.EventHandler(this.timerUpdateTextLog_Tick); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(262, 160); + this.ClientSize = new System.Drawing.Size(369, 317); + this.Controls.Add(this.textBox3); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox1); this.Controls.Add(this.statusStrip1); @@ -122,8 +143,8 @@ this.Controls.Add(this.button2); this.Name = "Form1"; this.Text = "Gate"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.Load += new System.EventHandler(this.Form1_Load); - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); this.ResumeLayout(false); @@ -138,9 +159,11 @@ private System.Windows.Forms.Button button3; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; - private System.Windows.Forms.Timer timer1; + private System.Windows.Forms.Timer timerCountSocketClients; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.TextBox textBox3; + private System.Windows.Forms.Timer timerUpdateTextLog; } } Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -9,6 +9,7 @@ using System.Net.Sockets; using AcmContester.Mediator.Library.Plugins; using AcmContester.Mediator.Library.Plugins.SocketGate; +using System.IO; namespace Mediator { @@ -22,12 +23,38 @@ textBox2.Text = s; } + string fullLog = ""; + private void button2_Click(object sender, EventArgs e) { AcmContester.Mediator.Library.MediatorKernel kernel = new AcmContester.Mediator.Library.MediatorKernel(); + kernel.onWorkingData += WorkingData; kernel.LoadLists(); } + private void WorkingData(string message) + { + string s = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString() + ": "; + s += message; + + lock (fullLog) + { + fullLog += s; + fullLog += "\r\n"; + } + } + private void UpdateTextLog() + { + lock (fullLog) + { + //textBox3.SelectedText = fullLog; + textBox3.Text += fullLog; + textBox3.Select(textBox3.Text.Length, 0); + textBox3.ScrollToCaret(); + fullLog = ""; + } + } + private void button3_Click(object sender, EventArgs e) { Disconnnect(); @@ -62,5 +89,10 @@ { button2_Click(this, null); } + + private void timerUpdateTextLog_Tick(object sender, EventArgs e) + { + UpdateTextLog(); + } } } \ No newline at end of file Modified: ACMServer/trunk/MediatorSolution/Mediator/Form1.resx =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Form1.resx 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Form1.resx 2008-06-09 13:19:32 UTC (rev 232) @@ -120,7 +120,10 @@ <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>17, 17</value> </metadata> - <metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <metadata name="timerCountSocketClients.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <value>127, 17</value> </metadata> + <metadata name="timerUpdateTextLog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>300, 17</value> + </metadata> </root> \ No newline at end of file Modified: ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/MediatorKernel.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -15,14 +15,24 @@ AcmContester.Mediator.Library.Plugins.WebGate.CreaterMediatorPlugin webCreater = new AcmContester.Mediator.Library.Plugins.WebGate.CreaterMediatorPlugin(); BaseMediatorPlugin b1 = webCreater.GetInstance(); b1.onDataArrived += DataArrivedFromClentList; + b1.onWorkingData += WorkingData; clientSideList.Add(b1); AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin socketCreater = new AcmContester.Mediator.Library.Plugins.SocketGate.CreaterMediatorPlugin(); BaseMediatorPlugin b2 = socketCreater.GetInstance(); b2.onDataArrived += DataArrivedFromTesterList; + b2.onWorkingData += WorkingData; testerSideList.Add(b2); } + public delegate void WorkingData_EventHandler(string message); + public event WorkingData_EventHandler onWorkingData; + private void WorkingData(string message) + { + if (onWorkingData != null) + onWorkingData(message); + } + private void DataArrivedFromClentList(string message) { for (int index = 0; index < testerSideList.Count; index++) Modified: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/BaseMediatorPlugin.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -7,12 +7,22 @@ public delegate void DataArrived_EventHandler(string message); public event DataArrived_EventHandler onDataArrived; + public delegate void WorkingData_EventHandler(string message); + public event WorkingData_EventHandler onWorkingData; + public abstract void Send(string message); protected virtual void DataArrived(string message) { + WorkingData("BaseMediatorPlugin::DataArrived(" + message + ")"); if (onDataArrived != null) onDataArrived(message); } + + protected virtual void WorkingData(string message) + { + if (onWorkingData != null) + onWorkingData(message); + } } } Modified: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/SocketGate/SocketServerPlugin.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -28,12 +28,15 @@ public override void Send(string message) { - if (dataContainer.Add(new Submit(message))) - server.Send(message); + WorkingData("SocketServerPlugin::Send(" + message + ")"); + if (server.CountClients() > 0) + if (dataContainer.Add(new Submit(message))) + server.Send(message); } protected override void DataArrived(string message) { + WorkingData("SocketServerPlugin::DataArrived(" + message + ")"); dataContainer.Return(new Result(message)); base.DataArrived(message); } @@ -47,6 +50,7 @@ internal void Stop() { + WorkingData("SocketServerPlugin::Stop()"); if (server != null) server.Stop(); server = null; Modified: ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs =================================================================== --- ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs 2008-06-09 13:08:31 UTC (rev 231) +++ ACMServer/trunk/MediatorSolution/Mediator/Library/Plugins/WebGate/WebGatePlugin.cs 2008-06-09 13:19:32 UTC (rev 232) @@ -25,6 +25,7 @@ public override void Send(string message) { + WorkingData("WebGatePlugin::Send(" + message + ")"); connector.Send(message); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |