Add more & correct comments.

This commit is contained in:
Starbeamrainbowlabs 2016-10-16 17:30:13 +01:00
parent fe97d617ce
commit d4701f963d
1 changed files with 29 additions and 3 deletions

View File

@ -25,7 +25,7 @@ namespace PixelHub.Server
public List<PixelBot> ConnectedBots = new List<PixelBot>();
/// <summary>
/// Whether the Hull Pixelbot serve is currently active and listening.
/// Whether the Hull Pixelbot server is currently active and listening.
/// </summary>
public bool Active { get; private set; } = false;
/// <summary>
@ -33,7 +33,7 @@ namespace PixelHub.Server
/// </summary>
/// <remarks>
/// You can only set this Property with generating an exception if the server
/// hasn't already been started with List().
/// hasn't already been started with Listen().
/// </remarks>
public IPAddress BindAddress
{
@ -46,7 +46,13 @@ namespace PixelHub.Server
bindAddress = value;
}
}
/// <summary>
/// The port number that the PixelHb is (or should be) listening on.
/// </summary>
/// <remarks>
/// You can only set this Property with generating an exception if the server
/// hasn't already been started with Listen().
/// </remarks>
public int Port
{
get {
@ -58,6 +64,10 @@ namespace PixelHub.Server
port = value;
}
}
/// <summary>
/// Squashes the BindAddress and the port number together to form the endpoint that the server
/// is (or should be) listening on.
/// </summary>
public IPEndPoint Endpoint
{
get {
@ -65,15 +75,27 @@ namespace PixelHub.Server
}
}
/// <summary>
/// Creates a new Pixelhub instance.
/// </summary>
/// <param name="inPort">The port to listen on.</param>
/// <param name="inLogger">The TextWriter to send log messages to.</param>
public PixelHub(int inPort, TextWriter inLogger)
{
Port = inPort;
logger = inLogger;
}
/// <summary>
/// Creates a new Pixelhub instance.
/// </summary>
/// <param name="inPort">The port to listen on.</param>
public PixelHub(int inPort) : this(inPort, Console.Out)
{
}
/// <summary>
/// Starts the PixelHub server and begins listening for connections.
/// </summary>
public async Task Listen()
{
server = new TcpListener(Endpoint);
@ -88,6 +110,10 @@ namespace PixelHub.Server
//Active = false;
}
/// <summary>
/// Handles a single connection.
/// </summary>
/// <param name="client">The TcpClient connection to handle.</param>
private async Task Handle(TcpClient client)
{
logger.WriteLine("Accepted connection from {0}.", client.Client.RemoteEndPoint);