Exemple #1
0
        // Called when a client connects, creates a new client object
        // It is not the same as the ClientInbound in ForeignClient.cs - that is where client sent messages are handled
        private static void ClientInbound(IAsyncResult result)
        {
            ForeignClient newClient = new ForeignClient(socket.EndAccept(result));

            if (ClientManager.maxClients < ClientManager.allClients.Count)
            {
                newClient.SendMessage("Server has reached full capacity. Please retry later.");
                newClient.Disconnect();
                Server.AddMessage("{" + newClient.IP + "} " + newClient.name + " tried to join but the server is full.");
                return;
            }

            socket.BeginAccept(new AsyncCallback(ClientInbound), null);
        }