From 0dc2bd7b6f8399fc738d20714f12df3fec76c9c7 Mon Sep 17 00:00:00 2001 From: yankejustin Date: Fri, 29 May 2015 20:16:45 -0400 Subject: [PATCH] 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);