/// <summary> /// Event handler for when a client connects. /// Makes sure there is enough room on the server before allowing it to proceed. /// if successful it starts the client read/write threads. /// </summary> /// <param name="sender">Client that is connecting</param> /// <param name="e">the handshake (contains its name)</param> public void Client_Connected(Client sender, GenericEventArgs<String> e) { if (!Interlocked.Equals(this.connectedClients, this.maxClients)) { Interlocked.Increment(ref this.connectedClients); this.On_Client_Sending += sender.Client_Sending; //subscribe to the send to all event sender.StartUp(); Console.WriteLine("Client connected: {0}", sender.Name); } else { sender.Close_Connection(); Console.WriteLine("Client refused, server full: {0}", sender.Name); } }