Beispiel #1
0
        public static async Task AddCockpit(WebSocket webSocket)
        {
            OneCockpit        client   = new OneCockpit(webSocket);
            List <OneCockpit> toRemove = new List <OneCockpit>();

            lock (lockListCockpit)
            {
                foreach (OneCockpit o in AllCockpit)
                {
                    if (o.MustRemove)
                    {
                        toRemove.Add(o);
                    }
                }
                AllCockpit.Add(client);
            };
            foreach (OneCockpit o in toRemove)
            {
                RemoveCockpit(o.ClientGuid);
            }
            Console.WriteLine($"#cockpit: {AllCockpit.Count}");
            await client.WaitReceive();

            RemoveCockpit(client.ClientGuid);
        }
Beispiel #2
0
 public static void RemoveCockpit(Guid guid)
 {
     OneCockpit toRemove = null;
     lock (lockListViewer)
     {
         foreach (OneCockpit o in AllCockpit)
         {
             if (o.ClientGuid == guid)
             {
                 toRemove = o;
                 break;
             }
         }
         if (toRemove != null)
             AllCockpit.Remove(toRemove);
     }
     Console.WriteLine($"#cockpit: {AllCockpit.Count}");
 }