aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs68
1 files changed, 36 insertions, 32 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
index 754ec8b..b866e49 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs
@@ -56,10 +56,7 @@ namespace OpenSim.Region.ClientStack.Linden
56 private Scene m_scene; 56 private Scene m_scene;
57 private bool m_Enabled = true; 57 private bool m_Enabled = true;
58 private string m_URL; 58 private string m_URL;
59
60 private string m_URL2; 59 private string m_URL2;
61 private string m_RedirectURL = null;
62 private string m_RedirectURL2 = null;
63 60
64 class APollRequest 61 class APollRequest
65 { 62 {
@@ -81,12 +78,11 @@ namespace OpenSim.Region.ClientStack.Linden
81 private IAssetService m_assetService = null; 78 private IAssetService m_assetService = null;
82 79
83 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>(); 80 private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
81 private Dictionary<UUID, string> m_capsDict2 = new Dictionary<UUID, string>();
84 private static Thread[] m_workerThreads = null; 82 private static Thread[] m_workerThreads = null;
85 private static int m_NumberScenes = 0; 83 private static int m_NumberScenes = 0;
86 private static BlockingCollection<APollRequest> m_queue = new BlockingCollection<APollRequest>(); 84 private static BlockingCollection<APollRequest> m_queue = new BlockingCollection<APollRequest>();
87 85
88 private Dictionary<UUID, PollServiceMeshEventArgs> m_pollservices = new Dictionary<UUID, PollServiceMeshEventArgs>();
89
90 #region Region Module interfaceBase Members 86 #region Region Module interfaceBase Members
91 87
92 public Type ReplaceableInterface 88 public Type ReplaceableInterface
@@ -103,19 +99,12 @@ namespace OpenSim.Region.ClientStack.Linden
103 m_URL = config.GetString("Cap_GetMesh", string.Empty); 99 m_URL = config.GetString("Cap_GetMesh", string.Empty);
104 // Cap doesn't exist 100 // Cap doesn't exist
105 if (m_URL != string.Empty) 101 if (m_URL != string.Empty)
106 {
107 m_Enabled = true; 102 m_Enabled = true;
108 m_RedirectURL = config.GetString("GetMeshRedirectURL");
109 }
110 103
111 m_URL2 = config.GetString("Cap_GetMesh2", string.Empty); 104 m_URL2 = config.GetString("Cap_GetMesh2", string.Empty);
112 // Cap doesn't exist 105 // Cap doesn't exist
113 if (m_URL2 != string.Empty) 106 if (m_URL2 != string.Empty)
114 {
115 m_Enabled = true; 107 m_Enabled = true;
116
117 m_RedirectURL2 = config.GetString("GetMesh2RedirectURL");
118 }
119 } 108 }
120 109
121 public void AddRegion(Scene pScene) 110 public void AddRegion(Scene pScene)
@@ -146,6 +135,12 @@ namespace OpenSim.Region.ClientStack.Linden
146 { 135 {
147 m_assetService = m_scene.RequestModuleInterface<IAssetService>(); 136 m_assetService = m_scene.RequestModuleInterface<IAssetService>();
148 // We'll reuse the same handler for all requests. 137 // We'll reuse the same handler for all requests.
138 if(m_assetService == null)
139 {
140 m_Enabled = false;
141 return;
142 }
143
149 m_getMeshHandler = new GetMeshHandler(m_assetService); 144 m_getMeshHandler = new GetMeshHandler(m_assetService);
150 } 145 }
151 146
@@ -355,49 +350,58 @@ namespace OpenSim.Region.ClientStack.Linden
355 350
356 public void RegisterCaps(UUID agentID, Caps caps) 351 public void RegisterCaps(UUID agentID, Caps caps)
357 { 352 {
358// UUID capID = UUID.Random(); 353 string hostName = m_scene.RegionInfo.ExternalHostName;
354 uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
355 string protocol = "http";
356 if (MainServer.Instance.UseSSL)
357 {
358 hostName = MainServer.Instance.SSLCommonName;
359 port = MainServer.Instance.SSLPort;
360 protocol = "https";
361 }
362
359 if (m_URL == "localhost") 363 if (m_URL == "localhost")
360 { 364 {
361 string capUrl = "/CAPS/" + UUID.Random() + "/"; 365 string capUrl = "/CAPS/" + UUID.Random() + "/";
362 366
363 // Register this as a poll service 367 // Register this as a poll service
364 PollServiceMeshEventArgs args = new PollServiceMeshEventArgs(capUrl, agentID, m_scene); 368 PollServiceMeshEventArgs args = new PollServiceMeshEventArgs(capUrl, agentID, m_scene);
365
366 args.Type = PollServiceEventArgs.EventType.Mesh; 369 args.Type = PollServiceEventArgs.EventType.Mesh;
367 MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); 370 MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args);
368 371
369 string hostName = m_scene.RegionInfo.ExternalHostName;
370 uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
371 string protocol = "http";
372
373 if (MainServer.Instance.UseSSL)
374 {
375 hostName = MainServer.Instance.SSLCommonName;
376 port = MainServer.Instance.SSLPort;
377 protocol = "https";
378 }
379 caps.RegisterHandler("GetMesh", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); 372 caps.RegisterHandler("GetMesh", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl));
380 m_pollservices[agentID] = args;
381 m_capsDict[agentID] = capUrl; 373 m_capsDict[agentID] = capUrl;
382 } 374 }
383 else 375 else if (m_URL != string.Empty)
384 {
385 caps.RegisterHandler("GetMesh", m_URL); 376 caps.RegisterHandler("GetMesh", m_URL);
377
378 if (m_URL2 == "localhost")
379 {
380 string capUrl = "/CAPS/" + UUID.Random() + "/";
381
382 // Register this as a poll service
383 PollServiceMeshEventArgs args = new PollServiceMeshEventArgs(capUrl, agentID, m_scene);
384 args.Type = PollServiceEventArgs.EventType.Mesh;
385 MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args);
386 caps.RegisterHandler("GetMesh2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl));
387 m_capsDict2[agentID] = capUrl;
386 } 388 }
389 else if(m_URL2 != string.Empty)
390 caps.RegisterHandler("GetMesh2", m_URL2);
387 } 391 }
388 392
389 private void DeregisterCaps(UUID agentID, Caps caps) 393 private void DeregisterCaps(UUID agentID, Caps caps)
390 { 394 {
391 string capUrl; 395 string capUrl;
392 PollServiceMeshEventArgs args;
393 if (m_capsDict.TryGetValue(agentID, out capUrl)) 396 if (m_capsDict.TryGetValue(agentID, out capUrl))
394 { 397 {
395 MainServer.Instance.RemoveHTTPHandler("", capUrl); 398 MainServer.Instance.RemovePollServiceHTTPHandler("", capUrl);
396 m_capsDict.Remove(agentID); 399 m_capsDict.Remove(agentID);
397 } 400 }
398 if (m_pollservices.TryGetValue(agentID, out args)) 401 if (m_capsDict2.TryGetValue(agentID, out capUrl))
399 { 402 {
400 m_pollservices.Remove(agentID); 403 MainServer.Instance.RemovePollServiceHTTPHandler("", capUrl);
404 m_capsDict2.Remove(agentID);
401 } 405 }
402 } 406 }
403 } 407 }