Example #1
0
        private void GetMapItems()
        {
            itemRequesterIsRunning = true;
            while (true)
            {
                MapItemRequester item = null;
                if (m_itemsToRequest.Count > 0)
                {
                    item = m_itemsToRequest.Dequeue();
                }
                if (item == null)
                {
                    break; //Nothing in the queue
                }
                List <mapItemReply> mapitems;
                if (!m_mapItemCache.TryGetValue(item.regionhandle, out mapitems)) //try again, might have gotten picked up by this already
                {
                    multipleMapItemReply allmapitems = m_scene.GridService.GetMapItems(item.regionhandle, (GridItemType)item.itemtype);

                    if (allmapitems == null)
                    {
                        continue;
                    }
                    //Send out the update
                    if (allmapitems.items.ContainsKey(item.regionhandle))
                    {
                        mapitems = allmapitems.items[item.regionhandle];

                        //Update the cache
                        foreach (KeyValuePair <ulong, List <mapItemReply> > kvp in allmapitems.items)
                        {
                            m_mapItemCache.AddOrUpdate(kvp.Key, kvp.Value, 3 * 60); //5 mins
                        }
                    }
                }

                if (mapitems != null)
                {
                    item.remoteClient.SendMapItemReply(mapitems.ToArray(), item.itemtype, item.flags);
                }
                Thread.Sleep(5);
            }
            itemRequesterIsRunning = false;
        }
Example #2
0
        private bool GetMapItems()
        {
            itemRequesterIsRunning = true;
            for (int i = 0; i < m_itemsToRequest.Count; i++)
            {
                MapItemRequester item = m_itemsToRequest[i];
                if (item == null)
                {
                    continue;
                }
                List <mapItemReply> mapitems = new List <mapItemReply>();
                if (!m_mapItemCache.TryGetValue(item.regionhandle, out mapitems)) //try again, might have gotten picked up by this already
                {
                    multipleMapItemReply allmapitems = m_scene.GridService.GetMapItems(item.regionhandle, (OpenMetaverse.GridItemType)item.itemtype);

                    if (allmapitems == null)
                    {
                        continue;
                    }
                    //Send out the update
                    if (allmapitems.items.ContainsKey(item.regionhandle))
                    {
                        mapitems = allmapitems.items[item.regionhandle];
                        item.remoteClient.SendMapItemReply(mapitems.ToArray(), item.itemtype, 0);

                        //Update the cache
                        foreach (KeyValuePair <ulong, List <mapItemReply> > kvp in allmapitems.items)
                        {
                            m_mapItemCache.AddOrUpdate(kvp.Key, kvp.Value, 30 * 60); //30 mins
                        }
                    }
                }
            }
            itemRequesterIsRunning = false;
            return(true);
        }