diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/SLUtil.cs | 52 | ||||
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 41 |
2 files changed, 92 insertions, 1 deletions
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index b337e03..f9cb851 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Xml; | ||
31 | using log4net; | 32 | using log4net; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | 34 | ||
@@ -39,6 +40,13 @@ namespace OpenSim.Framework | |||
39 | 40 | ||
40 | #region SL / file extension / content-type conversions | 41 | #region SL / file extension / content-type conversions |
41 | 42 | ||
43 | public static Dictionary<string, UUID> DefaultAvatarAnimations = new Dictionary<string, UUID>(); | ||
44 | |||
45 | static SLUtil() | ||
46 | { | ||
47 | DefaultAvatarAnimations = LoadDefaultAvatarAnimations("data/avataranimations.xml"); | ||
48 | } | ||
49 | |||
42 | public static string SLAssetTypeToContentType(int assetType) | 50 | public static string SLAssetTypeToContentType(int assetType) |
43 | { | 51 | { |
44 | switch ((AssetType)assetType) | 52 | switch ((AssetType)assetType) |
@@ -374,5 +382,47 @@ namespace OpenSim.Framework | |||
374 | 382 | ||
375 | return output; | 383 | return output; |
376 | } | 384 | } |
385 | |||
386 | /// <summary> | ||
387 | /// Load the default SL avatar animations. | ||
388 | /// </summary> | ||
389 | /// <returns></returns> | ||
390 | public static Dictionary<string, UUID> LoadDefaultAvatarAnimations(string path) | ||
391 | { | ||
392 | Dictionary<string, UUID> animations = new Dictionary<string, UUID>(); | ||
393 | |||
394 | using (XmlTextReader reader = new XmlTextReader(path)) | ||
395 | { | ||
396 | XmlDocument doc = new XmlDocument(); | ||
397 | doc.Load(reader); | ||
398 | if (doc.DocumentElement != null) | ||
399 | { | ||
400 | foreach (XmlNode nod in doc.DocumentElement.ChildNodes) | ||
401 | { | ||
402 | if (nod.Attributes["name"] != null) | ||
403 | { | ||
404 | string name = nod.Attributes["name"].Value.ToLower(); | ||
405 | string id = nod.InnerText; | ||
406 | animations.Add(name, (UUID)id); | ||
407 | } | ||
408 | } | ||
409 | } | ||
410 | } | ||
411 | |||
412 | return animations; | ||
413 | } | ||
414 | |||
415 | /// <summary> | ||
416 | /// Get the default SL avatar animation with the given name. | ||
417 | /// </summary> | ||
418 | /// <param name="name"></param> | ||
419 | /// <returns></returns> | ||
420 | public static UUID GetDefaultAvatarAnimation(string name) | ||
421 | { | ||
422 | if (DefaultAvatarAnimations.ContainsKey(name)) | ||
423 | return DefaultAvatarAnimations[name]; | ||
424 | |||
425 | return UUID.Zero; | ||
426 | } | ||
377 | } | 427 | } |
378 | } | 428 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index f90df12..71a56e5 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -63,6 +63,31 @@ namespace OpenSim.Framework | |||
63 | // a "long" call for warning & debugging purposes | 63 | // a "long" call for warning & debugging purposes |
64 | public const int LongCallTime = 500; | 64 | public const int LongCallTime = 500; |
65 | 65 | ||
66 | // dictionary of end points | ||
67 | private static Dictionary<string,object> m_endpointSerializer = new Dictionary<string,object>(); | ||
68 | |||
69 | |||
70 | private static object EndPointLock(string url) | ||
71 | { | ||
72 | System.Uri uri = new System.Uri(url); | ||
73 | string endpoint = string.Format("{0}:{1}",uri.Host,uri.Port); | ||
74 | |||
75 | lock (m_endpointSerializer) | ||
76 | { | ||
77 | object eplock = null; | ||
78 | |||
79 | if (! m_endpointSerializer.TryGetValue(endpoint,out eplock)) | ||
80 | { | ||
81 | eplock = new object(); | ||
82 | m_endpointSerializer.Add(endpoint,eplock); | ||
83 | // m_log.WarnFormat("[WEB UTIL] add a new host to end point serializer {0}",endpoint); | ||
84 | } | ||
85 | |||
86 | return eplock; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | |||
66 | #region JSONRequest | 91 | #region JSONRequest |
67 | 92 | ||
68 | /// <summary> | 93 | /// <summary> |
@@ -96,6 +121,14 @@ namespace OpenSim.Framework | |||
96 | 121 | ||
97 | public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed) | 122 | public static OSDMap ServiceOSDRequest(string url, OSDMap data, string method, int timeout, bool compressed) |
98 | { | 123 | { |
124 | lock (EndPointLock(url)) | ||
125 | { | ||
126 | return ServiceOSDRequestWorker(url,data,method,timeout,compressed); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | private static OSDMap ServiceOSDRequestWorker(string url, OSDMap data, string method, int timeout, bool compressed) | ||
131 | { | ||
99 | int reqnum = m_requestNumber++; | 132 | int reqnum = m_requestNumber++; |
100 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); | 133 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start osd request for {1}, method {2}",reqnum,url,method); |
101 | 134 | ||
@@ -249,6 +282,14 @@ namespace OpenSim.Framework | |||
249 | 282 | ||
250 | public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout) | 283 | public static OSDMap ServiceFormRequest(string url, NameValueCollection data, int timeout) |
251 | { | 284 | { |
285 | lock (EndPointLock(url)) | ||
286 | { | ||
287 | return ServiceFormRequestWorker(url,data,timeout); | ||
288 | } | ||
289 | } | ||
290 | |||
291 | private static OSDMap ServiceFormRequestWorker(string url, NameValueCollection data, int timeout) | ||
292 | { | ||
252 | int reqnum = m_requestNumber++; | 293 | int reqnum = m_requestNumber++; |
253 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; | 294 | string method = (data != null && data["RequestMethod"] != null) ? data["RequestMethod"] : "unknown"; |
254 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); | 295 | // m_log.DebugFormat("[WEB UTIL]: <{0}> start form request for {1}, method {2}",reqnum,url,method); |