Exemplo n.º 1
0
        public bool LogOut(Socket client)
        {
            var c = ClientsSocket.First(p => p.ClientSocket == client);

            if (c != null)
            {
                ClientsSocket.Remove(c);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 public void Receive()
 {
     while (IsListen)
     {
         var client = ServerSocket.Accept();
         if (ClientsSocket.Count < MaxConnectionLength)
         {
             var c = new ClientEntity()
             {
                 ClientSocket = client, LastActiveTime = DateTime.Now
             };
             ClientsSocket.Add(c);
             Task.Run(() => { DoClientHandler?.Invoke(c); });
             //DoClientHandler?.Invoke(client);
         }
         else
         {
             client.Close();
         }
     }
 }