public multipleMapItemReply GetMapItems(ulong regionHandle, GridItemType gridItemType) { multipleMapItemReply reply = m_localService.GetMapItems(regionHandle, gridItemType); if (reply.items.Count == 0) { reply = m_remoteService.GetMapItems(regionHandle, gridItemType); } return(reply); }
public virtual multipleMapItemReply GetMapItems(ulong regionHandle, GridItemType gridItemType) { multipleMapItemReply allItems = new multipleMapItemReply(); if (gridItemType == GridItemType.AgentLocations) //Grid server only cares about agent locations { int X, Y; Util.UlongToInts(regionHandle, out X, out Y); //Get the items and send them back allItems.items[regionHandle] = GetItems(X, Y, regionHandle); } return(allItems); }
public multipleMapItemReply GetMapItems(ulong regionHandle, GridItemType gridItemType) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["REGIONHANDLE"] = regionHandle; sendData["GRIDITEMTYPE"] = (int)gridItemType; sendData["METHOD"] = "getmapitems"; string reqString = WebUtils.BuildQueryString(sendData); try { List <string> serverURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("GridServerURI"); foreach (string m_ServerURI in serverURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); if (replyData != null) { multipleMapItemReply items = new multipleMapItemReply(); if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure")) { return(items); } items = new multipleMapItemReply((replyData["MapItems"]) as Dictionary <string, object>); // Success return(items); } else { m_log.DebugFormat("[GRID CONNECTOR]: GetMapItems {0} received null response", regionHandle); } } } } catch (Exception e) { m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting server: {0}", e.Message); } return(null); }
private byte[] GetMapItems(Dictionary <string, object> request) { Dictionary <string, object> result = new Dictionary <string, object>(); ulong regionHandle = ulong.Parse(request["REGIONHANDLE"].ToString()); GridItemType gridItemType = (GridItemType)int.Parse(request["GRIDITEMTYPE"].ToString()); multipleMapItemReply items = m_GridService.GetMapItems(regionHandle, gridItemType); result["MapItems"] = items.ToKeyValuePairs(); string xmlString = WebUtils.BuildXmlResponse(result); UTF8Encoding encoding = new UTF8Encoding(); return(encoding.GetBytes(xmlString)); }
void GetMapItems() { itemRequesterIsRunning = true; while (true) { MapItemRequester item; if (!m_itemsToRequest.TryDequeue(out item)) { break; // Nothing in the queue } 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.remoteClient.AllScopeIDs, item.regionhandle, (GridItemType)item.itemtype); if (allmapitems.items.Count == 0) // nothing to see here... { 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); // 3 mins } } } if (mapitems.Count > 0) // .if (mapitems != null) { item.remoteClient.SendMapItemReply(mapitems.ToArray(), item.itemtype, item.flags); } Thread.Sleep(5); } itemRequesterIsRunning = false; }
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); }