Esempio n. 1
0
        /// <summary>
        /// Un nouveau VIEWER de la simulation
        /// </summary>
        /// <param name="webSocket"></param>
        /// <returns></returns>
        public static async Task AddViewer(WebSocket webSocket)
        {
            // on en fait un vrai client
            OneDisplay client = new OneDisplay(webSocket);
            // on profite de faire le ménage au cas où
            List <OneDisplay> toRemove = new List <OneDisplay>();

            lock (lockListViewer)
            {
                foreach (OneDisplay o in AllViewer)
                {
                    if (o.MustRemove)
                    {
                        toRemove.Add(o);
                    }
                }
                AllViewer.Add(client);
            };
            foreach (OneDisplay o in toRemove)
            {
                RemoveViewer(o.ClientGuid);
            }
            Console.WriteLine($"#display: {AllViewer.Count}");
            // on se met à l'écoute des messages de ce client
            RefreshViewer();
            await client.WaitReceive();

            RemoveViewer(client.ClientGuid);
        }