// Passes on a message from a client to all other clients public static void PassOnMessage(string message, ForeignClient from) { allClients.ForEach(delegate(ForeignClient client) { if (client != from) { client.SendMessage(message); } }); }
// 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); }
// Constructor just assigns the client public ClientInfo(ForeignClient client) { this.client = client; }