Пример #1
0
        static Client()
        {
            clientQueueThread = new Thread(() =>
            {
                AutoResetEvent waitEvent = new AutoResetEvent(false);
                while (true)
                {
                    DateTime? next;
                    lock (clientQueueLock)
                    {
                        if (clientQueue.Count == 0)
                            next = null;
                        else
                            next = clientQueue.Peek().lastRequest;
                    }

                    if (next == null)
                    {
                        clientQueueResetEvent.WaitOne();
                        continue;
                    }

                    TimeSpan waitTime = next.Value.Add(TimeSpan.FromSeconds(31)).Subtract(DateTime.Now);
                    if (waitTime > TimeSpan.Zero)
                        waitEvent.WaitOne(waitTime);

                    Client client;
                    lock (clientQueueLock)
                        client = clientQueue.Dequeue();

                    if (DateTime.Now.Subtract(client.lastRequest) > TimeSpan.FromSeconds(30))
                        SpotifireServer.Instance.MessageClients(c => c.Ping(), client);
                }

            });
            clientQueueThread.IsBackground = true;
            clientQueueThread.Start();
        }
Пример #2
0
 private Client(ISpotifireClient client)
 {
     this.client = client;
 }
Пример #3
0
 private Client(ISpotifireClient client)
 {
     this.client = client;
 }