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);
                }
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
                }
            }
        }