예제 #1
0
 // 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);
         }
     });
 }
예제 #2
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);
        }
예제 #3
0
 // Constructor just assigns the client
 public ClientInfo(ForeignClient client)
 {
     this.client = client;
 }