From: <br...@us...> - 2008-05-05 11:38:49
|
Revision: 86 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=86&view=rev Author: brus07 Date: 2008-05-05 04:38:55 -0700 (Mon, 05 May 2008) Log Message: ----------- ?\208?\148?\208?\190?\209?\128?\208?\190?\208?\177?\208?\187?\208?\181?\208?\189?\208?\184?\208?\185 WebConnector, ?\208?\176?\208?\187?\208?\181 ?\209?\130?\208?\184?\208?\188?\209?\135?\208?\176?\209?\129?\208?\190?\208?\178?\208?\190 ?\208?\183?\209?\128?\208?\190?\208?\177?\208?\187?\208?\181?\208?\189?\208?\190, ?\209?\137?\208?\190 ?\208?\178?\209?\150?\208?\189 ?\208?\177?\208?\181?\209?\128?\208?\181 ?\209?\150?\208?\189?\209?\132?\208?\190?\209?\128?\208?\188?\208?\176?\209?\134?\209?\150?\209?\142 ?\208?\191?\208?\190 ?\209?\130?\208?\176?\208?\185?\208?\188?\208?\181?\209?\128?\209?\131 ?\209?\150?\208?\183 ?\209?\132?\208?\176?\208?\185?\208?\187?\208?\176 a.txt ?\209?\150 ?\208?\191?\208?\184?\209?\136?\208?\181 ?\208?\190?\209?\130?\209?\128?\208?\184?\208?\188?\208?\176?\208?\189?\209?\131 ?\209?\150?\208?\189?\209?\132?\208?\190?\209?\128?\208?\188?\208?\176?\209?\134?\209?\150?\209?\142 ?\209?\131 ?\209?\132?\208?\176?\208?\185?\208?\187?\209?\131 b.txt \AcmContester.sln \Library\Connector\SocketClient.cs \Library\Connector\WebConnector.cs \Mediator\Library\Connector\SocketServerSingleton.cs \Mediator\Library\Connector\WebConnectorSignleton.cs \Mediator\Library\Data\Submit.cs \Mediator\Library\SocketGate.cs \Mediator\Library\WebGate.cs \Mediator\Form1.cs \Tester\Form1.cs Modified Paths: -------------- ACMServer/trunk/AcmContester.sln ACMServer/trunk/AcmContester.suo ACMServer/trunk/Library/Connector/SocketClient.cs ACMServer/trunk/Library/Connector/WebConnector.cs ACMServer/trunk/Mediator/Form1.cs ACMServer/trunk/Mediator/Library/Connector/SocketServerSingleton.cs ACMServer/trunk/Mediator/Library/Connector/WebConnectorSignleton.cs ACMServer/trunk/Mediator/Library/Data/Submit.cs ACMServer/trunk/Mediator/Library/SocketGate.cs ACMServer/trunk/Mediator/Library/WebGate.cs ACMServer/trunk/Tester/Form1.cs Modified: ACMServer/trunk/AcmContester.sln =================================================================== --- ACMServer/trunk/AcmContester.sln 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/AcmContester.sln 2008-05-05 11:38:55 UTC (rev 86) @@ -1,29 +1,32 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{3C6F91E7-56AA-4138-8A3F-FE70897153DA}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Library", "Library", "{5AC26E6C-CFBB-4262-B07E-71C9B5288630}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Checker", "Checker\Checker.csproj", "{052D9F77-17AF-42F3-BFBF-975A19383496}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Connector", "Library\Connector\Connector.csproj", "{211DD6A5-2D73-439E-8722-ED2C89ED1DDB}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Resource", "Resource", "{E6E2D45E-F398-47F2-8A53-85C18D3BD82F}" - ProjectSection(SolutionItems) = preProject - Resource\EasySocket.dll = Resource\EasySocket.dll - EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mediator", "Mediator\Mediator.csproj", "{60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Library", "Library", "{5AC26E6C-CFBB-4262-B07E-71C9B5288630}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{3C6F91E7-56AA-4138-8A3F-FE70897153DA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Connector", "Library\Connector\Connector.csproj", "{211DD6A5-2D73-439E-8722-ED2C89ED1DDB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Checker", "Checker\Checker.csproj", "{052D9F77-17AF-42F3-BFBF-975A19383496}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibraryExtention", "Library\LibraryExtention\LibraryExtention.csproj", "{A8135069-F8BA-4E5D-835F-3FF3F350AA5D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mediator", "Mediator\Mediator.csproj", "{60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {211DD6A5-2D73-439E-8722-ED2C89ED1DDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {211DD6A5-2D73-439E-8722-ED2C89ED1DDB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {211DD6A5-2D73-439E-8722-ED2C89ED1DDB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {211DD6A5-2D73-439E-8722-ED2C89ED1DDB}.Release|Any CPU.Build.0 = Release|Any CPU + {60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}.Release|Any CPU.Build.0 = Release|Any CPU {3C6F91E7-56AA-4138-8A3F-FE70897153DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3C6F91E7-56AA-4138-8A3F-FE70897153DA}.Debug|Any CPU.Build.0 = Debug|Any CPU {3C6F91E7-56AA-4138-8A3F-FE70897153DA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -32,18 +35,10 @@ {052D9F77-17AF-42F3-BFBF-975A19383496}.Debug|Any CPU.Build.0 = Debug|Any CPU {052D9F77-17AF-42F3-BFBF-975A19383496}.Release|Any CPU.ActiveCfg = Release|Any CPU {052D9F77-17AF-42F3-BFBF-975A19383496}.Release|Any CPU.Build.0 = Release|Any CPU - {211DD6A5-2D73-439E-8722-ED2C89ED1DDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {211DD6A5-2D73-439E-8722-ED2C89ED1DDB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {211DD6A5-2D73-439E-8722-ED2C89ED1DDB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {211DD6A5-2D73-439E-8722-ED2C89ED1DDB}.Release|Any CPU.Build.0 = Release|Any CPU {A8135069-F8BA-4E5D-835F-3FF3F350AA5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A8135069-F8BA-4E5D-835F-3FF3F350AA5D}.Debug|Any CPU.Build.0 = Debug|Any CPU {A8135069-F8BA-4E5D-835F-3FF3F350AA5D}.Release|Any CPU.ActiveCfg = Release|Any CPU {A8135069-F8BA-4E5D-835F-3FF3F350AA5D}.Release|Any CPU.Build.0 = Release|Any CPU - {60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {60AAB414-BF4A-4A67-9FF2-D04C3B4BBA9B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: ACMServer/trunk/AcmContester.suo =================================================================== (Binary files differ) Modified: ACMServer/trunk/Library/Connector/SocketClient.cs =================================================================== --- ACMServer/trunk/Library/Connector/SocketClient.cs 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/Library/Connector/SocketClient.cs 2008-05-05 11:38:55 UTC (rev 86) @@ -21,11 +21,13 @@ public void Connect() { - client.ConnectToServerAsync(); + if (client.IsConnected == false) + client.ConnectToServerAsync(); } public void Disconnect() { - client.DisconnectFromServer(); + if (client.IsConnected == true) + client.DisconnectFromServer(); } public void Send(string message) { Modified: ACMServer/trunk/Library/Connector/WebConnector.cs =================================================================== --- ACMServer/trunk/Library/Connector/WebConnector.cs 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/Library/Connector/WebConnector.cs 2008-05-05 11:38:55 UTC (rev 86) @@ -1,13 +1,35 @@ using System; +using System.Timers; namespace AcmContester.Library.Connector { public class WebConnector { + Timer timer = new Timer(); public delegate void DataArrivedDelegate(string s); public event DataArrivedDelegate onDataArrived; + public WebConnector() + { + timer.Interval = 10 * 1000; + timer.Elapsed += new ElapsedEventHandler(OnTimedEvent); + timer.Enabled = true; + } + + // Specify what you want to happen when the Elapsed event is + // raised. + private void OnTimedEvent(object source, ElapsedEventArgs e) + { + timer.Enabled = false; + object ob = GetInfoFromSite(); + if (ob != null) + { + DataArrived(ob); + } + timer.Enabled = true; + } + private void DataArrived(object Data) { if (onDataArrived != null) @@ -16,8 +38,37 @@ } } + private object GetInfoFromSite() + { + try + { + string res = ""; + using (System.IO.StreamReader sr = new System.IO.StreamReader("a.txt")) + { + res = sr.ReadToEnd(); + } + if (res.Length == 0) + return null; + return res; + } + catch(Exception) + { + } + return null; + } + public void Send(string message) { + try + { + using (System.IO.StreamWriter sr = new System.IO.StreamWriter("b.txt", true)) + { + sr.WriteLine(message); + } + } + catch (Exception) + { + } //TODO: } } Modified: ACMServer/trunk/Mediator/Form1.cs =================================================================== --- ACMServer/trunk/Mediator/Form1.cs 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/Mediator/Form1.cs 2008-05-05 11:38:55 UTC (rev 86) @@ -32,7 +32,9 @@ private void button2_Click(object sender, EventArgs e) { - socket.Start(); + AcmContester.Gate.Library.SocketGate sg = new AcmContester.Gate.Library.SocketGate(); + AcmContester.Gate.Library.WebGate wg = new AcmContester.Gate.Library.WebGate(); + //socket.Start(); } private void button3_Click(object sender, EventArgs e) Modified: ACMServer/trunk/Mediator/Library/Connector/SocketServerSingleton.cs =================================================================== --- ACMServer/trunk/Mediator/Library/Connector/SocketServerSingleton.cs 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/Mediator/Library/Connector/SocketServerSingleton.cs 2008-05-05 11:38:55 UTC (rev 86) @@ -1,7 +1,7 @@ using System; using AcmContester.Library.Connector; -namespace Gate.Library.Connector +namespace AcmContester.Gate.Library.Connector { //TODO: \xEF\xEE\xF2\xF0\xB3\xE1\xED\xEE \xE7\xF0\xEE\xE1\xE8\xF2\xE8 \xE2\xB3\xE4\xEF\xEE\xE2\xB3\xE4\xED\xE8\xE9 \xB3\xED\xF2\xE5\xF0\xF4\xE5\xE9\xF1, \xF6\xE5\xE9 \xEA\xEB\xE0\xF1 \xB3 SocketServer \xEC\xE0\xFE\xF2\xFC \xE9\xEE\xE3\xEE \xED\xE0\xF1\xEB\xF3\xE4\xB3\xE2\xE0\xF2\xE8 /// <summary> Modified: ACMServer/trunk/Mediator/Library/Connector/WebConnectorSignleton.cs =================================================================== --- ACMServer/trunk/Mediator/Library/Connector/WebConnectorSignleton.cs 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/Mediator/Library/Connector/WebConnectorSignleton.cs 2008-05-05 11:38:55 UTC (rev 86) @@ -1,11 +1,11 @@ using System; using AcmContester.Library.Connector; -namespace Gate.Library.Connector +namespace AcmContester.Gate.Library.Connector { - class WebConnectorSignleton + class WebConnectorSingleton { - private static WebConnector instance = new WebConnector(); + private static WebConnectorSingleton instance = new WebConnectorSingleton(); private WebConnector connector = new WebConnector(); @@ -13,12 +13,12 @@ public delegate void DataArrivedDelegate(string s); public event DataArrivedDelegate onDataArrived; - private WebConnectorSignleton() + private WebConnectorSingleton() { connector.onDataArrived += DataArrived; } - public static WebConnector GetWebConnector() + public static WebConnectorSingleton GetWebConnector() { return instance; } Modified: ACMServer/trunk/Mediator/Library/Data/Submit.cs =================================================================== --- ACMServer/trunk/Mediator/Library/Data/Submit.cs 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/Mediator/Library/Data/Submit.cs 2008-05-05 11:38:55 UTC (rev 86) @@ -20,5 +20,17 @@ { return temp; } + + public override int GetHashCode() + { + //HACK: + int result = 0; + for (int i = 0; i < temp.Length; i++) + { + result *= 991; + result += (int)temp[i]; + } + return result; + } } } Modified: ACMServer/trunk/Mediator/Library/SocketGate.cs =================================================================== --- ACMServer/trunk/Mediator/Library/SocketGate.cs 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/Mediator/Library/SocketGate.cs 2008-05-05 11:38:55 UTC (rev 86) @@ -1,8 +1,8 @@ using System; using AcmContester.Library.Connector; -using Gate.Library.Connector; using AcmContester.AcmLibraryExtention; using AcmContester.Gate.Library.Data; +using AcmContester.Gate.Library.Connector; namespace AcmContester.Gate.Library { Modified: ACMServer/trunk/Mediator/Library/WebGate.cs =================================================================== --- ACMServer/trunk/Mediator/Library/WebGate.cs 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/Mediator/Library/WebGate.cs 2008-05-05 11:38:55 UTC (rev 86) @@ -1,12 +1,12 @@ using System; using AcmContester.Gate.Library.Data; -using Gate.Library.Connector; +using AcmContester.Gate.Library.Connector; namespace AcmContester.Gate.Library { class WebGate { - WebConnectorSignleton webConnector = WebConnectorSignleton.GetWebConnector(); + WebConnectorSingleton webConnector = WebConnectorSingleton.GetWebConnector(); DataMediator mediator = DataMediator.GetMediator(); Modified: ACMServer/trunk/Tester/Form1.cs =================================================================== --- ACMServer/trunk/Tester/Form1.cs 2008-05-05 08:26:54 UTC (rev 85) +++ ACMServer/trunk/Tester/Form1.cs 2008-05-05 11:38:55 UTC (rev 86) @@ -19,8 +19,11 @@ private void button1_Click(object sender, EventArgs e) { - socket = new SocketClient(textBox3.Text); - socket.onDataArrived += DataArrived; + if (socket == null) + { + socket = new SocketClient(textBox3.Text); + socket.onDataArrived += DataArrived; + } socket.Connect(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |