From 5450421900b063de5b0dfca15ecef7e00cddc3cb Mon Sep 17 00:00:00 2001 From: yankejustin Date: Fri, 29 May 2015 18:39:18 -0400 Subject: [PATCH 1/7] Added documentation for server's client Added some documentation for the server's client object. --- Server/Core/Client.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Server/Core/Client.cs b/Server/Core/Client.cs index 5d6c4bc3..ff70fff9 100644 --- a/Server/Core/Client.cs +++ b/Server/Core/Client.cs @@ -15,8 +15,17 @@ namespace xServer.Core { public class Client { + /// + /// Occurs when the state of the client changes. + /// public event ClientStateEventHandler ClientState; + /// + /// Represents the method that will handle a change in a client's state. + /// + /// The client to update the state of. + /// True if the client is connected; False if the client + /// is not connected. public delegate void ClientStateEventHandler(Client s, bool connected); private void OnClientState(bool connected) @@ -30,10 +39,23 @@ namespace xServer.Core } } + /// + /// Occurs when a packet is received from the client. + /// public event ClientReadEventHandler ClientRead; + /// + /// Represents the method that will handle a packet from a client. + /// + /// The client that has sent the packet. + /// The packet that has been received from the client. public delegate void ClientReadEventHandler(Client s, IPacket packet); + /// + /// Fires an event that informs subscribers that the a packet has been + /// received from the client. + /// + /// private void OnClientRead(IPacket packet) { if (ClientRead != null) @@ -59,6 +81,9 @@ namespace xServer.Core } } + /// + /// The type of the packet received. + /// public enum ReceiveType { Header, @@ -73,6 +98,9 @@ namespace xServer.Core private Socket _handle; private int _typeIndex; + /// + /// The buffer for the client's incoming and outgoing packets. + /// private byte[] _buffer = new byte[MAX_PACKET_SIZE]; //receive info @@ -294,6 +322,10 @@ namespace xServer.Core } } + /// + /// Disconnect the client from the server and dispose of + /// resources associated with the client. + /// public void Disconnect() { OnClientState(false); From 4be0073f837b1b34fa2d9a438b600e2c5d8fa497 Mon Sep 17 00:00:00 2001 From: yankejustin Date: Fri, 29 May 2015 19:03:24 -0400 Subject: [PATCH 2/7] Added documentation for the server Added some documentation for the Server's server object. --- Server/Core/Server.cs | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Server/Core/Server.cs b/Server/Core/Server.cs index cb7532cf..02222b41 100644 --- a/Server/Core/Server.cs +++ b/Server/Core/Server.cs @@ -11,8 +11,17 @@ namespace xServer.Core public long BytesReceived { get; set; } public long BytesSent { get; set; } + /// + /// Occurs when the state of the server changes. + /// public event ServerStateEventHandler ServerState; + /// + /// Represents a method that will handle a change in the server's state. + /// + /// The server to update the state of. + /// True if the server is listening; False if the server + /// is not listening. public delegate void ServerStateEventHandler(Server s, bool listening); private void OnServerState(bool listening) @@ -23,10 +32,24 @@ namespace xServer.Core } } + /// + /// Occurs when the state of a client changes. + /// public event ClientStateEventHandler ClientState; + /// + /// Represents a method that will handle a change in a client's state. + /// + /// + /// + /// public delegate void ClientStateEventHandler(Server s, Client c, bool connected); + /// + /// Fires an event that informs subscribers that the a packet has been + /// received from the client. + /// + /// private void OnClientState(Client c, bool connected) { if (ClientState != null) @@ -35,10 +58,25 @@ namespace xServer.Core } } + /// + /// Occurs when a packet is received by a client. + /// public event ClientReadEventHandler ClientRead; + /// + /// Represents a method that will handle a packet received from a client. + /// + /// The destination server of the packet; also where the client specified + /// should reside + /// The client that has sent the packet. + /// The packet that was sent to the server. public delegate void ClientReadEventHandler(Server s, Client c, IPacket packet); + /// + /// Fires an event that informs subscribers that the a packet has been + /// received from the client. + /// + /// private void OnClientRead(Client c, IPacket packet) { if (ClientRead != null) @@ -63,18 +101,36 @@ namespace xServer.Core private Socket _handle; private SocketAsyncEventArgs _item; + /// + /// Gets or sets if the server is currently processing data that + /// should prevent disconnection. + /// private bool Processing { get; set; } + /// + /// Gets the status of the server. True if the server is currently + /// listening; False if the server is not currently listening. + /// public bool Listening { get; private set; } + /// + /// The internal list of the clients connected to the server. + /// private List _clients; + /// + /// Gets the clients currently connected to the server, or an empty array of + /// clients if the server is currently not listening. + /// public Client[] Clients { get { return Listening ? _clients.ToArray() : new Client[0]; } } public int ConnectedClients { get; set; } + /// + /// A collection containing all of the clients that have connected to the server. + /// public Dictionary AllTimeConnectedClients { get; set; } private List PacketTypes { get; set; } From 8edeb8b9689d2fd57b3c189422e1a67db6d1f1e7 Mon Sep 17 00:00:00 2001 From: yankejustin Date: Fri, 29 May 2015 19:55:13 -0400 Subject: [PATCH 3/7] Added more documentation for the server Added some more documentation for the Server's server object. --- Server/Core/Server.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Server/Core/Server.cs b/Server/Core/Server.cs index 02222b41..3afea0fd 100644 --- a/Server/Core/Server.cs +++ b/Server/Core/Server.cs @@ -103,7 +103,7 @@ namespace xServer.Core /// /// Gets or sets if the server is currently processing data that - /// should prevent disconnection. + /// should prevent disconnection. /// private bool Processing { get; set; } @@ -141,6 +141,10 @@ namespace xServer.Core AllTimeConnectedClients = new Dictionary(); } + /// + /// Begins listening for clients. + /// + /// Port to listen for clients on. public void Listen(ushort port) { try @@ -202,6 +206,12 @@ namespace xServer.Core AddTypeToSerializer(parent, type); } + /// + /// Processes an incoming client; adding the client to the list of clients, + /// hooking up the client's events, and finally accepts the client. + /// + /// + /// private void Process(object s, SocketAsyncEventArgs e) { try @@ -233,6 +243,10 @@ namespace xServer.Core } } + /// + /// Disconnect the server from all of the clients and discontinue + /// listening (placing the server in an "off" state). + /// public void Disconnect() { if (Processing) From 0f281d4af37c684848e7295b154ee71427b239b2 Mon Sep 17 00:00:00 2001 From: yankejustin Date: Fri, 29 May 2015 19:59:54 -0400 Subject: [PATCH 4/7] Added and fixed some server documentation Changed a few lines of documentation and added some more documentation on another part. --- Server/Core/Server.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Server/Core/Server.cs b/Server/Core/Server.cs index 3afea0fd..65db61f9 100644 --- a/Server/Core/Server.cs +++ b/Server/Core/Server.cs @@ -24,6 +24,10 @@ namespace xServer.Core /// is not listening. public delegate void ServerStateEventHandler(Server s, bool listening); + /// + /// Fires an event that informs subscribers that the server has changed state. + /// + /// private void OnServerState(bool listening) { if (ServerState != null) @@ -46,8 +50,7 @@ namespace xServer.Core public delegate void ClientStateEventHandler(Server s, Client c, bool connected); /// - /// Fires an event that informs subscribers that the a packet has been - /// received from the client. + /// Fires an event that informs subscribers that a client has changed state. /// /// private void OnClientState(Client c, bool connected) From 978b64b564817fbda4ea35694b3248b7cdb0d4dd Mon Sep 17 00:00:00 2001 From: yankejustin Date: Fri, 29 May 2015 20:02:06 -0400 Subject: [PATCH 5/7] Final tweaks to the server documentation --- Server/Core/Server.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Server/Core/Server.cs b/Server/Core/Server.cs index 65db61f9..8ae3a121 100644 --- a/Server/Core/Server.cs +++ b/Server/Core/Server.cs @@ -27,7 +27,8 @@ namespace xServer.Core /// /// Fires an event that informs subscribers that the server has changed state. /// - /// + /// True if the server is listening; False if the server + /// is not listening. private void OnServerState(bool listening) { if (ServerState != null) @@ -52,7 +53,9 @@ namespace xServer.Core /// /// Fires an event that informs subscribers that a client has changed state. /// - /// + /// + /// True if the client is connected; False if the client + /// is not connected. private void OnClientState(Client c, bool connected) { if (ClientState != null) @@ -79,7 +82,7 @@ namespace xServer.Core /// Fires an event that informs subscribers that the a packet has been /// received from the client. /// - /// + /// The packet that has been received by the server from the client. private void OnClientRead(Client c, IPacket packet) { if (ClientRead != null) From a25416442471710208b8434870949e20d4ca4a34 Mon Sep 17 00:00:00 2001 From: yankejustin Date: Fri, 29 May 2015 20:06:25 -0400 Subject: [PATCH 6/7] Documented OnClientState for Server's client Added documentation for the Server's client's OnClientState. --- Server/Core/Client.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Server/Core/Client.cs b/Server/Core/Client.cs index ff70fff9..9942b061 100644 --- a/Server/Core/Client.cs +++ b/Server/Core/Client.cs @@ -28,6 +28,11 @@ namespace xServer.Core /// is not connected. public delegate void ClientStateEventHandler(Client s, bool connected); + /// + /// Fires an event that informs subscribers that the state of the client has changed. + /// + /// True if the client is connected; False if the client is + /// not connected. private void OnClientState(bool connected) { if (Connected == connected) return; From 0dc2bd7b6f8399fc738d20714f12df3fec76c9c7 Mon Sep 17 00:00:00 2001 From: yankejustin Date: Fri, 29 May 2015 20:16:45 -0400 Subject: [PATCH 7/7] Added documentation for the Client's client Added documentation for the Client's client object. --- Client/Core/Client.cs | 67 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/Client/Core/Client.cs b/Client/Core/Client.cs index e974cf0d..0f34871e 100644 --- a/Client/Core/Client.cs +++ b/Client/Core/Client.cs @@ -17,10 +17,24 @@ namespace xClient.Core { public class Client { + /// + /// Occurs as a result of an unrecoverable issue with the client. + /// public event ClientFailEventHandler ClientFail; + /// + /// Represents a method that will handle failure of the client. + /// + /// The client that has failed. + /// The exception containing information about the cause + /// of the client's failure. public delegate void ClientFailEventHandler(Client s, Exception ex); + /// + /// Fires an event that informs subscribers that the client has failed. + /// + /// The exception containing information about the cause + /// of the client's failure. private void OnClientFail(Exception ex) { if (ClientFail != null) @@ -29,10 +43,24 @@ namespace xClient.Core } } + /// + /// Occurs when the state of the client has changed. + /// public event ClientStateEventHandler ClientState; + /// + /// Represents a method that handles when the state of the client has changed. + /// + /// The client to update the state of. + /// True if the client is connected; False if the client + /// is not connected. public delegate void ClientStateEventHandler(Client s, bool connected); + /// + /// Fires an event that informs subscribers that the state of the client has changed. + /// + /// True if the client is connected; False if the client is + /// not connected. private void OnClientState(bool connected) { if (Connected == connected) return; @@ -44,10 +72,23 @@ namespace xClient.Core } } + /// + /// Occurs when a packet is received from the server. + /// public event ClientReadEventHandler ClientRead; + /// + /// Represents a method that will handle a packet from the server to the client. + /// + /// The client that is receiving the packet (from the server). + /// The packet that has been received by the client from the server. public delegate void ClientReadEventHandler(Client s, IPacket packet); + /// + /// Fires an event that informs subscribers that the a packet has been + /// received from the server to the client. + /// + /// private void OnClientRead(IPacket packet) { if (ClientRead != null) @@ -68,14 +109,23 @@ namespace xClient.Core } } + /// + /// The type of the packet received. + /// public enum ReceiveType { Header, Payload } + /// + /// A list of all the connected proxy clients that this client holds. + /// private List _proxyClients; + /// + /// Returns an array containing all of the proxy clients of this client. + /// public ReverseProxyClient[] ProxyClients { get { return _proxyClients.ToArray(); } @@ -89,6 +139,9 @@ namespace xClient.Core private Socket _handle; private int _typeIndex; + /// + /// The buffer for the client's incoming and outgoing packets. + /// private byte[] _buffer = new byte[MAX_PACKET_SIZE]; //receive info @@ -98,7 +151,9 @@ namespace xClient.Core private int _payloadLen; private ReceiveType _receiveState = ReceiveType.Header; - //Connection info + /// + /// Gets if the client is currently connected to a server. + /// public bool Connected { get; private set; } private const bool encryptionEnabled = true; @@ -108,6 +163,11 @@ namespace xClient.Core { } + /// + /// Attempts to connect to the specified host on the specified port. + /// + /// The host (or server) to connect to. + /// The port of the host. public void Connect(string host, ushort port) { try @@ -307,6 +367,11 @@ namespace xClient.Core } } + /// + /// Disconnect the client from the server, disconnect all proxies that + /// are held by this client, and dispose of other resources associated + /// with this client. + /// public void Disconnect() { OnClientState(false);