diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Scripting')
5 files changed, 336 insertions, 268 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index a676971..0276267 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -42,6 +42,7 @@ using OpenSim.Framework.Servers.HttpServer; | |||
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using Mono.Addins; | 44 | using Mono.Addins; |
45 | using Amib.Threading; | ||
45 | 46 | ||
46 | /***************************************************** | 47 | /***************************************************** |
47 | * | 48 | * |
@@ -102,6 +103,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
102 | private Dictionary<UUID, HttpRequestClass> m_pendingRequests; | 103 | private Dictionary<UUID, HttpRequestClass> m_pendingRequests; |
103 | private Scene m_scene; | 104 | private Scene m_scene; |
104 | // private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); | 105 | // private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>(); |
106 | public static SmartThreadPool ThreadPool = null; | ||
105 | 107 | ||
106 | public HttpRequestModule() | 108 | public HttpRequestModule() |
107 | { | 109 | { |
@@ -279,7 +281,30 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
279 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); | 281 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); |
280 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); | 282 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); |
281 | 283 | ||
284 | int maxThreads = 50; | ||
285 | |||
286 | IConfig httpConfig = config.Configs["HttpRequestModule"]; | ||
287 | if (httpConfig != null) | ||
288 | { | ||
289 | maxThreads = httpConfig.GetInt("MaxPoolThreads", maxThreads); | ||
290 | } | ||
291 | |||
282 | m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); | 292 | m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); |
293 | |||
294 | // First instance sets this up for all sims | ||
295 | if (ThreadPool == null) | ||
296 | { | ||
297 | STPStartInfo startInfo = new STPStartInfo(); | ||
298 | startInfo.IdleTimeout = 20000; | ||
299 | startInfo.MaxWorkerThreads = maxThreads; | ||
300 | startInfo.MinWorkerThreads = 5; | ||
301 | startInfo.ThreadPriority = ThreadPriority.BelowNormal; | ||
302 | startInfo.StartSuspended = true; | ||
303 | |||
304 | ThreadPool = new SmartThreadPool(startInfo); | ||
305 | |||
306 | ThreadPool.Start(); | ||
307 | } | ||
283 | } | 308 | } |
284 | 309 | ||
285 | public void AddRegion(Scene scene) | 310 | public void AddRegion(Scene scene) |
@@ -340,7 +365,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
340 | public string HttpMIMEType = "text/plain;charset=utf-8"; | 365 | public string HttpMIMEType = "text/plain;charset=utf-8"; |
341 | public int HttpTimeout; | 366 | public int HttpTimeout; |
342 | public bool HttpVerifyCert = true; | 367 | public bool HttpVerifyCert = true; |
343 | private Thread httpThread; | 368 | public IWorkItemResult WorkItem = null; |
344 | 369 | ||
345 | // Request info | 370 | // Request info |
346 | private UUID _itemID; | 371 | private UUID _itemID; |
@@ -374,12 +399,16 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
374 | 399 | ||
375 | public void Process() | 400 | public void Process() |
376 | { | 401 | { |
377 | httpThread = new Thread(SendRequest); | ||
378 | httpThread.Name = "HttpRequestThread"; | ||
379 | httpThread.Priority = ThreadPriority.BelowNormal; | ||
380 | httpThread.IsBackground = true; | ||
381 | _finished = false; | 402 | _finished = false; |
382 | httpThread.Start(); | 403 | |
404 | lock (HttpRequestModule.ThreadPool) | ||
405 | WorkItem = HttpRequestModule.ThreadPool.QueueWorkItem(new WorkItemCallback(StpSendWrapper), null); | ||
406 | } | ||
407 | |||
408 | private object StpSendWrapper(object o) | ||
409 | { | ||
410 | SendRequest(); | ||
411 | return null; | ||
383 | } | 412 | } |
384 | 413 | ||
385 | /* | 414 | /* |
@@ -398,6 +427,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
398 | try | 427 | try |
399 | { | 428 | { |
400 | Request = (HttpWebRequest) WebRequest.Create(Url); | 429 | Request = (HttpWebRequest) WebRequest.Create(Url); |
430 | |||
431 | //This works around some buggy HTTP Servers like Lighttpd | ||
432 | Request.ServicePoint.Expect100Continue = false; | ||
433 | |||
401 | Request.Method = HttpMethod; | 434 | Request.Method = HttpMethod; |
402 | Request.ContentType = HttpMIMEType; | 435 | Request.ContentType = HttpMIMEType; |
403 | 436 | ||
@@ -405,13 +438,8 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
405 | { | 438 | { |
406 | // We could hijack Connection Group Name to identify | 439 | // We could hijack Connection Group Name to identify |
407 | // a desired security exception. But at the moment we'll use a dummy header instead. | 440 | // a desired security exception. But at the moment we'll use a dummy header instead. |
408 | // Request.ConnectionGroupName = "NoVerify"; | ||
409 | Request.Headers.Add("NoVerifyCert", "true"); | 441 | Request.Headers.Add("NoVerifyCert", "true"); |
410 | } | 442 | } |
411 | // else | ||
412 | // { | ||
413 | // Request.ConnectionGroupName="Verify"; | ||
414 | // } | ||
415 | if (proxyurl != null && proxyurl.Length > 0) | 443 | if (proxyurl != null && proxyurl.Length > 0) |
416 | { | 444 | { |
417 | if (proxyexcepts != null && proxyexcepts.Length > 0) | 445 | if (proxyexcepts != null && proxyexcepts.Length > 0) |
@@ -474,25 +502,56 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
474 | 502 | ||
475 | // continue building the string | 503 | // continue building the string |
476 | sb.Append(tempString); | 504 | sb.Append(tempString); |
505 | if (sb.Length > 2048) | ||
506 | break; | ||
477 | } | 507 | } |
478 | } while (count > 0); // any more data to read? | 508 | } while (count > 0); // any more data to read? |
479 | 509 | ||
480 | ResponseBody = sb.ToString(); | 510 | ResponseBody = sb.ToString().Replace("\r", ""); |
481 | } | 511 | } |
482 | catch (Exception e) | 512 | catch (WebException e) |
483 | { | 513 | { |
484 | Status = (int)OSHttpStatusCode.ClientErrorJoker; | 514 | if (e.Status == WebExceptionStatus.ProtocolError) |
485 | ResponseBody = e.Message; | 515 | { |
516 | HttpWebResponse webRsp = (HttpWebResponse)((WebException)e).Response; | ||
517 | Status = (int)webRsp.StatusCode; | ||
518 | try | ||
519 | { | ||
520 | using (Stream responseStream = webRsp.GetResponseStream()) | ||
521 | { | ||
522 | ResponseBody = responseStream.GetStreamString(); | ||
523 | } | ||
524 | } | ||
525 | catch | ||
526 | { | ||
527 | ResponseBody = webRsp.StatusDescription; | ||
528 | } | ||
529 | } | ||
530 | else | ||
531 | { | ||
532 | Status = (int)OSHttpStatusCode.ClientErrorJoker; | ||
533 | ResponseBody = e.Message; | ||
534 | } | ||
535 | |||
536 | if (ResponseBody == null) | ||
537 | ResponseBody = String.Empty; | ||
486 | 538 | ||
487 | _finished = true; | 539 | _finished = true; |
488 | return; | 540 | return; |
489 | } | 541 | } |
542 | catch (Exception e) | ||
543 | { | ||
544 | // Don't crash on anything else | ||
545 | } | ||
490 | finally | 546 | finally |
491 | { | 547 | { |
492 | if (response != null) | 548 | if (response != null) |
493 | response.Close(); | 549 | response.Close(); |
494 | } | 550 | } |
495 | 551 | ||
552 | if (ResponseBody == null) | ||
553 | ResponseBody = String.Empty; | ||
554 | |||
496 | _finished = true; | 555 | _finished = true; |
497 | } | 556 | } |
498 | 557 | ||
@@ -500,7 +559,10 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
500 | { | 559 | { |
501 | try | 560 | try |
502 | { | 561 | { |
503 | httpThread.Abort(); | 562 | if (!WorkItem.Cancel()) |
563 | { | ||
564 | WorkItem.Abort(); | ||
565 | } | ||
504 | } | 566 | } |
505 | catch (Exception) | 567 | catch (Exception) |
506 | { | 568 | { |
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index c9cd412..f2922d6 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -42,40 +42,15 @@ using OpenSim.Region.Framework.Scenes; | |||
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | 43 | namespace OpenSim.Region.CoreModules.Scripting.LSLHttp |
44 | { | 44 | { |
45 | /// <summary> | ||
46 | /// Data describing an external URL set up by a script. | ||
47 | /// </summary> | ||
48 | public class UrlData | 45 | public class UrlData |
49 | { | 46 | { |
50 | /// <summary> | ||
51 | /// Scene object part hosting the script | ||
52 | /// </summary> | ||
53 | public UUID hostID; | 47 | public UUID hostID; |
54 | |||
55 | /// <summary> | ||
56 | /// The item ID of the script that requested the URL. | ||
57 | /// </summary> | ||
58 | public UUID itemID; | 48 | public UUID itemID; |
59 | |||
60 | /// <summary> | ||
61 | /// The script engine that runs the script. | ||
62 | /// </summary> | ||
63 | public IScriptModule engine; | 49 | public IScriptModule engine; |
64 | |||
65 | /// <summary> | ||
66 | /// The generated URL. | ||
67 | /// </summary> | ||
68 | public string url; | 50 | public string url; |
69 | |||
70 | /// <summary> | ||
71 | /// The random UUID component of the generated URL. | ||
72 | /// </summary> | ||
73 | public UUID urlcode; | 51 | public UUID urlcode; |
74 | |||
75 | /// <summary> | ||
76 | /// The external requests currently being processed or awaiting retrieval for this URL. | ||
77 | /// </summary> | ||
78 | public Dictionary<UUID, RequestData> requests; | 52 | public Dictionary<UUID, RequestData> requests; |
53 | public bool isSsl; | ||
79 | } | 54 | } |
80 | 55 | ||
81 | public class RequestData | 56 | public class RequestData |
@@ -89,6 +64,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
89 | //public ManualResetEvent ev; | 64 | //public ManualResetEvent ev; |
90 | public bool requestDone; | 65 | public bool requestDone; |
91 | public int startTime; | 66 | public int startTime; |
67 | public bool responseSent; | ||
92 | public string uri; | 68 | public string uri; |
93 | } | 69 | } |
94 | 70 | ||
@@ -102,20 +78,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
102 | LogManager.GetLogger( | 78 | LogManager.GetLogger( |
103 | MethodBase.GetCurrentMethod().DeclaringType); | 79 | MethodBase.GetCurrentMethod().DeclaringType); |
104 | 80 | ||
105 | /// <summary> | 81 | private Dictionary<UUID, UrlData> m_RequestMap = |
106 | /// Indexs the URL request metadata (which script requested it, outstanding requests, etc.) by the request ID | 82 | new Dictionary<UUID, UrlData>(); |
107 | /// randomly generated when a request is received for this URL. | ||
108 | /// </summary> | ||
109 | /// <remarks> | ||
110 | /// Manipulation or retrieval from this dictionary must be locked on m_UrlMap to preserve consistency with | ||
111 | /// m_UrlMap | ||
112 | /// </remarks> | ||
113 | private Dictionary<UUID, UrlData> m_RequestMap = new Dictionary<UUID, UrlData>(); | ||
114 | 83 | ||
115 | /// <summary> | 84 | private Dictionary<string, UrlData> m_UrlMap = |
116 | /// Indexs the URL request metadata (which script requested it, outstanding requests, etc.) by the full URL | 85 | new Dictionary<string, UrlData>(); |
117 | /// </summary> | ||
118 | private Dictionary<string, UrlData> m_UrlMap = new Dictionary<string, UrlData>(); | ||
119 | 86 | ||
120 | private uint m_HttpsPort = 0; | 87 | private uint m_HttpsPort = 0; |
121 | private IHttpServer m_HttpServer = null; | 88 | private IHttpServer m_HttpServer = null; |
@@ -126,7 +93,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
126 | /// <summary> | 93 | /// <summary> |
127 | /// The default maximum number of urls | 94 | /// The default maximum number of urls |
128 | /// </summary> | 95 | /// </summary> |
129 | public const int DefaultTotalUrls = 100; | 96 | public const int DefaultTotalUrls = 15000; |
130 | 97 | ||
131 | /// <summary> | 98 | /// <summary> |
132 | /// Maximum number of external urls that can be set up by this module. | 99 | /// Maximum number of external urls that can be set up by this module. |
@@ -221,7 +188,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
221 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); | 188 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); |
222 | return urlcode; | 189 | return urlcode; |
223 | } | 190 | } |
224 | string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; | 191 | string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString(); |
225 | 192 | ||
226 | UrlData urlData = new UrlData(); | 193 | UrlData urlData = new UrlData(); |
227 | urlData.hostID = host.UUID; | 194 | urlData.hostID = host.UUID; |
@@ -229,19 +196,20 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
229 | urlData.engine = engine; | 196 | urlData.engine = engine; |
230 | urlData.url = url; | 197 | urlData.url = url; |
231 | urlData.urlcode = urlcode; | 198 | urlData.urlcode = urlcode; |
199 | urlData.isSsl = false; | ||
232 | urlData.requests = new Dictionary<UUID, RequestData>(); | 200 | urlData.requests = new Dictionary<UUID, RequestData>(); |
233 | 201 | ||
234 | m_UrlMap[url] = urlData; | 202 | m_UrlMap[url] = urlData; |
235 | 203 | ||
236 | string uri = "/lslhttp/" + urlcode.ToString() + "/"; | 204 | string uri = "/lslhttp/" + urlcode.ToString(); |
237 | 205 | ||
238 | m_HttpServer.AddPollServiceHTTPHandler( | 206 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); |
239 | uri, | 207 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
240 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); | 208 | m_HttpServer.AddPollServiceHTTPHandler(uri, args); |
241 | 209 | ||
242 | m_log.DebugFormat( | 210 | // m_log.DebugFormat( |
243 | "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", | 211 | // "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", |
244 | uri, itemID, host.Name, host.LocalId); | 212 | // uri, itemID, host.Name, host.LocalId); |
245 | 213 | ||
246 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); | 214 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); |
247 | } | 215 | } |
@@ -266,7 +234,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
266 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); | 234 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); |
267 | return urlcode; | 235 | return urlcode; |
268 | } | 236 | } |
269 | string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; | 237 | string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString(); |
270 | 238 | ||
271 | UrlData urlData = new UrlData(); | 239 | UrlData urlData = new UrlData(); |
272 | urlData.hostID = host.UUID; | 240 | urlData.hostID = host.UUID; |
@@ -274,19 +242,21 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
274 | urlData.engine = engine; | 242 | urlData.engine = engine; |
275 | urlData.url = url; | 243 | urlData.url = url; |
276 | urlData.urlcode = urlcode; | 244 | urlData.urlcode = urlcode; |
245 | urlData.isSsl = true; | ||
277 | urlData.requests = new Dictionary<UUID, RequestData>(); | 246 | urlData.requests = new Dictionary<UUID, RequestData>(); |
278 | 247 | ||
248 | |||
279 | m_UrlMap[url] = urlData; | 249 | m_UrlMap[url] = urlData; |
280 | 250 | ||
281 | string uri = "/lslhttps/" + urlcode.ToString() + "/"; | 251 | string uri = "/lslhttps/" + urlcode.ToString(); |
282 | 252 | ||
283 | m_HttpsServer.AddPollServiceHTTPHandler( | 253 | PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); |
284 | uri, | 254 | args.Type = PollServiceEventArgs.EventType.LslHttp; |
285 | new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); | 255 | m_HttpsServer.AddPollServiceHTTPHandler(uri, args); |
286 | 256 | ||
287 | m_log.DebugFormat( | 257 | // m_log.DebugFormat( |
288 | "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", | 258 | // "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", |
289 | uri, itemID, host.Name, host.LocalId); | 259 | // uri, itemID, host.Name, host.LocalId); |
290 | 260 | ||
291 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); | 261 | engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); |
292 | } | 262 | } |
@@ -305,12 +275,15 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
305 | return; | 275 | return; |
306 | } | 276 | } |
307 | 277 | ||
308 | foreach (UUID req in data.requests.Keys) | 278 | lock (m_RequestMap) |
309 | m_RequestMap.Remove(req); | 279 | { |
310 | 280 | foreach (UUID req in data.requests.Keys) | |
311 | m_log.DebugFormat( | 281 | m_RequestMap.Remove(req); |
312 | "[URL MODULE]: Releasing url {0} for {1} in {2}", | 282 | } |
313 | url, data.itemID, data.hostID); | 283 | |
284 | // m_log.DebugFormat( | ||
285 | // "[URL MODULE]: Releasing url {0} for {1} in {2}", | ||
286 | // url, data.itemID, data.hostID); | ||
314 | 287 | ||
315 | RemoveUrl(data); | 288 | RemoveUrl(data); |
316 | m_UrlMap.Remove(url); | 289 | m_UrlMap.Remove(url); |
@@ -335,29 +308,34 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
335 | 308 | ||
336 | public void HttpResponse(UUID request, int status, string body) | 309 | public void HttpResponse(UUID request, int status, string body) |
337 | { | 310 | { |
338 | lock (m_UrlMap) | 311 | lock (m_RequestMap) |
339 | { | 312 | { |
340 | if (m_RequestMap.ContainsKey(request)) | 313 | if (m_RequestMap.ContainsKey(request)) |
341 | { | 314 | { |
342 | UrlData urlData = m_RequestMap[request]; | 315 | UrlData urlData = m_RequestMap[request]; |
343 | string responseBody = body; | 316 | if (!urlData.requests[request].responseSent) |
344 | if (urlData.requests[request].responseType.Equals("text/plain")) | ||
345 | { | 317 | { |
346 | string value; | 318 | string responseBody = body; |
347 | if (urlData.requests[request].headers.TryGetValue("user-agent", out value)) | 319 | if (urlData.requests[request].responseType.Equals("text/plain")) |
348 | { | 320 | { |
349 | if (value != null && value.IndexOf("MSIE") >= 0) | 321 | string value; |
322 | if (urlData.requests[request].headers.TryGetValue("user-agent", out value)) | ||
350 | { | 323 | { |
351 | // wrap the html escaped response if the target client is IE | 324 | if (value != null && value.IndexOf("MSIE") >= 0) |
352 | // It ignores "text/plain" if the body is html | 325 | { |
353 | responseBody = "<html>" + System.Web.HttpUtility.HtmlEncode(body) + "</html>"; | 326 | // wrap the html escaped response if the target client is IE |
327 | // It ignores "text/plain" if the body is html | ||
328 | responseBody = "<html>" + System.Web.HttpUtility.HtmlEncode(body) + "</html>"; | ||
329 | } | ||
354 | } | 330 | } |
355 | } | 331 | } |
332 | |||
333 | urlData.requests[request].responseCode = status; | ||
334 | urlData.requests[request].responseBody = body; | ||
335 | //urlData.requests[request].ev.Set(); | ||
336 | urlData.requests[request].requestDone = true; | ||
337 | urlData.requests[request].responseSent = true; | ||
356 | } | 338 | } |
357 | urlData.requests[request].responseCode = status; | ||
358 | urlData.requests[request].responseBody = responseBody; | ||
359 | //urlData.requests[request].ev.Set(); | ||
360 | urlData.requests[request].requestDone =true; | ||
361 | } | 339 | } |
362 | else | 340 | else |
363 | { | 341 | { |
@@ -368,7 +346,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
368 | 346 | ||
369 | public string GetHttpHeader(UUID requestId, string header) | 347 | public string GetHttpHeader(UUID requestId, string header) |
370 | { | 348 | { |
371 | lock (m_UrlMap) | 349 | lock (m_RequestMap) |
372 | { | 350 | { |
373 | if (m_RequestMap.ContainsKey(requestId)) | 351 | if (m_RequestMap.ContainsKey(requestId)) |
374 | { | 352 | { |
@@ -382,7 +360,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
382 | m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); | 360 | m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); |
383 | } | 361 | } |
384 | } | 362 | } |
385 | |||
386 | return String.Empty; | 363 | return String.Empty; |
387 | } | 364 | } |
388 | 365 | ||
@@ -406,8 +383,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
406 | { | 383 | { |
407 | RemoveUrl(url.Value); | 384 | RemoveUrl(url.Value); |
408 | removeURLs.Add(url.Key); | 385 | removeURLs.Add(url.Key); |
409 | foreach (UUID req in url.Value.requests.Keys) | 386 | lock (m_RequestMap) |
410 | m_RequestMap.Remove(req); | 387 | { |
388 | foreach (UUID req in url.Value.requests.Keys) | ||
389 | m_RequestMap.Remove(req); | ||
390 | } | ||
411 | } | 391 | } |
412 | } | 392 | } |
413 | 393 | ||
@@ -428,9 +408,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
428 | { | 408 | { |
429 | RemoveUrl(url.Value); | 409 | RemoveUrl(url.Value); |
430 | removeURLs.Add(url.Key); | 410 | removeURLs.Add(url.Key); |
431 | 411 | lock (m_RequestMap) | |
432 | foreach (UUID req in url.Value.requests.Keys) | 412 | { |
433 | m_RequestMap.Remove(req); | 413 | foreach (UUID req in url.Value.requests.Keys) |
414 | m_RequestMap.Remove(req); | ||
415 | } | ||
434 | } | 416 | } |
435 | } | 417 | } |
436 | 418 | ||
@@ -439,123 +421,128 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
439 | } | 421 | } |
440 | } | 422 | } |
441 | 423 | ||
424 | |||
442 | private void RemoveUrl(UrlData data) | 425 | private void RemoveUrl(UrlData data) |
443 | { | 426 | { |
444 | m_HttpServer.RemoveHTTPHandler("", "/lslhttp/" + data.urlcode.ToString() + "/"); | 427 | if (data.isSsl) |
428 | m_HttpsServer.RemoveHTTPHandler("", "/lslhttps/"+data.urlcode.ToString()+"/"); | ||
429 | else | ||
430 | m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); | ||
445 | } | 431 | } |
446 | 432 | ||
447 | private Hashtable NoEvents(UUID requestID, UUID sessionID) | 433 | private Hashtable NoEvents(UUID requestID, UUID sessionID) |
448 | { | 434 | { |
449 | Hashtable response = new Hashtable(); | 435 | Hashtable response = new Hashtable(); |
450 | UrlData urlData; | 436 | UrlData url; |
451 | 437 | int startTime = 0; | |
452 | lock (m_UrlMap) | 438 | lock (m_RequestMap) |
453 | { | 439 | { |
454 | // We need to return a 404 here in case the request URL was removed at exactly the same time that a | ||
455 | // request was made. In this case, the request thread can outrace llRemoveURL() and still be polling | ||
456 | // for the request ID. | ||
457 | if (!m_RequestMap.ContainsKey(requestID)) | 440 | if (!m_RequestMap.ContainsKey(requestID)) |
458 | { | ||
459 | response["int_response_code"] = 404; | ||
460 | response["str_response_string"] = ""; | ||
461 | response["keepalive"] = false; | ||
462 | response["reusecontext"] = false; | ||
463 | |||
464 | return response; | 441 | return response; |
465 | } | 442 | url = m_RequestMap[requestID]; |
443 | startTime = url.requests[requestID].startTime; | ||
444 | } | ||
466 | 445 | ||
467 | urlData = m_RequestMap[requestID]; | 446 | if (System.Environment.TickCount - startTime > 25000) |
447 | { | ||
448 | response["int_response_code"] = 500; | ||
449 | response["str_response_string"] = "Script timeout"; | ||
450 | response["content_type"] = "text/plain"; | ||
451 | response["keepalive"] = false; | ||
452 | response["reusecontext"] = false; | ||
468 | 453 | ||
469 | if (System.Environment.TickCount - urlData.requests[requestID].startTime > 25000) | 454 | //remove from map |
455 | lock (url.requests) | ||
456 | { | ||
457 | url.requests.Remove(requestID); | ||
458 | } | ||
459 | lock (m_RequestMap) | ||
470 | { | 460 | { |
471 | response["int_response_code"] = 500; | ||
472 | response["str_response_string"] = "Script timeout"; | ||
473 | response["content_type"] = "text/plain"; | ||
474 | response["keepalive"] = false; | ||
475 | response["reusecontext"] = false; | ||
476 | |||
477 | //remove from map | ||
478 | urlData.requests.Remove(requestID); | ||
479 | m_RequestMap.Remove(requestID); | 461 | m_RequestMap.Remove(requestID); |
480 | |||
481 | return response; | ||
482 | } | 462 | } |
463 | |||
464 | return response; | ||
483 | } | 465 | } |
484 | 466 | ||
467 | |||
485 | return response; | 468 | return response; |
486 | } | 469 | } |
487 | 470 | ||
488 | private bool HasEvents(UUID requestID, UUID sessionID) | 471 | private bool HasEvents(UUID requestID, UUID sessionID) |
489 | { | 472 | { |
490 | lock (m_UrlMap) | 473 | UrlData url=null; |
474 | |||
475 | lock (m_RequestMap) | ||
491 | { | 476 | { |
492 | // We return true here because an external URL request that happened at the same time as an llRemoveURL() | ||
493 | // can still make it through to HttpRequestHandler(). That will return without setting up a request | ||
494 | // when it detects that the URL has been removed. The poller, however, will continue to ask for | ||
495 | // events for that request, so here we will signal that there are events and in GetEvents we will | ||
496 | // return a 404. | ||
497 | if (!m_RequestMap.ContainsKey(requestID)) | 477 | if (!m_RequestMap.ContainsKey(requestID)) |
498 | { | 478 | { |
499 | return true; | 479 | return false; |
500 | } | 480 | } |
501 | 481 | url = m_RequestMap[requestID]; | |
502 | UrlData urlData = m_RequestMap[requestID]; | 482 | } |
503 | 483 | lock (url.requests) | |
504 | if (!urlData.requests.ContainsKey(requestID)) | 484 | { |
485 | if (!url.requests.ContainsKey(requestID)) | ||
505 | { | 486 | { |
506 | return true; | 487 | return false; |
507 | } | 488 | } |
508 | 489 | else | |
509 | // Trigger return of timeout response. | ||
510 | if (System.Environment.TickCount - urlData.requests[requestID].startTime > 25000) | ||
511 | { | 490 | { |
512 | return true; | 491 | if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) |
492 | { | ||
493 | return true; | ||
494 | } | ||
495 | if (url.requests[requestID].requestDone) | ||
496 | return true; | ||
497 | else | ||
498 | return false; | ||
513 | } | 499 | } |
514 | |||
515 | return urlData.requests[requestID].requestDone; | ||
516 | } | 500 | } |
517 | } | 501 | } |
518 | 502 | private Hashtable GetEvents(UUID requestID, UUID sessionID) | |
519 | private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) | ||
520 | { | 503 | { |
521 | Hashtable response; | 504 | UrlData url = null; |
505 | RequestData requestData = null; | ||
522 | 506 | ||
523 | lock (m_UrlMap) | 507 | lock (m_RequestMap) |
524 | { | 508 | { |
525 | UrlData url = null; | ||
526 | RequestData requestData = null; | ||
527 | |||
528 | if (!m_RequestMap.ContainsKey(requestID)) | 509 | if (!m_RequestMap.ContainsKey(requestID)) |
529 | return NoEvents(requestID, sessionID); | 510 | return NoEvents(requestID,sessionID); |
530 | |||
531 | url = m_RequestMap[requestID]; | 511 | url = m_RequestMap[requestID]; |
512 | } | ||
513 | lock (url.requests) | ||
514 | { | ||
532 | requestData = url.requests[requestID]; | 515 | requestData = url.requests[requestID]; |
516 | } | ||
517 | |||
518 | if (!requestData.requestDone) | ||
519 | return NoEvents(requestID,sessionID); | ||
520 | |||
521 | Hashtable response = new Hashtable(); | ||
533 | 522 | ||
534 | if (!requestData.requestDone) | 523 | if (System.Environment.TickCount - requestData.startTime > 25000) |
535 | return NoEvents(requestID, sessionID); | 524 | { |
536 | 525 | response["int_response_code"] = 500; | |
537 | response = new Hashtable(); | 526 | response["str_response_string"] = "Script timeout"; |
538 | 527 | response["content_type"] = "text/plain"; | |
539 | if (System.Environment.TickCount - requestData.startTime > 25000) | ||
540 | { | ||
541 | response["int_response_code"] = 500; | ||
542 | response["str_response_string"] = "Script timeout"; | ||
543 | response["content_type"] = "text/plain"; | ||
544 | response["keepalive"] = false; | ||
545 | response["reusecontext"] = false; | ||
546 | return response; | ||
547 | } | ||
548 | |||
549 | //put response | ||
550 | response["int_response_code"] = requestData.responseCode; | ||
551 | response["str_response_string"] = requestData.responseBody; | ||
552 | response["content_type"] = requestData.responseType; | ||
553 | // response["content_type"] = "text/plain"; | ||
554 | response["keepalive"] = false; | 528 | response["keepalive"] = false; |
555 | response["reusecontext"] = false; | 529 | response["reusecontext"] = false; |
556 | 530 | return response; | |
557 | //remove from map | 531 | } |
532 | //put response | ||
533 | response["int_response_code"] = requestData.responseCode; | ||
534 | response["str_response_string"] = requestData.responseBody; | ||
535 | response["content_type"] = "text/plain"; | ||
536 | response["keepalive"] = false; | ||
537 | response["reusecontext"] = false; | ||
538 | |||
539 | //remove from map | ||
540 | lock (url.requests) | ||
541 | { | ||
558 | url.requests.Remove(requestID); | 542 | url.requests.Remove(requestID); |
543 | } | ||
544 | lock (m_RequestMap) | ||
545 | { | ||
559 | m_RequestMap.Remove(requestID); | 546 | m_RequestMap.Remove(requestID); |
560 | } | 547 | } |
561 | 548 | ||
@@ -564,41 +551,45 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
564 | 551 | ||
565 | public void HttpRequestHandler(UUID requestID, Hashtable request) | 552 | public void HttpRequestHandler(UUID requestID, Hashtable request) |
566 | { | 553 | { |
567 | string uri = request["uri"].ToString(); | 554 | lock (request) |
568 | bool is_ssl = uri.Contains("lslhttps"); | ||
569 | |||
570 | try | ||
571 | { | 555 | { |
572 | Hashtable headers = (Hashtable)request["headers"]; | 556 | string uri = request["uri"].ToString(); |
573 | 557 | bool is_ssl = uri.Contains("lslhttps"); | |
574 | // string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; | ||
575 | 558 | ||
576 | int pos1 = uri.IndexOf("/");// /lslhttp | 559 | try |
577 | int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ | ||
578 | int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp/<UUID>/ | ||
579 | string uri_tmp = uri.Substring(0, pos3 + 1); | ||
580 | //HTTP server code doesn't provide us with QueryStrings | ||
581 | string pathInfo; | ||
582 | string queryString; | ||
583 | queryString = ""; | ||
584 | |||
585 | pathInfo = uri.Substring(pos3); | ||
586 | |||
587 | UrlData urlData = null; | ||
588 | |||
589 | lock (m_UrlMap) | ||
590 | { | 560 | { |
591 | string url; | 561 | Hashtable headers = (Hashtable)request["headers"]; |
592 | 562 | ||
593 | if (is_ssl) | 563 | // string uri_full = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; |
594 | url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; | 564 | |
565 | int pos1 = uri.IndexOf("/");// /lslhttp | ||
566 | int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ | ||
567 | int pos3 = pos2 + 37; // /lslhttp/urlcode | ||
568 | string uri_tmp = uri.Substring(0, pos3); | ||
569 | //HTTP server code doesn't provide us with QueryStrings | ||
570 | string pathInfo; | ||
571 | string queryString; | ||
572 | queryString = ""; | ||
573 | |||
574 | pathInfo = uri.Substring(pos3); | ||
575 | |||
576 | UrlData url = null; | ||
577 | string urlkey; | ||
578 | if (!is_ssl) | ||
579 | urlkey = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; | ||
580 | //m_UrlMap[]; | ||
595 | else | 581 | else |
596 | url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; | 582 | urlkey = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; |
597 | 583 | ||
598 | // Avoid a race - the request URL may have been released via llRequestUrl() whilst this | 584 | if (m_UrlMap.ContainsKey(urlkey)) |
599 | // request was being processed. | 585 | { |
600 | if (!m_UrlMap.TryGetValue(url, out urlData)) | 586 | url = m_UrlMap[urlkey]; |
587 | } | ||
588 | else | ||
589 | { | ||
590 | //m_log.Warn("[HttpRequestHandler]: http-in request failed; no such url: "+urlkey.ToString()); | ||
601 | return; | 591 | return; |
592 | } | ||
602 | 593 | ||
603 | //for llGetHttpHeader support we need to store original URI here | 594 | //for llGetHttpHeader support we need to store original URI here |
604 | //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers | 595 | //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers |
@@ -618,7 +609,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
618 | string value = (string)header.Value; | 609 | string value = (string)header.Value; |
619 | requestData.headers.Add(key, value); | 610 | requestData.headers.Add(key, value); |
620 | } | 611 | } |
621 | |||
622 | foreach (DictionaryEntry de in request) | 612 | foreach (DictionaryEntry de in request) |
623 | { | 613 | { |
624 | if (de.Key.ToString() == "querystringkeys") | 614 | if (de.Key.ToString() == "querystringkeys") |
@@ -629,13 +619,21 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
629 | if (request.ContainsKey(key)) | 619 | if (request.ContainsKey(key)) |
630 | { | 620 | { |
631 | string val = (String)request[key]; | 621 | string val = (String)request[key]; |
632 | queryString = queryString + key + "=" + val + "&"; | 622 | if (key != "") |
623 | { | ||
624 | queryString = queryString + key + "=" + val + "&"; | ||
625 | } | ||
626 | else | ||
627 | { | ||
628 | queryString = queryString + val + "&"; | ||
629 | } | ||
633 | } | 630 | } |
634 | } | 631 | } |
635 | |||
636 | if (queryString.Length > 1) | 632 | if (queryString.Length > 1) |
637 | queryString = queryString.Substring(0, queryString.Length - 1); | 633 | queryString = queryString.Substring(0, queryString.Length - 1); |
634 | |||
638 | } | 635 | } |
636 | |||
639 | } | 637 | } |
640 | 638 | ||
641 | //if this machine is behind DNAT/port forwarding, currently this is being | 639 | //if this machine is behind DNAT/port forwarding, currently this is being |
@@ -643,23 +641,34 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
643 | requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; | 641 | requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; |
644 | requestData.headers["x-path-info"] = pathInfo; | 642 | requestData.headers["x-path-info"] = pathInfo; |
645 | requestData.headers["x-query-string"] = queryString; | 643 | requestData.headers["x-query-string"] = queryString; |
646 | requestData.headers["x-script-url"] = urlData.url; | 644 | requestData.headers["x-script-url"] = url.url; |
647 | 645 | ||
648 | urlData.requests.Add(requestID, requestData); | 646 | //requestData.ev = new ManualResetEvent(false); |
649 | m_RequestMap.Add(requestID, urlData); | 647 | lock (url.requests) |
650 | } | 648 | { |
649 | url.requests.Add(requestID, requestData); | ||
650 | } | ||
651 | lock (m_RequestMap) | ||
652 | { | ||
653 | //add to request map | ||
654 | m_RequestMap.Add(requestID, url); | ||
655 | } | ||
651 | 656 | ||
652 | urlData.engine.PostScriptEvent( | 657 | url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); |
653 | urlData.itemID, | 658 | |
654 | "http_request", | 659 | //send initial response? |
655 | new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); | 660 | // Hashtable response = new Hashtable(); |
656 | } | 661 | |
657 | catch (Exception we) | 662 | return; |
658 | { | 663 | |
659 | //Hashtable response = new Hashtable(); | 664 | } |
660 | m_log.Warn("[HttpRequestHandler]: http-in request failed"); | 665 | catch (Exception we) |
661 | m_log.Warn(we.Message); | 666 | { |
662 | m_log.Warn(we.StackTrace); | 667 | //Hashtable response = new Hashtable(); |
668 | m_log.Warn("[HttpRequestHandler]: http-in request failed"); | ||
669 | m_log.Warn(we.Message); | ||
670 | m_log.Warn(we.StackTrace); | ||
671 | } | ||
663 | } | 672 | } |
664 | } | 673 | } |
665 | 674 | ||
@@ -668,4 +677,4 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
668 | ScriptRemoved(itemID); | 677 | ScriptRemoved(itemID); |
669 | } | 678 | } |
670 | } | 679 | } |
671 | } \ No newline at end of file | 680 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 6bf50d2..fccf053 100644 --- a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | |||
@@ -262,6 +262,8 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms | |||
262 | return "modInvokeR"; | 262 | return "modInvokeR"; |
263 | else if (sid.ReturnType == typeof(object[])) | 263 | else if (sid.ReturnType == typeof(object[])) |
264 | return "modInvokeL"; | 264 | return "modInvokeL"; |
265 | else if (sid.ReturnType == typeof(void)) | ||
266 | return "modInvokeN"; | ||
265 | 267 | ||
266 | m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name); | 268 | m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name); |
267 | } | 269 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index 4cecd85..2fc89fc 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | |||
@@ -861,4 +861,4 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
861 | return null; | 861 | return null; |
862 | } | 862 | } |
863 | } | 863 | } |
864 | } \ No newline at end of file | 864 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 2c2c99c..87a0537 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -96,6 +96,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
96 | // private static readonly ILog m_log = | 96 | // private static readonly ILog m_log = |
97 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 97 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
98 | 98 | ||
99 | private const int DEBUG_CHANNEL = 2147483647; | ||
100 | |||
99 | private ListenerManager m_listenerManager; | 101 | private ListenerManager m_listenerManager; |
100 | private Queue m_pending; | 102 | private Queue m_pending; |
101 | private Queue m_pendingQ; | 103 | private Queue m_pendingQ; |
@@ -366,67 +368,60 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
366 | /// <param name='msg'> | 368 | /// <param name='msg'> |
367 | /// Message. | 369 | /// Message. |
368 | /// </param> | 370 | /// </param> |
369 | public void DeliverMessageTo(UUID target, int channel, Vector3 pos, | 371 | public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) |
370 | string name, UUID id, string msg) | ||
371 | { | 372 | { |
373 | error = null; | ||
374 | |||
375 | if (channel == DEBUG_CHANNEL) | ||
376 | return true; | ||
377 | |||
372 | // Is id an avatar? | 378 | // Is id an avatar? |
373 | ScenePresence sp = m_scene.GetScenePresence(target); | 379 | ScenePresence sp = m_scene.GetScenePresence(target); |
374 | 380 | ||
375 | if (sp != null) | 381 | if (sp != null) |
376 | { | 382 | { |
377 | // ignore if a child agent this is restricted to inside one | 383 | // Send message to avatar |
378 | // region | ||
379 | if (sp.IsChildAgent) | ||
380 | return; | ||
381 | |||
382 | // Send message to the avatar. | ||
383 | // Channel zero only goes to the avatar | ||
384 | // non zero channel messages only go to the attachments | ||
385 | if (channel == 0) | 384 | if (channel == 0) |
386 | { | 385 | { |
387 | m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), | 386 | // Channel 0 goes to viewer ONLY |
388 | pos, name, id, false); | 387 | m_scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, target, false, false); |
388 | return true; | ||
389 | } | 389 | } |
390 | else | ||
391 | { | ||
392 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
393 | if (attachments.Count == 0) | ||
394 | return; | ||
395 | 390 | ||
396 | // Get uuid of attachments | 391 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
397 | List<UUID> targets = new List<UUID>(); | ||
398 | foreach (SceneObjectGroup sog in attachments) | ||
399 | { | ||
400 | if (!sog.IsDeleted) | ||
401 | targets.Add(sog.UUID); | ||
402 | } | ||
403 | 392 | ||
404 | // Need to check each attachment | 393 | if (attachments.Count == 0) |
405 | foreach (ListenerInfo li | 394 | return true; |
406 | in m_listenerManager.GetListeners(UUID.Zero, | ||
407 | channel, name, id, msg)) | ||
408 | { | ||
409 | if (li.GetHostID().Equals(id)) | ||
410 | continue; | ||
411 | 395 | ||
412 | if (m_scene.GetSceneObjectPart( | 396 | // Get uuid of attachments |
413 | li.GetHostID()) == null) | 397 | List<UUID> targets = new List<UUID>(); |
414 | { | 398 | foreach (SceneObjectGroup sog in attachments) |
415 | continue; | 399 | { |
416 | } | 400 | if (!sog.IsDeleted) |
401 | targets.Add(sog.UUID); | ||
402 | } | ||
417 | 403 | ||
418 | if (targets.Contains(li.GetHostID())) | 404 | // Need to check each attachment |
419 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 405 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) |
420 | } | 406 | { |
407 | if (li.GetHostID().Equals(id)) | ||
408 | continue; | ||
409 | |||
410 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | ||
411 | continue; | ||
412 | |||
413 | if (targets.Contains(li.GetHostID())) | ||
414 | QueueMessage(new ListenerInfo(li, name, id, msg)); | ||
421 | } | 415 | } |
422 | 416 | ||
423 | return; | 417 | return true; |
424 | } | 418 | } |
425 | 419 | ||
426 | // No avatar found so look for an object | 420 | SceneObjectPart part = m_scene.GetSceneObjectPart(target); |
427 | foreach (ListenerInfo li | 421 | if (part == null) // Not even an object |
428 | in m_listenerManager.GetListeners(UUID.Zero, channel, | 422 | return true; // No error |
429 | name, id, msg)) | 423 | |
424 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | ||
430 | { | 425 | { |
431 | // Dont process if this message is from yourself! | 426 | // Dont process if this message is from yourself! |
432 | if (li.GetHostID().Equals(id)) | 427 | if (li.GetHostID().Equals(id)) |
@@ -444,7 +439,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
444 | } | 439 | } |
445 | } | 440 | } |
446 | 441 | ||
447 | return; | 442 | return true; |
448 | } | 443 | } |
449 | 444 | ||
450 | protected void QueueMessage(ListenerInfo li) | 445 | protected void QueueMessage(ListenerInfo li) |