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>(); public List<PixelBot> ConnectedBots = new List<PixelBot>();
/// <summary> /// <summary>
/// Whether the Hull Pixelbot serve is currently active and listening. /// Whether the Hull Pixelbot server is currently active and listening.
/// </summary> /// </summary>
public bool Active { get; private set; } = false; public bool Active { get; private set; } = false;
/// <summary> /// <summary>
@ -33,7 +33,7 @@ namespace PixelHub.Server
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// You can only set this Property with generating an exception if the server /// 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> /// </remarks>
public IPAddress BindAddress public IPAddress BindAddress
{ {
@ -46,7 +46,13 @@ namespace PixelHub.Server
bindAddress = value; 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 public int Port
{ {
get { get {
@ -58,6 +64,10 @@ namespace PixelHub.Server
port = value; 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 public IPEndPoint Endpoint
{ {
get { 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) public PixelHub(int inPort, TextWriter inLogger)
{ {
Port = inPort; Port = inPort;
logger = inLogger; 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) public PixelHub(int inPort) : this(inPort, Console.Out)
{ {
} }
/// <summary>
/// Starts the PixelHub server and begins listening for connections.
/// </summary>
public async Task Listen() public async Task Listen()
{ {
server = new TcpListener(Endpoint); server = new TcpListener(Endpoint);
@ -88,6 +110,10 @@ namespace PixelHub.Server
//Active = false; //Active = false;
} }
/// <summary>
/// Handles a single connection.
/// </summary>
/// <param name="client">The TcpClient connection to handle.</param>
private async Task Handle(TcpClient client) private async Task Handle(TcpClient client)
{ {
logger.WriteLine("Accepted connection from {0}.", client.Client.RemoteEndPoint); logger.WriteLine("Accepted connection from {0}.", client.Client.RemoteEndPoint);