private static void HandleClientThread()
        {
            while (!Handler.Shutdown.Token.IsCancellationRequested)
            {
                Context context;

                while (ContextQueue.Count == 0)
                {
                    Thread.Sleep(10);
                    if (Handler.Shutdown.IsCancellationRequested)
                    {
                        return;
                    }
                }

                if (!ContextQueue.TryDequeue(out context))
                {
                    continue;
                }

                lock (ContextMapping)
                {
                    WebSocketServer server = ContextMapping[context];
                    server.SetupContext(context);
                }

                lock (CurrentConnections){
                    CurrentConnections.Add(context);
                }
            }
        }
Example #2
0
        private static void HandleClientThread()
        {
            try
            {
                while (!cancellation.Token.IsCancellationRequested)
                {
                    Context context;

                    while (ContextQueue.Count == 0)
                    {
                        Thread.Sleep(10);
                        if (cancellation.Token.IsCancellationRequested)
                        {
                            return;
                        }
                    }

                    if (!ContextQueue.TryDequeue(out context))
                    {
                        continue;
                    }

                    context.Server.SetupContext(context);

                    lock (CurrentConnections){
                        CurrentConnections.Add(context);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Example #3
0
        private static void HandleClientThread()
        {
            while (true)
            {
                Context context;

                while (ContextQueue.Count == 0)
                {
                    Thread.Sleep(10);
                }

                if (!ContextQueue.TryDequeue(out context))
                {
                    continue;
                }

                lock (ContextMapping)
                {
                    WebSocketServer client = ContextMapping[context];
                    client.SetupContext(context);
                }

                lock (CurrentConnections){
                    CurrentConnections.Add(context);
                }
            }
        }