/// <summary>
        /// Tries to implement the Get [] semantics, but it cuts corners.
        /// Specifically, it gets all friendships even if they weren't accepted yet.
        /// </summary>
        /// <param name="fields"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public FriendsData[] GetFriends(string userID)
        {
            List <FriendsData> lst = m_Data.FindAll(fdata =>
            {
                return(fdata.PrincipalID == userID.ToString());
            });

            if (lst != null)
            {
                lst.ForEach(f =>
                {
                    FriendsData f2 = m_Data.Find(candidateF2 => f.Friend == candidateF2.PrincipalID);
                    if (f2 != null)
                    {
                        f.Data["TheirFlags"] = f2.Data["Flags"];
                    }

//                    m_log.DebugFormat(
//                        "[NULL FRIENDS DATA]: Got {0} {1} {2} for {3}",
//                        f.Friend, f.Data["Flags"], f2 != null ? f.Data["TheirFlags"] : "not found!", f.PrincipalID);
                });

//                m_log.DebugFormat("[NULL FRIENDS DATA]: Got {0} friends for {1}", lst.Count, userID);

                return(lst.ToArray());
            }

            return(new FriendsData[0]);
        }
        private void CheckLongPollThreads()
        {
            // The only purpose of this thread is to check the EQs for events.
            // If there are events, that thread will be placed in the "ready-to-serve" queue, m_requests.
            // If there are no events, that thread will be back to its "waiting" queue, m_longPollRequests.
            // All other types of tasks (Inventory handlers, http-in, etc) don't have the long-poll nature,
            // so if they aren't ready to be served by a worker thread (no events), they are placed
            // directly back in the "ready-to-serve" queue by the worker thread.
            while (IsRunning)
            {
                Thread.Sleep(500);
                Watchdog.UpdateThread();

//                List<PollServiceHttpRequest> not_ready = new List<PollServiceHttpRequest>();
                if (m_longPollRequests.Count > 0 && IsRunning)
                {
                    List <PollServiceHttpRequest> ready = m_longPollRequests.FindAll(req =>
                                                                                     (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id) ||    // there are events in this EQ
                                                                                      (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) // no events, but timeout
                                                                                     );

                    ready.ForEach(req =>
                    {
                        m_requests.Enqueue(req);
                        m_longPollRequests.Remove(req);
                    });
                }
            }
        }