aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorTeravus Ovares2008-10-06 18:29:25 +0000
committerTeravus Ovares2008-10-06 18:29:25 +0000
commit600721d4809c30985c1999d13c940d31f708cc26 (patch)
tree9fba3226cfc49cb9eb593e95cd12f1bd1faf1264 /OpenSim/Region/Environment
parent* restore Header.Resent field setting for resent packets (diff)
downloadopensim-SC-600721d4809c30985c1999d13c940d31f708cc26.zip
opensim-SC-600721d4809c30985c1999d13c940d31f708cc26.tar.gz
opensim-SC-600721d4809c30985c1999d13c940d31f708cc26.tar.bz2
opensim-SC-600721d4809c30985c1999d13c940d31f708cc26.tar.xz
* Made Mapitems more failure friendly
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs96
1 files changed, 86 insertions, 10 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
index d40574a..e68bd65 100644
--- a/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/WorldMap/WorldMapModule.cs
@@ -66,6 +66,8 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
66 private int cachedTime = 0; 66 private int cachedTime = 0;
67 private byte[] myMapImageJPEG; 67 private byte[] myMapImageJPEG;
68 private bool m_Enabled = false; 68 private bool m_Enabled = false;
69 private Dictionary<UUID, MapRequestState> m_openRequests = new Dictionary<UUID, MapRequestState>();
70
69 71
70 //private int CacheRegionsDistance = 256; 72 //private int CacheRegionsDistance = 256;
71 73
@@ -297,11 +299,51 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
297 if (mreg != null) 299 if (mreg != null)
298 { 300 {
299 string httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString(); 301 string httpserver = "http://" + mreg.ExternalEndPoint.Address.ToString() + ":" + mreg.HttpPort + "/MAP/MapItems/" + regionhandle.ToString();
300 List<mapItemReply> returnitems = new List<mapItemReply>(); 302
301 LLSDMap ramap = RequestMapItems(httpserver); 303 RequestMapItems(httpserver,remoteClient.AgentId,flags,EstateID,godlike,itemtype,regionhandle);
302 if (ramap.ContainsKey(itemtype.ToString())) 304
305 }
306 }
307 }
308
309 }
310
311 public delegate LLSDMap RequestMapItemsDelegate(string httpserver, UUID id, uint flags,
312 uint EstateID, bool godlike, uint itemtype, ulong regionhandle);
313
314 private void RequestMapItemsCompleted(IAsyncResult iar)
315 {
316
317 RequestMapItemsDelegate icon = (RequestMapItemsDelegate)iar.AsyncState;
318 LLSDMap response = icon.EndInvoke(iar);
319
320
321
322 UUID requestID = response["requestID"].AsUUID();
323
324 if (requestID != UUID.Zero)
325 {
326 MapRequestState mrs = new MapRequestState();
327 mrs.agentID = UUID.Zero;
328 lock (m_openRequests)
329 {
330 if (m_openRequests.ContainsKey(requestID))
331 {
332 mrs = m_openRequests[requestID];
333 m_openRequests.Remove(requestID);
334 }
335 }
336
337 if (mrs.agentID != UUID.Zero)
338 {
339 ScenePresence av = null;
340 m_scene.TryGetAvatar(mrs.agentID, out av);
341 if (av != null)
342 {
343 if (response.ContainsKey(mrs.itemtype.ToString()))
303 { 344 {
304 LLSDArray itemarray = (LLSDArray)ramap[itemtype.ToString()]; 345 List<mapItemReply> returnitems = new List<mapItemReply>();
346 LLSDArray itemarray = (LLSDArray)response[mrs.itemtype.ToString()];
305 for (int i = 0; i < itemarray.Count; i++) 347 for (int i = 0; i < itemarray.Count; i++)
306 { 348 {
307 LLSDMap mapitem = (LLSDMap)itemarray[i]; 349 LLSDMap mapitem = (LLSDMap)itemarray[i];
@@ -314,17 +356,38 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
314 mi.name = mapitem["Name"].AsString(); 356 mi.name = mapitem["Name"].AsString();
315 returnitems.Add(mi); 357 returnitems.Add(mi);
316 } 358 }
317 359 av.ControllingClient.SendMapItemReply(returnitems.ToArray(), mrs.itemtype, mrs.flags);
318 } 360 }
319 remoteClient.SendMapItemReply(returnitems.ToArray(), itemtype, flags); 361
320 } 362 }
363
321 } 364 }
322 } 365 }
323
324 } 366 }
325 367 public void RequestMapItems(string httpserver, UUID id, uint flags,
326 private LLSDMap RequestMapItems(string httpserver) 368 uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
327 { 369 {
370 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
371 RequestMapItemsDelegate d = RequestMapItemsAsync;
372 d.BeginInvoke(httpserver, id,flags,EstateID,godlike,itemtype,regionhandle,RequestMapItemsCompleted, d);
373 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
374 }
375 private LLSDMap RequestMapItemsAsync(string httpserver, UUID id, uint flags,
376 uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
377 {
378 UUID requestID = UUID.Random();
379
380 MapRequestState mrs = new MapRequestState();
381 mrs.agentID = id;
382 mrs.EstateID = EstateID;
383 mrs.flags = flags;
384 mrs.godlike = godlike;
385 mrs.itemtype=itemtype;
386 mrs.regionhandle = regionhandle;
387
388 lock (m_openRequests)
389 m_openRequests.Add(requestID, mrs);
390
328 WebRequest mapitemsrequest = WebRequest.Create(httpserver); 391 WebRequest mapitemsrequest = WebRequest.Create(httpserver);
329 mapitemsrequest.Method = "POST"; 392 mapitemsrequest.Method = "POST";
330 mapitemsrequest.ContentType = "application/xml+llsd"; 393 mapitemsrequest.ContentType = "application/xml+llsd";
@@ -335,6 +398,8 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
335 398
336 byte[] buffer = LLSDParser.SerializeXmlBytes(LLSDofRAMap); 399 byte[] buffer = LLSDParser.SerializeXmlBytes(LLSDofRAMap);
337 LLSDMap responseMap = new LLSDMap(); 400 LLSDMap responseMap = new LLSDMap();
401 responseMap["requestID"] = LLSD.FromUUID(requestID);
402
338 Stream os = null; 403 Stream os = null;
339 try 404 try
340 { // send the Post 405 { // send the Post
@@ -381,6 +446,7 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
381 rezResponse = LLSDParser.DeserializeXml(response_mapItems_reply); 446 rezResponse = LLSDParser.DeserializeXml(response_mapItems_reply);
382 447
383 responseMap = (LLSDMap)rezResponse; 448 responseMap = (LLSDMap)rezResponse;
449 responseMap["requestID"] = LLSD.FromUUID(requestID);
384 } 450 }
385 catch (Exception ex) 451 catch (Exception ex)
386 { 452 {
@@ -590,5 +656,15 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
590 return responsemap; 656 return responsemap;
591 } 657 }
592 } 658 }
593 659 public struct MapRequestState
660 {
661 public UUID agentID;
662 public uint flags;
663 public uint EstateID;
664 public bool godlike;
665 public uint itemtype;
666 public ulong regionhandle;
667 }
668
669
594} 670}