|
From: <br...@us...> - 2008-07-09 09:53:44
|
Revision: 295
http://acmcontester.svn.sourceforge.net/acmcontester/?rev=295&view=rev
Author: brus07
Date: 2008-07-09 02:53:53 -0700 (Wed, 09 Jul 2008)
Log Message:
-----------
Refactoring of Protocol classes. All data transferring in string type.
Modified Paths:
--------------
ACMServer/trunk/ACMServer/Library/Connector/ISocket.cs
ACMServer/trunk/ACMServer/Library/Connector/SocketClient.cs
ACMServer/trunk/ACMServer/Library/Connector/SocketProtocol/EasyProtocol.cs
ACMServer/trunk/ACMServer/Library/Connector/SocketProtocol/IProtocol.cs
ACMServer/trunk/ACMServer/Library/Connector/SocketServer.cs
Modified: ACMServer/trunk/ACMServer/Library/Connector/ISocket.cs
===================================================================
--- ACMServer/trunk/ACMServer/Library/Connector/ISocket.cs 2008-07-09 09:43:28 UTC (rev 294)
+++ ACMServer/trunk/ACMServer/Library/Connector/ISocket.cs 2008-07-09 09:53:53 UTC (rev 295)
@@ -2,6 +2,6 @@
{
interface ISocket
{
- void OnDataArrived(object data);
+ void OnDataArrived(string message);
}
}
Modified: ACMServer/trunk/ACMServer/Library/Connector/SocketClient.cs
===================================================================
--- ACMServer/trunk/ACMServer/Library/Connector/SocketClient.cs 2008-07-09 09:43:28 UTC (rev 294)
+++ ACMServer/trunk/ACMServer/Library/Connector/SocketClient.cs 2008-07-09 09:53:53 UTC (rev 295)
@@ -59,11 +59,11 @@
#region ISocket Members
- public void OnDataArrived(object data)
+ public void OnDataArrived(string message)
{
if (onDataArrived != null)
{
- onDataArrived(data.ToString());
+ onDataArrived(message);
}
}
Modified: ACMServer/trunk/ACMServer/Library/Connector/SocketProtocol/EasyProtocol.cs
===================================================================
--- ACMServer/trunk/ACMServer/Library/Connector/SocketProtocol/EasyProtocol.cs 2008-07-09 09:43:28 UTC (rev 294)
+++ ACMServer/trunk/ACMServer/Library/Connector/SocketProtocol/EasyProtocol.cs 2008-07-09 09:53:53 UTC (rev 295)
@@ -5,27 +5,20 @@
{
class EasyProtocol: IProtocol
{
- int clientIndex = 0;
#region IProtocol Members
- public void DataArrived(object message, ISocket socket)
+ public void DataArrived(string message, ISocket socket)
{
socket.OnDataArrived(message);
}
- public void Send(object message, EasyServer server)
+ public void Send(string message, EasyServer server, int targerClientIndex)
{
- if (server.CountClients > 0)
- {
- if (clientIndex >= server.CountClients)
- clientIndex = 0;
- server.SendData(message, clientIndex);
- clientIndex++;
- }
+ server.SendData(message, targerClientIndex);
}
- public void Send(object message, EasyClient client)
+ public void Send(string message, EasyClient client)
{
if (client.IsConnected == true)
client.SendData(message);
Modified: ACMServer/trunk/ACMServer/Library/Connector/SocketProtocol/IProtocol.cs
===================================================================
--- ACMServer/trunk/ACMServer/Library/Connector/SocketProtocol/IProtocol.cs 2008-07-09 09:43:28 UTC (rev 294)
+++ ACMServer/trunk/ACMServer/Library/Connector/SocketProtocol/IProtocol.cs 2008-07-09 09:53:53 UTC (rev 295)
@@ -4,8 +4,8 @@
{
interface IProtocol
{
- void DataArrived(object message, ISocket socket);
- void Send(object message, EasyServer server);
- void Send(object message, EasyClient client);
+ void DataArrived(string message, ISocket socket);
+ void Send(string message, EasyServer server, int targerClientIndex);
+ void Send(string message, EasyClient client);
}
}
Modified: ACMServer/trunk/ACMServer/Library/Connector/SocketServer.cs
===================================================================
--- ACMServer/trunk/ACMServer/Library/Connector/SocketServer.cs 2008-07-09 09:43:28 UTC (rev 294)
+++ ACMServer/trunk/ACMServer/Library/Connector/SocketServer.cs 2008-07-09 09:53:53 UTC (rev 295)
@@ -41,9 +41,16 @@
protocol.DataArrived(Data.ToString(), this);
}
+ int clientIndex = 0;
public void Send(string message)
{
- protocol.Send(message, server);
+ if (server.CountClients > 0)
+ {
+ if (clientIndex >= server.CountClients)
+ clientIndex = 0;
+ protocol.Send(message, server, clientIndex);
+ clientIndex++;
+ }
}
public int CountClients()
@@ -53,11 +60,11 @@
#region ISocket Members
- public void OnDataArrived(object data)
+ public void OnDataArrived(string message)
{
if (onDataArrived != null)
{
- onDataArrived(data.ToString());
+ onDataArrived(message);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|