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 @@ public class Server 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 @@ private void OnServerState(bool listening) } } + /// + /// 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 @@ private void OnClientState(Client c, bool connected) } } + /// + /// 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 @@ private void OnClientWrite(Client c, IPacket packet, long length, byte[] rawData 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; }