diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Services/Connectors/SimianGrid | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid')
13 files changed, 938 insertions, 437 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs index 95e4bab..cd4781d 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianActivityDetector.cs | |||
@@ -69,7 +69,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
69 | Util.FireAndForget(delegate(object o) | 69 | Util.FireAndForget(delegate(object o) |
70 | { | 70 | { |
71 | m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | 71 | m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); |
72 | }); | 72 | }, null, "SimianActivityDetector.SetLastPositionOnMakeRootAgent"); |
73 | } | 73 | } |
74 | 74 | ||
75 | public void OnNewClient(IClientAPI client) | 75 | public void OnNewClient(IClientAPI client) |
@@ -94,7 +94,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
94 | Util.FireAndForget(delegate(object o) | 94 | Util.FireAndForget(delegate(object o) |
95 | { | 95 | { |
96 | m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | 96 | m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); |
97 | }); | 97 | }, null, "SimianActivityDetector.SetLastPositionOnEnteringNewParcel"); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | } \ No newline at end of file | 100 | } \ No newline at end of file |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 63a32e7..9ad4a7a 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Collections.Specialized; | ||
30 | using System.IO; | 31 | using System.IO; |
31 | using System.Net; | 32 | using System.Net; |
32 | using System.Reflection; | 33 | using System.Reflection; |
@@ -122,7 +123,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
122 | m_Enabled = true; | 123 | m_Enabled = true; |
123 | } | 124 | } |
124 | 125 | ||
125 | #region IAssetService | 126 | #region IAssetService |
126 | 127 | ||
127 | public AssetBase Get(string id) | 128 | public AssetBase Get(string id) |
128 | { | 129 | { |
@@ -140,8 +141,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
140 | return asset; | 141 | return asset; |
141 | } | 142 | } |
142 | 143 | ||
143 | return GetRemote(id); | 144 | return SimianGetOperation(id); |
144 | } | 145 | } |
146 | |||
145 | 147 | ||
146 | public AssetBase GetCached(string id) | 148 | public AssetBase GetCached(string id) |
147 | { | 149 | { |
@@ -164,8 +166,6 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
164 | throw new InvalidOperationException(); | 166 | throw new InvalidOperationException(); |
165 | } | 167 | } |
166 | 168 | ||
167 | AssetMetadata metadata = null; | ||
168 | |||
169 | // Cache fetch | 169 | // Cache fetch |
170 | if (m_cache != null) | 170 | if (m_cache != null) |
171 | { | 171 | { |
@@ -174,50 +174,18 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
174 | return asset.Metadata; | 174 | return asset.Metadata; |
175 | } | 175 | } |
176 | 176 | ||
177 | Uri url; | 177 | // return GetRemoteMetadata(id); |
178 | 178 | return SimianGetMetadataOperation(id); | |
179 | // Determine if id is an absolute URL or a grid-relative UUID | ||
180 | if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | ||
181 | url = new Uri(m_serverUrl + id); | ||
182 | |||
183 | try | ||
184 | { | ||
185 | HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | ||
186 | request.Method = "HEAD"; | ||
187 | |||
188 | using (WebResponse response = request.GetResponse()) | ||
189 | { | ||
190 | using (Stream responseStream = response.GetResponseStream()) | ||
191 | { | ||
192 | // Create the metadata object | ||
193 | metadata = new AssetMetadata(); | ||
194 | metadata.ContentType = response.ContentType; | ||
195 | metadata.ID = id; | ||
196 | |||
197 | UUID uuid; | ||
198 | if (UUID.TryParse(id, out uuid)) | ||
199 | metadata.FullID = uuid; | ||
200 | |||
201 | string lastModifiedStr = response.Headers.Get("Last-Modified"); | ||
202 | if (!String.IsNullOrEmpty(lastModifiedStr)) | ||
203 | { | ||
204 | DateTime lastModified; | ||
205 | if (DateTime.TryParse(lastModifiedStr, out lastModified)) | ||
206 | metadata.CreationDate = lastModified; | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | catch (Exception ex) | ||
212 | { | ||
213 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message); | ||
214 | } | ||
215 | |||
216 | return metadata; | ||
217 | } | 179 | } |
218 | 180 | ||
219 | public byte[] GetData(string id) | 181 | public byte[] GetData(string id) |
220 | { | 182 | { |
183 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
184 | { | ||
185 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
186 | throw new InvalidOperationException(); | ||
187 | } | ||
188 | |||
221 | AssetBase asset = Get(id); | 189 | AssetBase asset = Get(id); |
222 | 190 | ||
223 | if (asset != null) | 191 | if (asset != null) |
@@ -255,14 +223,34 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
255 | Util.FireAndForget( | 223 | Util.FireAndForget( |
256 | delegate(object o) | 224 | delegate(object o) |
257 | { | 225 | { |
258 | AssetBase asset = GetRemote(id); | 226 | AssetBase asset = SimianGetOperation(id); |
259 | handler(id, sender, asset); | 227 | handler(id, sender, asset); |
260 | } | 228 | }, null, "SimianAssetServiceConnector.GetFromService" |
261 | ); | 229 | ); |
262 | 230 | ||
263 | return true; | 231 | return true; |
264 | } | 232 | } |
265 | 233 | ||
234 | public bool[] AssetsExist(string[] ids) | ||
235 | { | ||
236 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
237 | { | ||
238 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
239 | throw new InvalidOperationException(); | ||
240 | } | ||
241 | |||
242 | bool[] exist = new bool[ids.Length]; | ||
243 | |||
244 | for (int i = 0; i < ids.Length; i++) | ||
245 | { | ||
246 | AssetMetadata metadata = GetMetadata(ids[i]); | ||
247 | if (metadata != null) | ||
248 | exist[i] = true; | ||
249 | } | ||
250 | |||
251 | return exist; | ||
252 | } | ||
253 | |||
266 | /// <summary> | 254 | /// <summary> |
267 | /// Creates a new asset | 255 | /// Creates a new asset |
268 | /// </summary> | 256 | /// </summary> |
@@ -278,7 +266,6 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
278 | } | 266 | } |
279 | 267 | ||
280 | bool storedInCache = false; | 268 | bool storedInCache = false; |
281 | string errorMessage = null; | ||
282 | 269 | ||
283 | // AssetID handling | 270 | // AssetID handling |
284 | if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID) | 271 | if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID) |
@@ -307,80 +294,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
307 | return asset.ID; | 294 | return asset.ID; |
308 | } | 295 | } |
309 | 296 | ||
310 | // Distinguish public and private assets | 297 | return SimianStoreOperation(asset); |
311 | bool isPublic = true; | ||
312 | switch ((AssetType)asset.Type) | ||
313 | { | ||
314 | case AssetType.CallingCard: | ||
315 | case AssetType.Gesture: | ||
316 | case AssetType.LSLBytecode: | ||
317 | case AssetType.LSLText: | ||
318 | isPublic = false; | ||
319 | break; | ||
320 | } | ||
321 | |||
322 | // Make sure ContentType is set | ||
323 | if (String.IsNullOrEmpty(asset.Metadata.ContentType)) | ||
324 | asset.Metadata.ContentType = SLUtil.SLAssetTypeToContentType(asset.Type); | ||
325 | |||
326 | // Build the remote storage request | ||
327 | List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() | ||
328 | { | ||
329 | new MultipartForm.Parameter("AssetID", asset.FullID.ToString()), | ||
330 | new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID), | ||
331 | new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"), | ||
332 | new MultipartForm.Parameter("Public", isPublic ? "1" : "0"), | ||
333 | new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data) | ||
334 | }; | ||
335 | |||
336 | // Make the remote storage request | ||
337 | try | ||
338 | { | ||
339 | // Simian does not require the asset ID to be in the URL because it's in the post data. | ||
340 | // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs | ||
341 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString()); | ||
342 | |||
343 | HttpWebResponse response = MultipartForm.Post(request, postParameters); | ||
344 | using (Stream responseStream = response.GetResponseStream()) | ||
345 | { | ||
346 | string responseStr = null; | ||
347 | |||
348 | try | ||
349 | { | ||
350 | responseStr = responseStream.GetStreamString(); | ||
351 | OSD responseOSD = OSDParser.Deserialize(responseStr); | ||
352 | if (responseOSD.Type == OSDType.Map) | ||
353 | { | ||
354 | OSDMap responseMap = (OSDMap)responseOSD; | ||
355 | if (responseMap["Success"].AsBoolean()) | ||
356 | return asset.ID; | ||
357 | else | ||
358 | errorMessage = "Upload failed: " + responseMap["Message"].AsString(); | ||
359 | } | ||
360 | else | ||
361 | { | ||
362 | errorMessage = "Response format was invalid:\n" + responseStr; | ||
363 | } | ||
364 | } | ||
365 | catch (Exception ex) | ||
366 | { | ||
367 | if (!String.IsNullOrEmpty(responseStr)) | ||
368 | errorMessage = "Failed to parse the response:\n" + responseStr; | ||
369 | else | ||
370 | errorMessage = "Failed to retrieve the response: " + ex.Message; | ||
371 | } | ||
372 | } | ||
373 | } | ||
374 | catch (WebException ex) | ||
375 | { | ||
376 | errorMessage = ex.Message; | ||
377 | } | ||
378 | |||
379 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}", | ||
380 | asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage); | ||
381 | return null; | ||
382 | } | 298 | } |
383 | 299 | ||
384 | /// <summary> | 300 | /// <summary> |
385 | /// Update an asset's content | 301 | /// Update an asset's content |
386 | /// </summary> | 302 | /// </summary> |
@@ -390,11 +306,17 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
390 | /// <returns></returns> | 306 | /// <returns></returns> |
391 | public bool UpdateContent(string id, byte[] data) | 307 | public bool UpdateContent(string id, byte[] data) |
392 | { | 308 | { |
309 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
310 | { | ||
311 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
312 | throw new InvalidOperationException(); | ||
313 | } | ||
314 | |||
393 | AssetBase asset = Get(id); | 315 | AssetBase asset = Get(id); |
394 | 316 | ||
395 | if (asset == null) | 317 | if (asset == null) |
396 | { | 318 | { |
397 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset " + id + " for updating"); | 319 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset {0} for updating", id); |
398 | return false; | 320 | return false; |
399 | } | 321 | } |
400 | 322 | ||
@@ -417,83 +339,347 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
417 | throw new InvalidOperationException(); | 339 | throw new InvalidOperationException(); |
418 | } | 340 | } |
419 | 341 | ||
420 | //string errorMessage = String.Empty; | ||
421 | string url = m_serverUrl + id; | ||
422 | |||
423 | if (m_cache != null) | 342 | if (m_cache != null) |
424 | m_cache.Expire(id); | 343 | m_cache.Expire(id); |
425 | 344 | ||
345 | return SimianDeleteOperation(id); | ||
346 | } | ||
347 | |||
348 | #endregion IAssetService | ||
349 | |||
350 | #region SimianOperations | ||
351 | /// <summary> | ||
352 | /// Invokes the xRemoveAsset operation on the simian server to delete an asset | ||
353 | /// </summary> | ||
354 | /// <param name="id"></param> | ||
355 | /// <returns></returns> | ||
356 | private bool SimianDeleteOperation(string id) | ||
357 | { | ||
426 | try | 358 | try |
427 | { | 359 | { |
428 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); | 360 | NameValueCollection requestArgs = new NameValueCollection |
429 | request.Method = "DELETE"; | 361 | { |
362 | { "RequestMethod", "xRemoveAsset" }, | ||
363 | { "AssetID", id } | ||
364 | }; | ||
430 | 365 | ||
431 | using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) | 366 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); |
367 | if (! response["Success"].AsBoolean()) | ||
432 | { | 368 | { |
433 | if (response.StatusCode != HttpStatusCode.NoContent) | 369 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString()); |
434 | { | 370 | return false; |
435 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Unexpected response when deleting asset " + url + ": " + | ||
436 | response.StatusCode + " (" + response.StatusDescription + ")"); | ||
437 | } | ||
438 | } | 371 | } |
439 | 372 | ||
440 | return true; | 373 | return true; |
374 | |||
441 | } | 375 | } |
442 | catch (Exception ex) | 376 | catch (Exception ex) |
443 | { | 377 | { |
444 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to delete asset " + id + " from the asset service: " + ex.Message); | 378 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset {0}; {1}", id, ex.Message); |
445 | return false; | ||
446 | } | 379 | } |
447 | } | ||
448 | 380 | ||
449 | #endregion IAssetService | 381 | return false; |
382 | } | ||
450 | 383 | ||
451 | private AssetBase GetRemote(string id) | 384 | /// <summary> |
385 | /// Invokes the xAddAsset operation on the simian server to create or update an asset | ||
386 | /// </summary> | ||
387 | /// <param name="id"></param> | ||
388 | /// <returns></returns> | ||
389 | private string SimianStoreOperation(AssetBase asset) | ||
452 | { | 390 | { |
453 | AssetBase asset = null; | 391 | try |
454 | Uri url; | 392 | { |
393 | NameValueCollection requestArgs = new NameValueCollection | ||
394 | { | ||
395 | { "RequestMethod", "xAddAsset" }, | ||
396 | { "ContentType", asset.Metadata.ContentType }, | ||
397 | { "EncodedData", Convert.ToBase64String(asset.Data) }, | ||
398 | { "AssetID", asset.FullID.ToString() }, | ||
399 | { "CreatorID", asset.Metadata.CreatorID }, | ||
400 | { "Temporary", asset.Temporary ? "1" : "0" }, | ||
401 | { "Name", asset.Name } | ||
402 | }; | ||
403 | |||
404 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); | ||
405 | if (! response["Success"].AsBoolean()) | ||
406 | { | ||
407 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",response["Message"].AsString()); | ||
408 | return null; | ||
409 | } | ||
455 | 410 | ||
456 | // Determine if id is an absolute URL or a grid-relative UUID | 411 | // asset.ID is always set before calling this function |
457 | if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | 412 | return asset.ID; |
458 | url = new Uri(m_serverUrl + id); | 413 | |
414 | } | ||
415 | catch (Exception ex) | ||
416 | { | ||
417 | m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message); | ||
418 | } | ||
419 | |||
420 | return null; | ||
421 | } | ||
459 | 422 | ||
460 | try | 423 | /// <summary> |
424 | /// Invokes the xGetAsset operation on the simian server to get data associated with an asset | ||
425 | /// </summary> | ||
426 | /// <param name="id"></param> | ||
427 | /// <returns></returns> | ||
428 | private AssetBase SimianGetOperation(string id) | ||
429 | { | ||
430 | try | ||
461 | { | 431 | { |
462 | HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | 432 | NameValueCollection requestArgs = new NameValueCollection |
433 | { | ||
434 | { "RequestMethod", "xGetAsset" }, | ||
435 | { "ID", id } | ||
436 | }; | ||
463 | 437 | ||
464 | using (WebResponse response = request.GetResponse()) | 438 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); |
439 | if (! response["Success"].AsBoolean()) | ||
465 | { | 440 | { |
466 | using (Stream responseStream = response.GetResponseStream()) | 441 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString()); |
467 | { | 442 | return null; |
468 | string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty; | ||
469 | |||
470 | // Create the asset object | ||
471 | asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID); | ||
472 | |||
473 | UUID assetID; | ||
474 | if (UUID.TryParse(id, out assetID)) | ||
475 | asset.FullID = assetID; | ||
476 | |||
477 | // Grab the asset data from the response stream | ||
478 | using (MemoryStream stream = new MemoryStream()) | ||
479 | { | ||
480 | responseStream.CopyStream(stream, Int32.MaxValue); | ||
481 | asset.Data = stream.ToArray(); | ||
482 | } | ||
483 | } | ||
484 | } | 443 | } |
444 | |||
445 | AssetBase asset = new AssetBase(); | ||
485 | 446 | ||
486 | // Cache store | 447 | asset.ID = id; |
487 | if (m_cache != null && asset != null) | 448 | asset.Name = String.Empty; |
488 | m_cache.Cache(asset); | 449 | asset.Metadata.ContentType = response["ContentType"].AsString(); // this will also set the asset Type property |
450 | asset.CreatorID = response["CreatorID"].AsString(); | ||
451 | asset.Data = System.Convert.FromBase64String(response["EncodedData"].AsString()); | ||
452 | asset.Local = false; | ||
453 | asset.Temporary = response["Temporary"]; | ||
489 | 454 | ||
490 | return asset; | 455 | return asset; |
491 | } | 456 | } |
492 | catch (Exception ex) | 457 | catch (Exception ex) |
493 | { | 458 | { |
494 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message); | 459 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to retrieve asset {0}; {1}", id, ex.Message); |
495 | return null; | 460 | } |
461 | |||
462 | return null; | ||
463 | } | ||
464 | |||
465 | /// <summary> | ||
466 | /// Invokes the xGetAssetMetadata operation on the simian server to retrieve metadata for an asset | ||
467 | /// This operation is generally used to determine if an asset exists in the database | ||
468 | /// </summary> | ||
469 | /// <param name="id"></param> | ||
470 | /// <returns></returns> | ||
471 | private AssetMetadata SimianGetMetadataOperation(string id) | ||
472 | { | ||
473 | try | ||
474 | { | ||
475 | NameValueCollection requestArgs = new NameValueCollection | ||
476 | { | ||
477 | { "RequestMethod", "xGetAssetMetadata" }, | ||
478 | { "ID", id } | ||
479 | }; | ||
480 | |||
481 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); | ||
482 | if (! response["Success"].AsBoolean()) | ||
483 | { | ||
484 | // this is not really an error, this call is used to test existence | ||
485 | // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString()); | ||
486 | return null; | ||
487 | } | ||
488 | |||
489 | AssetMetadata metadata = new AssetMetadata(); | ||
490 | metadata.ID = id; | ||
491 | metadata.ContentType = response["ContentType"].AsString(); | ||
492 | metadata.CreatorID = response["CreatorID"].AsString(); | ||
493 | metadata.Local = false; | ||
494 | metadata.Temporary = response["Temporary"]; | ||
495 | |||
496 | string lastModifiedStr = response["Last-Modified"].AsString(); | ||
497 | if (! String.IsNullOrEmpty(lastModifiedStr)) | ||
498 | { | ||
499 | DateTime lastModified; | ||
500 | if (DateTime.TryParse(lastModifiedStr, out lastModified)) | ||
501 | metadata.CreationDate = lastModified; | ||
502 | } | ||
503 | |||
504 | return metadata; | ||
505 | } | ||
506 | catch (Exception ex) | ||
507 | { | ||
508 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to get asset metadata; {0}", ex.Message); | ||
496 | } | 509 | } |
510 | |||
511 | return null; | ||
497 | } | 512 | } |
513 | #endregion | ||
514 | |||
515 | // private AssetMetadata GetRemoteMetadata(string id) | ||
516 | // { | ||
517 | // Uri url; | ||
518 | // AssetMetadata metadata = null; | ||
519 | |||
520 | // // Determine if id is an absolute URL or a grid-relative UUID | ||
521 | // if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | ||
522 | // url = new Uri(m_serverUrl + id); | ||
523 | |||
524 | // try | ||
525 | // { | ||
526 | // HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | ||
527 | // request.Method = "HEAD"; | ||
528 | |||
529 | // using (WebResponse response = request.GetResponse()) | ||
530 | // { | ||
531 | // using (Stream responseStream = response.GetResponseStream()) | ||
532 | // { | ||
533 | // // Create the metadata object | ||
534 | // metadata = new AssetMetadata(); | ||
535 | // metadata.ContentType = response.ContentType; | ||
536 | // metadata.ID = id; | ||
537 | |||
538 | // UUID uuid; | ||
539 | // if (UUID.TryParse(id, out uuid)) | ||
540 | // metadata.FullID = uuid; | ||
541 | |||
542 | // string lastModifiedStr = response.Headers.Get("Last-Modified"); | ||
543 | // if (!String.IsNullOrEmpty(lastModifiedStr)) | ||
544 | // { | ||
545 | // DateTime lastModified; | ||
546 | // if (DateTime.TryParse(lastModifiedStr, out lastModified)) | ||
547 | // metadata.CreationDate = lastModified; | ||
548 | // } | ||
549 | // } | ||
550 | // } | ||
551 | // } | ||
552 | // catch (Exception ex) | ||
553 | // { | ||
554 | // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message); | ||
555 | // } | ||
556 | |||
557 | // return metadata; | ||
558 | // } | ||
559 | |||
560 | // private AssetBase GetRemote(string id) | ||
561 | // { | ||
562 | // AssetBase asset = null; | ||
563 | // Uri url; | ||
564 | |||
565 | // // Determine if id is an absolute URL or a grid-relative UUID | ||
566 | // if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | ||
567 | // url = new Uri(m_serverUrl + id); | ||
568 | |||
569 | // try | ||
570 | // { | ||
571 | // HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | ||
572 | |||
573 | // using (WebResponse response = request.GetResponse()) | ||
574 | // { | ||
575 | // using (Stream responseStream = response.GetResponseStream()) | ||
576 | // { | ||
577 | // string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty; | ||
578 | |||
579 | // // Create the asset object | ||
580 | // asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID); | ||
581 | |||
582 | // UUID assetID; | ||
583 | // if (UUID.TryParse(id, out assetID)) | ||
584 | // asset.FullID = assetID; | ||
585 | |||
586 | // // Grab the asset data from the response stream | ||
587 | // using (MemoryStream stream = new MemoryStream()) | ||
588 | // { | ||
589 | // responseStream.CopyStream(stream, Int32.MaxValue); | ||
590 | // asset.Data = stream.ToArray(); | ||
591 | // } | ||
592 | // } | ||
593 | // } | ||
594 | |||
595 | // // Cache store | ||
596 | // if (m_cache != null && asset != null) | ||
597 | // m_cache.Cache(asset); | ||
598 | |||
599 | // return asset; | ||
600 | // } | ||
601 | // catch (Exception ex) | ||
602 | // { | ||
603 | // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message); | ||
604 | // return null; | ||
605 | // } | ||
606 | // } | ||
607 | |||
608 | // private string StoreRemote(AssetBase asset) | ||
609 | // { | ||
610 | // // Distinguish public and private assets | ||
611 | // bool isPublic = true; | ||
612 | // switch ((AssetType)asset.Type) | ||
613 | // { | ||
614 | // case AssetType.CallingCard: | ||
615 | // case AssetType.Gesture: | ||
616 | // case AssetType.LSLBytecode: | ||
617 | // case AssetType.LSLText: | ||
618 | // isPublic = false; | ||
619 | // break; | ||
620 | // } | ||
621 | |||
622 | // string errorMessage = null; | ||
623 | |||
624 | // // Build the remote storage request | ||
625 | // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() | ||
626 | // { | ||
627 | // new MultipartForm.Parameter("AssetID", asset.FullID.ToString()), | ||
628 | // new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID), | ||
629 | // new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"), | ||
630 | // new MultipartForm.Parameter("Public", isPublic ? "1" : "0"), | ||
631 | // new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data) | ||
632 | // }; | ||
633 | |||
634 | // // Make the remote storage request | ||
635 | // try | ||
636 | // { | ||
637 | // // Simian does not require the asset ID to be in the URL because it's in the post data. | ||
638 | // // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs | ||
639 | // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString()); | ||
640 | |||
641 | // using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) | ||
642 | // { | ||
643 | // using (Stream responseStream = response.GetResponseStream()) | ||
644 | // { | ||
645 | // string responseStr = null; | ||
646 | |||
647 | // try | ||
648 | // { | ||
649 | // responseStr = responseStream.GetStreamString(); | ||
650 | // OSD responseOSD = OSDParser.Deserialize(responseStr); | ||
651 | // if (responseOSD.Type == OSDType.Map) | ||
652 | // { | ||
653 | // OSDMap responseMap = (OSDMap)responseOSD; | ||
654 | // if (responseMap["Success"].AsBoolean()) | ||
655 | // return asset.ID; | ||
656 | // else | ||
657 | // errorMessage = "Upload failed: " + responseMap["Message"].AsString(); | ||
658 | // } | ||
659 | // else | ||
660 | // { | ||
661 | // errorMessage = "Response format was invalid:\n" + responseStr; | ||
662 | // } | ||
663 | // } | ||
664 | // catch (Exception ex) | ||
665 | // { | ||
666 | // if (!String.IsNullOrEmpty(responseStr)) | ||
667 | // errorMessage = "Failed to parse the response:\n" + responseStr; | ||
668 | // else | ||
669 | // errorMessage = "Failed to retrieve the response: " + ex.Message; | ||
670 | // } | ||
671 | // } | ||
672 | // } | ||
673 | // } | ||
674 | // catch (WebException ex) | ||
675 | // { | ||
676 | // errorMessage = ex.Message; | ||
677 | // } | ||
678 | |||
679 | // m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}", | ||
680 | // asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage); | ||
681 | |||
682 | // return null; | ||
683 | // } | ||
498 | } | 684 | } |
499 | } | 685 | } |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs index 6603f6e..3bd11d9 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs | |||
@@ -110,7 +110,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
110 | { "UserID", principalID.ToString() } | 110 | { "UserID", principalID.ToString() } |
111 | }; | 111 | }; |
112 | 112 | ||
113 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 113 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
114 | if (response["Success"].AsBoolean() && response["Identities"] is OSDArray) | 114 | if (response["Success"].AsBoolean() && response["Identities"] is OSDArray) |
115 | { | 115 | { |
116 | bool md5hashFound = false; | 116 | bool md5hashFound = false; |
@@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
153 | { "SessionID", token } | 153 | { "SessionID", token } |
154 | }; | 154 | }; |
155 | 155 | ||
156 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 156 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
157 | if (response["Success"].AsBoolean()) | 157 | if (response["Success"].AsBoolean()) |
158 | { | 158 | { |
159 | return true; | 159 | return true; |
@@ -175,7 +175,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
175 | { "UserID", principalID.ToString() } | 175 | { "UserID", principalID.ToString() } |
176 | }; | 176 | }; |
177 | 177 | ||
178 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 178 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
179 | if (response["Success"].AsBoolean()) | 179 | if (response["Success"].AsBoolean()) |
180 | { | 180 | { |
181 | return true; | 181 | return true; |
@@ -198,7 +198,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
198 | { "UserID", principalID.ToString() } | 198 | { "UserID", principalID.ToString() } |
199 | }; | 199 | }; |
200 | 200 | ||
201 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 201 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
202 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) | 202 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) |
203 | { | 203 | { |
204 | OSDMap userMap = (OSDMap)response["User"]; | 204 | OSDMap userMap = (OSDMap)response["User"]; |
@@ -218,7 +218,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
218 | { "UserID", principalID.ToString() } | 218 | { "UserID", principalID.ToString() } |
219 | }; | 219 | }; |
220 | 220 | ||
221 | response = WebUtil.PostToService(m_serverUrl, requestArgs); | 221 | response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
222 | bool success = response["Success"].AsBoolean(); | 222 | bool success = response["Success"].AsBoolean(); |
223 | 223 | ||
224 | if (!success) | 224 | if (!success) |
@@ -297,7 +297,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
297 | { "UserID", userID.ToString() } | 297 | { "UserID", userID.ToString() } |
298 | }; | 298 | }; |
299 | 299 | ||
300 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 300 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
301 | if (response["Success"].AsBoolean()) | 301 | if (response["Success"].AsBoolean()) |
302 | return response["SessionID"].AsUUID().ToString(); | 302 | return response["SessionID"].AsUUID().ToString(); |
303 | else | 303 | else |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs index 841bfa0..a397740 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs | |||
@@ -122,7 +122,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
122 | { "UserID", userID.ToString() } | 122 | { "UserID", userID.ToString() } |
123 | }; | 123 | }; |
124 | 124 | ||
125 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 125 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
126 | if (response["Success"].AsBoolean()) | 126 | if (response["Success"].AsBoolean()) |
127 | { | 127 | { |
128 | OSDMap map = null; | 128 | OSDMap map = null; |
@@ -168,7 +168,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
168 | { "LLPackedAppearance", OSDParser.SerializeJsonString(map) } | 168 | { "LLPackedAppearance", OSDParser.SerializeJsonString(map) } |
169 | }; | 169 | }; |
170 | 170 | ||
171 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 171 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
172 | bool success = response["Success"].AsBoolean(); | 172 | bool success = response["Success"].AsBoolean(); |
173 | 173 | ||
174 | if (! success) | 174 | if (! success) |
@@ -189,7 +189,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
189 | { "UserID", userID.ToString() } | 189 | { "UserID", userID.ToString() } |
190 | }; | 190 | }; |
191 | 191 | ||
192 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 192 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
193 | if (response["Success"].AsBoolean()) | 193 | if (response["Success"].AsBoolean()) |
194 | { | 194 | { |
195 | OSDMap map = null; | 195 | OSDMap map = null; |
@@ -306,7 +306,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
306 | { "LLAttachments", OSDParser.SerializeJsonString(items) } | 306 | { "LLAttachments", OSDParser.SerializeJsonString(items) } |
307 | }; | 307 | }; |
308 | 308 | ||
309 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 309 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
310 | bool success = response["Success"].AsBoolean(); | 310 | bool success = response["Success"].AsBoolean(); |
311 | 311 | ||
312 | if (!success) | 312 | if (!success) |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs new file mode 100644 index 0000000..764e71f --- /dev/null +++ b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs | |||
@@ -0,0 +1,180 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Web; | ||
34 | |||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using Mono.Addins; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | |||
42 | using OpenSim.Framework; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
47 | |||
48 | namespace OpenSim.Services.Connectors.SimianGrid | ||
49 | { | ||
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")] | ||
51 | public class SimianExternalCapsModule : INonSharedRegionModule, IExternalCapsModule | ||
52 | { | ||
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | private bool m_enabled = true; | ||
56 | private Scene m_scene; | ||
57 | private String m_simianURL; | ||
58 | |||
59 | #region IRegionModule Members | ||
60 | |||
61 | public string Name | ||
62 | { | ||
63 | get { return this.GetType().Name; } | ||
64 | } | ||
65 | |||
66 | public void Initialise(IConfigSource config) | ||
67 | { | ||
68 | try | ||
69 | { | ||
70 | IConfig m_config; | ||
71 | |||
72 | if ((m_config = config.Configs["SimianExternalCaps"]) != null) | ||
73 | { | ||
74 | m_enabled = m_config.GetBoolean("Enabled", m_enabled); | ||
75 | if ((m_config = config.Configs["SimianGrid"]) != null) | ||
76 | { | ||
77 | m_simianURL = m_config.GetString("SimianServiceURL"); | ||
78 | if (String.IsNullOrEmpty(m_simianURL)) | ||
79 | { | ||
80 | //m_log.DebugFormat("[SimianGrid] service URL is not defined"); | ||
81 | m_enabled = false; | ||
82 | return; | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | else | ||
87 | m_enabled = false; | ||
88 | } | ||
89 | catch (Exception e) | ||
90 | { | ||
91 | m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message); | ||
92 | return; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public void PostInitialise() { } | ||
97 | public void Close() { } | ||
98 | |||
99 | public void AddRegion(Scene scene) | ||
100 | { | ||
101 | if (! m_enabled) | ||
102 | return; | ||
103 | |||
104 | m_scene = scene; | ||
105 | m_scene.RegisterModuleInterface<IExternalCapsModule>(this); | ||
106 | } | ||
107 | |||
108 | public void RemoveRegion(Scene scene) | ||
109 | { | ||
110 | if (! m_enabled) | ||
111 | return; | ||
112 | |||
113 | m_scene.EventManager.OnRegisterCaps -= RegisterCapsEventHandler; | ||
114 | m_scene.EventManager.OnDeregisterCaps -= DeregisterCapsEventHandler; | ||
115 | } | ||
116 | |||
117 | public void RegionLoaded(Scene scene) | ||
118 | { | ||
119 | if (! m_enabled) | ||
120 | return; | ||
121 | |||
122 | m_scene.EventManager.OnRegisterCaps += RegisterCapsEventHandler; | ||
123 | m_scene.EventManager.OnDeregisterCaps += DeregisterCapsEventHandler; | ||
124 | } | ||
125 | |||
126 | public Type ReplaceableInterface | ||
127 | { | ||
128 | get { return null; } | ||
129 | } | ||
130 | |||
131 | #endregion | ||
132 | |||
133 | #region IExternalCapsModule | ||
134 | // Eg http://grid.sciencesim.com/GridPublic/%CAP%/%OP%/" | ||
135 | public bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel) | ||
136 | { | ||
137 | UUID cap = UUID.Random(); | ||
138 | |||
139 | // Call to simian to register the cap we generated | ||
140 | // NameValueCollection requestArgs = new NameValueCollection | ||
141 | // { | ||
142 | // { "RequestMethod", "AddCapability" }, | ||
143 | // { "Resource", "user" }, | ||
144 | // { "Expiration", 0 }, | ||
145 | // { "OwnerID", agentID.ToString() }, | ||
146 | // { "CapabilityID", cap.ToString() } | ||
147 | // }; | ||
148 | |||
149 | // OSDMap response = SimianGrid.PostToService(m_simianURL, requestArgs); | ||
150 | |||
151 | Dictionary<String,String> subs = new Dictionary<String,String>(); | ||
152 | subs["%OP%"] = capName; | ||
153 | subs["%USR%"] = agentID.ToString(); | ||
154 | subs["%CAP%"] = cap.ToString(); | ||
155 | subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString(); | ||
156 | |||
157 | caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs)); | ||
158 | return true; | ||
159 | } | ||
160 | |||
161 | #endregion | ||
162 | |||
163 | #region EventHandlers | ||
164 | public void RegisterCapsEventHandler(UUID agentID, Caps caps) { } | ||
165 | public void DeregisterCapsEventHandler(UUID agentID, Caps caps) { } | ||
166 | #endregion | ||
167 | |||
168 | private String ExpandSkeletonURL(String urlSkel, Dictionary<String,String> subs) | ||
169 | { | ||
170 | String result = urlSkel; | ||
171 | |||
172 | foreach (KeyValuePair<String,String> kvp in subs) | ||
173 | { | ||
174 | result = result.Replace(kvp.Key,kvp.Value); | ||
175 | } | ||
176 | |||
177 | return result; | ||
178 | } | ||
179 | } | ||
180 | } \ No newline at end of file | ||
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs index 7422d94..9a8164c 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs | |||
@@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
153 | { "Value", flags.ToString() } | 153 | { "Value", flags.ToString() } |
154 | }; | 154 | }; |
155 | 155 | ||
156 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 156 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
157 | bool success = response["Success"].AsBoolean(); | 157 | bool success = response["Success"].AsBoolean(); |
158 | 158 | ||
159 | if (!success) | 159 | if (!success) |
@@ -180,7 +180,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
180 | { "Key", friend } | 180 | { "Key", friend } |
181 | }; | 181 | }; |
182 | 182 | ||
183 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 183 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
184 | bool success = response["Success"].AsBoolean(); | 184 | bool success = response["Success"].AsBoolean(); |
185 | 185 | ||
186 | if (!success) | 186 | if (!success) |
@@ -200,7 +200,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
200 | { "Type", "Friend" } | 200 | { "Type", "Friend" } |
201 | }; | 201 | }; |
202 | 202 | ||
203 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 203 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
204 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | 204 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) |
205 | { | 205 | { |
206 | return (OSDArray)response["Entries"]; | 206 | return (OSDArray)response["Entries"]; |
@@ -221,7 +221,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
221 | { "Type", "Friend" } | 221 | { "Type", "Friend" } |
222 | }; | 222 | }; |
223 | 223 | ||
224 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 224 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
225 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | 225 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) |
226 | { | 226 | { |
227 | return (OSDArray)response["Entries"]; | 227 | return (OSDArray)response["Entries"]; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs index 847319c..a35d749 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs | |||
@@ -26,8 +26,122 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
29 | using Mono.Addins; | 33 | using Mono.Addins; |
30 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
31 | 41 | ||
32 | [assembly: Addin("SimianGrid", "1.0")] | 42 | [assembly: Addin("SimianGrid", OpenSim.VersionInfo.VersionNumber)] |
33 | [assembly: AddinDependency("OpenSim", "0.5")] | 43 | [assembly: AddinDependency("OpenSim.Region.Framework", OpenSim.VersionInfo.VersionNumber)] |
44 | |||
45 | namespace OpenSim.Services.Connectors.SimianGrid | ||
46 | { | ||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")] | ||
48 | public class SimianGrid : ISharedRegionModule | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private IConfig m_config = null; | ||
53 | |||
54 | private String m_simianURL; | ||
55 | |||
56 | #region IRegionModule Members | ||
57 | |||
58 | public string Name | ||
59 | { | ||
60 | get { return this.GetType().Name; } | ||
61 | } | ||
62 | |||
63 | public void Initialise(IConfigSource config) | ||
64 | { | ||
65 | try | ||
66 | { | ||
67 | m_config = config.Configs["SimianGrid"]; | ||
68 | |||
69 | if (m_config != null) | ||
70 | { | ||
71 | m_simianURL = m_config.GetString("SimianServiceURL"); | ||
72 | if (String.IsNullOrEmpty(m_simianURL)) | ||
73 | { | ||
74 | // m_log.DebugFormat("[SimianGrid] service URL is not defined"); | ||
75 | return; | ||
76 | } | ||
77 | |||
78 | InitialiseSimCap(); | ||
79 | SimulatorCapability = SimulatorCapability.Trim(); | ||
80 | m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability); | ||
81 | } | ||
82 | } | ||
83 | catch (Exception e) | ||
84 | { | ||
85 | m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message); | ||
86 | return; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | public void PostInitialise() { } | ||
91 | public void Close() { } | ||
92 | public void AddRegion(Scene scene) { } | ||
93 | public void RemoveRegion(Scene scene) { } | ||
94 | public void RegionLoaded(Scene scene) { } | ||
95 | |||
96 | public Type ReplaceableInterface | ||
97 | { | ||
98 | get { return null; } | ||
99 | } | ||
100 | |||
101 | ///<summary> | ||
102 | /// Try a variety of methods for finding the simian simulator capability; first check the | ||
103 | /// configuration itself, then look for a file that contains the cap, then finally look | ||
104 | /// for an environment variable that contains it. | ||
105 | ///</summary> | ||
106 | private void InitialiseSimCap() | ||
107 | { | ||
108 | if (m_config.Contains("SimulatorCapability")) | ||
109 | { | ||
110 | SimulatorCapability = m_config.GetString("SimulatorCapability"); | ||
111 | return; | ||
112 | } | ||
113 | |||
114 | if (m_config.Contains("SimulatorCapabilityFile")) | ||
115 | { | ||
116 | String filename = m_config.GetString("SimulatorCapabilityFile"); | ||
117 | if (System.IO.File.Exists(filename)) | ||
118 | { | ||
119 | SimulatorCapability = System.IO.File.ReadAllText(filename); | ||
120 | return; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | if (m_config.Contains("SimulatorCapabilityVariable")) | ||
125 | { | ||
126 | String envname = m_config.GetString("SimulatorCapabilityVariable"); | ||
127 | String envvalue = System.Environment.GetEnvironmentVariable(envname); | ||
128 | if (envvalue != null) | ||
129 | { | ||
130 | SimulatorCapability = envvalue; | ||
131 | return; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability"); | ||
136 | } | ||
137 | |||
138 | #endregion | ||
139 | |||
140 | public static String SimulatorCapability = UUID.Zero.ToString(); | ||
141 | public static OSDMap PostToService(string url, NameValueCollection data) | ||
142 | { | ||
143 | data["cap"] = SimulatorCapability; | ||
144 | return WebUtil.PostToService(url, data); | ||
145 | } | ||
146 | } | ||
147 | } \ No newline at end of file | ||
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs index 93fdae3..8375c95 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Collections.Specialized; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Net; | 32 | using System.Net; |
32 | using System.IO; | 33 | using System.IO; |
@@ -43,7 +44,8 @@ using OpenSim.Region.Framework.Scenes; | |||
43 | using OpenMetaverse; | 44 | using OpenMetaverse; |
44 | using OpenMetaverse.StructuredData; | 45 | using OpenMetaverse.StructuredData; |
45 | 46 | ||
46 | namespace OpenSim.Region.OptionalModules.Simian | 47 | //namespace OpenSim.Region.OptionalModules.Simian |
48 | namespace OpenSim.Services.Connectors.SimianGrid | ||
47 | { | 49 | { |
48 | /// <summary> | 50 | /// <summary> |
49 | /// </summary> | 51 | /// </summary> |
@@ -179,7 +181,6 @@ namespace OpenSim.Region.OptionalModules.Simian | |||
179 | m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName); | 181 | m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}",scene.RegionInfo.RegionName); |
180 | 182 | ||
181 | // Create a PNG map tile and upload it to the AddMapTile API | 183 | // Create a PNG map tile and upload it to the AddMapTile API |
182 | byte[] pngData = Utils.EmptyBytes; | ||
183 | IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); | 184 | IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); |
184 | if (tileGenerator == null) | 185 | if (tileGenerator == null) |
185 | { | 186 | { |
@@ -187,76 +188,79 @@ namespace OpenSim.Region.OptionalModules.Simian | |||
187 | return; | 188 | return; |
188 | } | 189 | } |
189 | 190 | ||
190 | using (Image mapTile = tileGenerator.CreateMapTile()) | 191 | using (Bitmap mapTile = tileGenerator.CreateMapTile()) |
191 | { | ||
192 | using (MemoryStream stream = new MemoryStream()) | ||
193 | { | ||
194 | mapTile.Save(stream, ImageFormat.Png); | ||
195 | pngData = stream.ToArray(); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() | ||
200 | { | ||
201 | new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()), | ||
202 | new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()), | ||
203 | new MultipartForm.File("Tile", "tile.png", "image/png", pngData) | ||
204 | }; | ||
205 | |||
206 | string errorMessage = null; | ||
207 | int tickstart = Util.EnvironmentTickCount(); | ||
208 | |||
209 | // Make the remote storage request | ||
210 | try | ||
211 | { | 192 | { |
212 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl); | 193 | if (mapTile != null) |
213 | request.Timeout = 20000; | ||
214 | request.ReadWriteTimeout = 5000; | ||
215 | |||
216 | using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) | ||
217 | { | 194 | { |
218 | using (Stream responseStream = response.GetResponseStream()) | 195 | // If the region/maptile is legacy sized, just upload the one tile like it has always been done |
196 | if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) | ||
219 | { | 197 | { |
220 | string responseStr = responseStream.GetStreamString(); | 198 | ConvertAndUploadMaptile(mapTile, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY); |
221 | OSD responseOSD = OSDParser.Deserialize(responseStr); | 199 | } |
222 | if (responseOSD.Type == OSDType.Map) | 200 | else |
201 | { | ||
202 | // For larger regions (varregion) we must cut the region image into legacy sized | ||
203 | // pieces since that is how the maptile system works. | ||
204 | // Note the assumption that varregions are always a multiple of legacy size. | ||
205 | for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize) | ||
223 | { | 206 | { |
224 | OSDMap responseMap = (OSDMap)responseOSD; | 207 | for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize) |
225 | if (responseMap["Success"].AsBoolean()) | 208 | { |
226 | return; | 209 | // Images are addressed from the upper left corner so have to do funny |
210 | // math to pick out the sub-tile since regions are numbered from | ||
211 | // the lower left. | ||
212 | Rectangle rect = new Rectangle( | ||
213 | (int)xx, | ||
214 | mapTile.Height - (int)yy - (int)Constants.RegionSize, | ||
215 | (int)Constants.RegionSize, (int)Constants.RegionSize); | ||
227 | 216 | ||
228 | errorMessage = "Upload failed: " + responseMap["Message"].AsString(); | 217 | using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat)) |
229 | } | 218 | { |
230 | else | 219 | uint locX = scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize); |
231 | { | 220 | uint locY = scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize); |
232 | errorMessage = "Response format was invalid:\n" + responseStr; | 221 | |
222 | ConvertAndUploadMaptile(subMapTile, locX, locY); | ||
223 | } | ||
224 | } | ||
233 | } | 225 | } |
234 | } | 226 | } |
235 | } | 227 | } |
236 | } | 228 | else |
237 | catch (WebException we) | ||
238 | { | ||
239 | errorMessage = we.Message; | ||
240 | if (we.Status == WebExceptionStatus.ProtocolError) | ||
241 | { | 229 | { |
242 | HttpWebResponse webResponse = (HttpWebResponse)we.Response; | 230 | m_log.WarnFormat("[SIMIAN MAPTILE] Tile image generation failed"); |
243 | errorMessage = String.Format("[{0}] {1}", | ||
244 | webResponse.StatusCode,webResponse.StatusDescription); | ||
245 | } | 231 | } |
246 | } | 232 | } |
247 | catch (Exception ex) | 233 | |
234 | } | ||
235 | |||
236 | ///<summary> | ||
237 | /// | ||
238 | ///</summary> | ||
239 | private void ConvertAndUploadMaptile(Image mapTile, uint locX, uint locY) | ||
240 | { | ||
241 | //m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for location {0}, {1}", locX, locY); | ||
242 | |||
243 | byte[] pngData = Utils.EmptyBytes; | ||
244 | using (MemoryStream stream = new MemoryStream()) | ||
248 | { | 245 | { |
249 | errorMessage = ex.Message; | 246 | mapTile.Save(stream, ImageFormat.Png); |
247 | pngData = stream.ToArray(); | ||
250 | } | 248 | } |
251 | finally | 249 | |
250 | NameValueCollection requestArgs = new NameValueCollection | ||
251 | { | ||
252 | { "RequestMethod", "xAddMapTile" }, | ||
253 | { "X", locX.ToString() }, | ||
254 | { "Y", locY.ToString() }, | ||
255 | { "ContentType", "image/png" }, | ||
256 | { "EncodedData", System.Convert.ToBase64String(pngData) } | ||
257 | }; | ||
258 | |||
259 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); | ||
260 | if (! response["Success"].AsBoolean()) | ||
252 | { | 261 | { |
253 | // This just dumps a warning for any operation that takes more than 100 ms | 262 | m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}",response["Message"].AsString()); |
254 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | ||
255 | m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff); | ||
256 | } | 263 | } |
257 | |||
258 | m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}", | ||
259 | pngData.Length, scene.RegionInfo.RegionName, errorMessage); | ||
260 | } | 264 | } |
261 | } | 265 | } |
262 | } \ No newline at end of file | 266 | } \ No newline at end of file |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index 038a4bf..b031f21 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | |||
@@ -101,7 +101,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
101 | public string RegisterRegion(UUID scopeID, GridRegion regionInfo) | 101 | public string RegisterRegion(UUID scopeID, GridRegion regionInfo) |
102 | { | 102 | { |
103 | Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); | 103 | Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); |
104 | Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); | 104 | Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight); |
105 | 105 | ||
106 | OSDMap extraData = new OSDMap | 106 | OSDMap extraData = new OSDMap |
107 | { | 107 | { |
@@ -129,7 +129,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
129 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } | 129 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } |
130 | }; | 130 | }; |
131 | 131 | ||
132 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 132 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
133 | if (response["Success"].AsBoolean()) | 133 | if (response["Success"].AsBoolean()) |
134 | return String.Empty; | 134 | return String.Empty; |
135 | else | 135 | else |
@@ -145,7 +145,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
145 | { "Enabled", "0" } | 145 | { "Enabled", "0" } |
146 | }; | 146 | }; |
147 | 147 | ||
148 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 148 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
149 | bool success = response["Success"].AsBoolean(); | 149 | bool success = response["Success"].AsBoolean(); |
150 | 150 | ||
151 | if (!success) | 151 | if (!success) |
@@ -156,15 +156,15 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
156 | 156 | ||
157 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) | 157 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) |
158 | { | 158 | { |
159 | const int NEIGHBOR_RADIUS = 128; | ||
160 | |||
161 | GridRegion region = GetRegionByUUID(scopeID, regionID); | 159 | GridRegion region = GetRegionByUUID(scopeID, regionID); |
162 | 160 | ||
161 | int NEIGHBOR_RADIUS = Math.Max(region.RegionSizeX, region.RegionSizeY) / 2; | ||
162 | |||
163 | if (region != null) | 163 | if (region != null) |
164 | { | 164 | { |
165 | List<GridRegion> regions = GetRegionRange(scopeID, | 165 | List<GridRegion> regions = GetRegionRange(scopeID, |
166 | region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + (int)Constants.RegionSize + NEIGHBOR_RADIUS, | 166 | region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + region.RegionSizeX + NEIGHBOR_RADIUS, |
167 | region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + (int)Constants.RegionSize + NEIGHBOR_RADIUS); | 167 | region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + region.RegionSizeY + NEIGHBOR_RADIUS); |
168 | 168 | ||
169 | for (int i = 0; i < regions.Count; i++) | 169 | for (int i = 0; i < regions.Count; i++) |
170 | { | 170 | { |
@@ -192,7 +192,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
192 | 192 | ||
193 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); | 193 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); |
194 | 194 | ||
195 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 195 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
196 | if (response["Success"].AsBoolean()) | 196 | if (response["Success"].AsBoolean()) |
197 | { | 197 | { |
198 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); | 198 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); |
@@ -220,7 +220,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
220 | 220 | ||
221 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); | 221 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); |
222 | 222 | ||
223 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 223 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
224 | if (response["Success"].AsBoolean()) | 224 | if (response["Success"].AsBoolean()) |
225 | { | 225 | { |
226 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString()); | 226 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString()); |
@@ -229,7 +229,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
229 | else | 229 | else |
230 | { | 230 | { |
231 | // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}", | 231 | // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}", |
232 | // x / Constants.RegionSize, y / Constants.RegionSize); | 232 | // Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y)); |
233 | return null; | 233 | return null; |
234 | } | 234 | } |
235 | } | 235 | } |
@@ -261,7 +261,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
261 | 261 | ||
262 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); | 262 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); |
263 | 263 | ||
264 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 264 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
265 | if (response["Success"].AsBoolean()) | 265 | if (response["Success"].AsBoolean()) |
266 | { | 266 | { |
267 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); | 267 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); |
@@ -299,7 +299,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
299 | //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); | 299 | //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); |
300 | 300 | ||
301 | 301 | ||
302 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 302 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
303 | if (response["Success"].AsBoolean()) | 303 | if (response["Success"].AsBoolean()) |
304 | { | 304 | { |
305 | OSDArray array = response["Scenes"] as OSDArray; | 305 | OSDArray array = response["Scenes"] as OSDArray; |
@@ -330,6 +330,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
330 | return new List<GridRegion>(0); | 330 | return new List<GridRegion>(0); |
331 | } | 331 | } |
332 | 332 | ||
333 | public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID) | ||
334 | { | ||
335 | // TODO: Allow specifying the default grid location | ||
336 | return GetDefaultRegions(scopeID); | ||
337 | } | ||
338 | |||
333 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) | 339 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) |
334 | { | 340 | { |
335 | GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true); | 341 | GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true); |
@@ -350,7 +356,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
350 | { "Enabled", "1" } | 356 | { "Enabled", "1" } |
351 | }; | 357 | }; |
352 | 358 | ||
353 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 359 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
354 | if (response["Success"].AsBoolean()) | 360 | if (response["Success"].AsBoolean()) |
355 | { | 361 | { |
356 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); | 362 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); |
@@ -380,7 +386,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
380 | 386 | ||
381 | m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString()); | 387 | m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString()); |
382 | 388 | ||
383 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 389 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
384 | if (response["Success"].AsBoolean()) | 390 | if (response["Success"].AsBoolean()) |
385 | { | 391 | { |
386 | OSDMap extraData = response["ExtraData"] as OSDMap; | 392 | OSDMap extraData = response["ExtraData"] as OSDMap; |
@@ -396,6 +402,13 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
396 | return -1; | 402 | return -1; |
397 | } | 403 | } |
398 | } | 404 | } |
405 | |||
406 | public Dictionary<string, object> GetExtraFeatures() | ||
407 | { | ||
408 | /// See SimulatorFeaturesModule - Need to get map, search and destination guide | ||
409 | Dictionary<string, object> extraFeatures = new Dictionary<string, object>(); | ||
410 | return extraFeatures; | ||
411 | } | ||
399 | 412 | ||
400 | #endregion IGridService | 413 | #endregion IGridService |
401 | 414 | ||
@@ -410,7 +423,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
410 | if (onlyEnabled) | 423 | if (onlyEnabled) |
411 | requestArgs["Enabled"] = "1"; | 424 | requestArgs["Enabled"] = "1"; |
412 | 425 | ||
413 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 426 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
414 | if (response["Success"].AsBoolean()) | 427 | if (response["Success"].AsBoolean()) |
415 | { | 428 | { |
416 | return ResponseToGridRegion(response); | 429 | return ResponseToGridRegion(response); |
@@ -437,9 +450,13 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
437 | region.RegionName = response["Name"].AsString(); | 450 | region.RegionName = response["Name"].AsString(); |
438 | 451 | ||
439 | Vector3d minPosition = response["MinPosition"].AsVector3d(); | 452 | Vector3d minPosition = response["MinPosition"].AsVector3d(); |
453 | Vector3d maxPosition = response["MaxPosition"].AsVector3d(); | ||
440 | region.RegionLocX = (int)minPosition.X; | 454 | region.RegionLocX = (int)minPosition.X; |
441 | region.RegionLocY = (int)minPosition.Y; | 455 | region.RegionLocY = (int)minPosition.Y; |
442 | 456 | ||
457 | region.RegionSizeX = (int)maxPosition.X - (int)minPosition.X; | ||
458 | region.RegionSizeY = (int)maxPosition.Y - (int)minPosition.Y; | ||
459 | |||
443 | if ( ! extraData["HyperGrid"] ) { | 460 | if ( ! extraData["HyperGrid"] ) { |
444 | Uri httpAddress = response["Address"].AsUri(); | 461 | Uri httpAddress = response["Address"].AsUri(); |
445 | region.ExternalHostName = httpAddress.Host; | 462 | region.ExternalHostName = httpAddress.Host; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs index a391275..e793420 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs | |||
@@ -38,12 +38,14 @@ using OpenSim.Framework; | |||
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using PermissionMask = OpenSim.Framework.PermissionMask; | ||
41 | 42 | ||
42 | namespace OpenSim.Services.Connectors.SimianGrid | 43 | namespace OpenSim.Services.Connectors.SimianGrid |
43 | { | 44 | { |
44 | /// <summary> | 45 | /// <summary> |
45 | /// Permissions bitflags | 46 | /// Permissions bitflags |
46 | /// </summary> | 47 | /// </summary> |
48 | /* | ||
47 | [Flags] | 49 | [Flags] |
48 | public enum PermissionMask : uint | 50 | public enum PermissionMask : uint |
49 | { | 51 | { |
@@ -55,6 +57,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
55 | Damage = 1 << 20, | 57 | Damage = 1 << 20, |
56 | All = 0x7FFFFFFF | 58 | All = 0x7FFFFFFF |
57 | } | 59 | } |
60 | */ | ||
58 | 61 | ||
59 | /// <summary> | 62 | /// <summary> |
60 | /// Connects avatar inventories to the SimianGrid backend | 63 | /// Connects avatar inventories to the SimianGrid backend |
@@ -71,6 +74,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
71 | // private object m_gestureSyncRoot = new object(); | 74 | // private object m_gestureSyncRoot = new object(); |
72 | private bool m_Enabled = false; | 75 | private bool m_Enabled = false; |
73 | 76 | ||
77 | private const double CACHE_EXPIRATION_SECONDS = 20.0; | ||
78 | private static ExpiringCache<UUID, InventoryItemBase> m_ItemCache; | ||
79 | |||
74 | #region ISharedRegionModule | 80 | #region ISharedRegionModule |
75 | 81 | ||
76 | public Type ReplaceableInterface { get { return null; } } | 82 | public Type ReplaceableInterface { get { return null; } } |
@@ -96,6 +102,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
96 | url = url + '/'; | 102 | url = url + '/'; |
97 | m_serverUrl = url; | 103 | m_serverUrl = url; |
98 | 104 | ||
105 | if (m_ItemCache == null) | ||
106 | m_ItemCache = new ExpiringCache<UUID, InventoryItemBase>(); | ||
107 | |||
99 | } | 108 | } |
100 | 109 | ||
101 | public void Initialise(IConfigSource source) | 110 | public void Initialise(IConfigSource source) |
@@ -129,6 +138,8 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
129 | { | 138 | { |
130 | m_userServerUrl = serviceUrl; | 139 | m_userServerUrl = serviceUrl; |
131 | m_Enabled = true; | 140 | m_Enabled = true; |
141 | if (m_ItemCache == null) | ||
142 | m_ItemCache = new ExpiringCache<UUID, InventoryItemBase>(); | ||
132 | } | 143 | } |
133 | } | 144 | } |
134 | } | 145 | } |
@@ -153,7 +164,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
153 | { "OwnerID", userID.ToString() } | 164 | { "OwnerID", userID.ToString() } |
154 | }; | 165 | }; |
155 | 166 | ||
156 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 167 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
157 | bool success = response["Success"].AsBoolean(); | 168 | bool success = response["Success"].AsBoolean(); |
158 | 169 | ||
159 | if (!success) | 170 | if (!success) |
@@ -179,7 +190,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
179 | { "ChildrenOnly", "0" } | 190 | { "ChildrenOnly", "0" } |
180 | }; | 191 | }; |
181 | 192 | ||
182 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 193 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
183 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 194 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
184 | { | 195 | { |
185 | OSDArray items = (OSDArray)response["Items"]; | 196 | OSDArray items = (OSDArray)response["Items"]; |
@@ -194,37 +205,6 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
194 | } | 205 | } |
195 | 206 | ||
196 | /// <summary> | 207 | /// <summary> |
197 | /// Synchronous inventory fetch. | ||
198 | /// </summary> | ||
199 | /// <param name="userID"></param> | ||
200 | /// <returns></returns> | ||
201 | [Obsolete] | ||
202 | public InventoryCollection GetUserInventory(UUID userID) | ||
203 | { | ||
204 | m_log.Error("[SIMIAN INVENTORY CONNECTOR]: Obsolete GetUserInventory called for " + userID); | ||
205 | |||
206 | InventoryCollection inventory = new InventoryCollection(); | ||
207 | inventory.UserID = userID; | ||
208 | inventory.Folders = new List<InventoryFolderBase>(); | ||
209 | inventory.Items = new List<InventoryItemBase>(); | ||
210 | |||
211 | return inventory; | ||
212 | } | ||
213 | |||
214 | /// <summary> | ||
215 | /// Request the inventory for a user. This is an asynchronous operation that will call the callback when the | ||
216 | /// inventory has been received | ||
217 | /// </summary> | ||
218 | /// <param name="userID"></param> | ||
219 | /// <param name="callback"></param> | ||
220 | [Obsolete] | ||
221 | public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) | ||
222 | { | ||
223 | m_log.Error("[SIMIAN INVENTORY CONNECTOR]: Obsolete GetUserInventory called for " + userID); | ||
224 | callback(new List<InventoryFolderImpl>(0), new List<InventoryItemBase>(0)); | ||
225 | } | ||
226 | |||
227 | /// <summary> | ||
228 | /// Retrieve the root inventory folder for the given user. | 208 | /// Retrieve the root inventory folder for the given user. |
229 | /// </summary> | 209 | /// </summary> |
230 | /// <param name="userID"></param> | 210 | /// <param name="userID"></param> |
@@ -241,7 +221,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
241 | { "ChildrenOnly", "1" } | 221 | { "ChildrenOnly", "1" } |
242 | }; | 222 | }; |
243 | 223 | ||
244 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 224 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
245 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 225 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
246 | { | 226 | { |
247 | OSDArray items = (OSDArray)response["Items"]; | 227 | OSDArray items = (OSDArray)response["Items"]; |
@@ -260,7 +240,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
260 | /// <param name="userID"></param> | 240 | /// <param name="userID"></param> |
261 | /// <param name="type"></param> | 241 | /// <param name="type"></param> |
262 | /// <returns></returns> | 242 | /// <returns></returns> |
263 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | 243 | public InventoryFolderBase GetFolderForType(UUID userID, FolderType type) |
264 | { | 244 | { |
265 | string contentType = SLUtil.SLAssetTypeToContentType((int)type); | 245 | string contentType = SLUtil.SLAssetTypeToContentType((int)type); |
266 | 246 | ||
@@ -271,7 +251,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
271 | { "OwnerID", userID.ToString() } | 251 | { "OwnerID", userID.ToString() } |
272 | }; | 252 | }; |
273 | 253 | ||
274 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 254 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
275 | if (response["Success"].AsBoolean() && response["Folder"] is OSDMap) | 255 | if (response["Success"].AsBoolean() && response["Folder"] is OSDMap) |
276 | { | 256 | { |
277 | OSDMap folder = (OSDMap)response["Folder"]; | 257 | OSDMap folder = (OSDMap)response["Folder"]; |
@@ -299,6 +279,10 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
299 | /// <returns></returns> | 279 | /// <returns></returns> |
300 | public InventoryItemBase GetItem(InventoryItemBase item) | 280 | public InventoryItemBase GetItem(InventoryItemBase item) |
301 | { | 281 | { |
282 | InventoryItemBase retrieved = null; | ||
283 | if (m_ItemCache.TryGetValue(item.ID, out retrieved)) | ||
284 | return retrieved; | ||
285 | |||
302 | NameValueCollection requestArgs = new NameValueCollection | 286 | NameValueCollection requestArgs = new NameValueCollection |
303 | { | 287 | { |
304 | { "RequestMethod", "GetInventoryNode" }, | 288 | { "RequestMethod", "GetInventoryNode" }, |
@@ -309,7 +293,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
309 | { "ChildrenOnly", "1" } | 293 | { "ChildrenOnly", "1" } |
310 | }; | 294 | }; |
311 | 295 | ||
312 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 296 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
313 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 297 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
314 | { | 298 | { |
315 | List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]); | 299 | List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]); |
@@ -320,7 +304,11 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
320 | for (int i = 0; i < items.Count; i++) | 304 | for (int i = 0; i < items.Count; i++) |
321 | { | 305 | { |
322 | if (items[i].ID == item.ID) | 306 | if (items[i].ID == item.ID) |
323 | return items[i]; | 307 | { |
308 | retrieved = items[i]; | ||
309 | m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS); | ||
310 | return retrieved; | ||
311 | } | ||
324 | } | 312 | } |
325 | } | 313 | } |
326 | } | 314 | } |
@@ -329,6 +317,21 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
329 | return null; | 317 | return null; |
330 | } | 318 | } |
331 | 319 | ||
320 | public InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs) | ||
321 | { | ||
322 | InventoryItemBase[] result = new InventoryItemBase[itemIDs.Length]; | ||
323 | int i = 0; | ||
324 | InventoryItemBase item = new InventoryItemBase(); | ||
325 | item.Owner = principalID; | ||
326 | foreach (UUID id in itemIDs) | ||
327 | { | ||
328 | item.ID = id; | ||
329 | result[i++] = GetItem(item); | ||
330 | } | ||
331 | |||
332 | return result; | ||
333 | } | ||
334 | |||
332 | /// <summary> | 335 | /// <summary> |
333 | /// Get a folder, given by its UUID | 336 | /// Get a folder, given by its UUID |
334 | /// </summary> | 337 | /// </summary> |
@@ -346,7 +349,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
346 | { "ChildrenOnly", "1" } | 349 | { "ChildrenOnly", "1" } |
347 | }; | 350 | }; |
348 | 351 | ||
349 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 352 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
350 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 353 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
351 | { | 354 | { |
352 | OSDArray items = (OSDArray)response["Items"]; | 355 | OSDArray items = (OSDArray)response["Items"]; |
@@ -368,7 +371,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
368 | public InventoryCollection GetFolderContent(UUID userID, UUID folderID) | 371 | public InventoryCollection GetFolderContent(UUID userID, UUID folderID) |
369 | { | 372 | { |
370 | InventoryCollection inventory = new InventoryCollection(); | 373 | InventoryCollection inventory = new InventoryCollection(); |
371 | inventory.UserID = userID; | 374 | inventory.OwnerID = userID; |
372 | 375 | ||
373 | NameValueCollection requestArgs = new NameValueCollection | 376 | NameValueCollection requestArgs = new NameValueCollection |
374 | { | 377 | { |
@@ -380,7 +383,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
380 | { "ChildrenOnly", "1" } | 383 | { "ChildrenOnly", "1" } |
381 | }; | 384 | }; |
382 | 385 | ||
383 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 386 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
384 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 387 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
385 | { | 388 | { |
386 | OSDArray items = (OSDArray)response["Items"]; | 389 | OSDArray items = (OSDArray)response["Items"]; |
@@ -399,6 +402,18 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
399 | return inventory; | 402 | return inventory; |
400 | } | 403 | } |
401 | 404 | ||
405 | public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs) | ||
406 | { | ||
407 | InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length]; | ||
408 | int i = 0; | ||
409 | foreach (UUID fid in folderIDs) | ||
410 | { | ||
411 | invColl[i++] = GetFolderContent(principalID, fid); | ||
412 | } | ||
413 | |||
414 | return invColl; | ||
415 | } | ||
416 | |||
402 | /// <summary> | 417 | /// <summary> |
403 | /// Gets the items inside a folder | 418 | /// Gets the items inside a folder |
404 | /// </summary> | 419 | /// </summary> |
@@ -408,7 +423,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
408 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) | 423 | public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID) |
409 | { | 424 | { |
410 | InventoryCollection inventory = new InventoryCollection(); | 425 | InventoryCollection inventory = new InventoryCollection(); |
411 | inventory.UserID = userID; | 426 | inventory.OwnerID = userID; |
412 | 427 | ||
413 | NameValueCollection requestArgs = new NameValueCollection | 428 | NameValueCollection requestArgs = new NameValueCollection |
414 | { | 429 | { |
@@ -420,7 +435,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
420 | { "ChildrenOnly", "1" } | 435 | { "ChildrenOnly", "1" } |
421 | }; | 436 | }; |
422 | 437 | ||
423 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 438 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
424 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 439 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
425 | { | 440 | { |
426 | OSDArray items = (OSDArray)response["Items"]; | 441 | OSDArray items = (OSDArray)response["Items"]; |
@@ -451,7 +466,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
451 | { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) } | 466 | { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) } |
452 | }; | 467 | }; |
453 | 468 | ||
454 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 469 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
455 | bool success = response["Success"].AsBoolean(); | 470 | bool success = response["Success"].AsBoolean(); |
456 | 471 | ||
457 | if (!success) | 472 | if (!success) |
@@ -515,7 +530,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
515 | { "ItemID", itemID.ToString() } | 530 | { "ItemID", itemID.ToString() } |
516 | }; | 531 | }; |
517 | 532 | ||
518 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 533 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
519 | bool success = response["Success"].AsBoolean(); | 534 | bool success = response["Success"].AsBoolean(); |
520 | 535 | ||
521 | if (!success) | 536 | if (!success) |
@@ -543,7 +558,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
543 | { "FolderID", folder.ID.ToString() } | 558 | { "FolderID", folder.ID.ToString() } |
544 | }; | 559 | }; |
545 | 560 | ||
546 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 561 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
547 | bool success = response["Success"].AsBoolean(); | 562 | bool success = response["Success"].AsBoolean(); |
548 | 563 | ||
549 | if (!success) | 564 | if (!success) |
@@ -565,7 +580,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
565 | // A folder of UUID.Zero means we need to find the most appropriate home for this item | 580 | // A folder of UUID.Zero means we need to find the most appropriate home for this item |
566 | if (item.Folder == UUID.Zero) | 581 | if (item.Folder == UUID.Zero) |
567 | { | 582 | { |
568 | InventoryFolderBase folder = GetFolderForType(item.Owner, (AssetType)item.AssetType); | 583 | InventoryFolderBase folder = null; |
584 | if (Enum.IsDefined(typeof(FolderType), (sbyte)item.AssetType)) | ||
585 | folder = GetFolderForType(item.Owner, (FolderType)item.AssetType); | ||
569 | if (folder != null && folder.ID != UUID.Zero) | 586 | if (folder != null && folder.ID != UUID.Zero) |
570 | item.Folder = folder.ID; | 587 | item.Folder = folder.ID; |
571 | else | 588 | else |
@@ -620,7 +637,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
620 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } | 637 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } |
621 | }; | 638 | }; |
622 | 639 | ||
623 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 640 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
624 | bool success = response["Success"].AsBoolean(); | 641 | bool success = response["Success"].AsBoolean(); |
625 | 642 | ||
626 | if (!success) | 643 | if (!success) |
@@ -844,7 +861,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
844 | { "Items", String.Join(",", itemIDs) } | 861 | { "Items", String.Join(",", itemIDs) } |
845 | }; | 862 | }; |
846 | 863 | ||
847 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 864 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
848 | bool success = response["Success"].AsBoolean(); | 865 | bool success = response["Success"].AsBoolean(); |
849 | 866 | ||
850 | if (!success) | 867 | if (!success) |
@@ -882,7 +899,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
882 | { "UserID", userID.ToString() } | 899 | { "UserID", userID.ToString() } |
883 | }; | 900 | }; |
884 | 901 | ||
885 | OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); | 902 | OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs); |
886 | if (response["Success"].AsBoolean()) | 903 | if (response["Success"].AsBoolean()) |
887 | { | 904 | { |
888 | OSDMap user = response["User"] as OSDMap; | 905 | OSDMap user = response["User"] as OSDMap; |
@@ -913,7 +930,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
913 | { "Gestures", OSDParser.SerializeJsonString(gestures) } | 930 | { "Gestures", OSDParser.SerializeJsonString(gestures) } |
914 | }; | 931 | }; |
915 | 932 | ||
916 | OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); | 933 | OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs); |
917 | if (!response["Success"].AsBoolean()) | 934 | if (!response["Success"].AsBoolean()) |
918 | { | 935 | { |
919 | m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " + | 936 | m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " + |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs index 854bea4..211b775 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
65 | public void PostInitialise() { } | 65 | public void PostInitialise() { } |
66 | public void Close() { } | 66 | public void Close() { } |
67 | 67 | ||
68 | public SimianPresenceServiceConnector() { m_activityDetector = new SimianActivityDetector(this); } | 68 | public SimianPresenceServiceConnector() { } |
69 | public string Name { get { return "SimianPresenceServiceConnector"; } } | 69 | public string Name { get { return "SimianPresenceServiceConnector"; } } |
70 | public void AddRegion(Scene scene) | 70 | public void AddRegion(Scene scene) |
71 | { | 71 | { |
@@ -121,6 +121,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
121 | if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) | 121 | if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) |
122 | serviceUrl = serviceUrl + '/'; | 122 | serviceUrl = serviceUrl + '/'; |
123 | m_serverUrl = serviceUrl; | 123 | m_serverUrl = serviceUrl; |
124 | m_activityDetector = new SimianActivityDetector(this); | ||
124 | m_Enabled = true; | 125 | m_Enabled = true; |
125 | } | 126 | } |
126 | } | 127 | } |
@@ -137,17 +138,18 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
137 | userID, sessionID, secureSessionID); | 138 | userID, sessionID, secureSessionID); |
138 | 139 | ||
139 | NameValueCollection requestArgs = new NameValueCollection | 140 | NameValueCollection requestArgs = new NameValueCollection |
140 | { | 141 | { |
141 | { "RequestMethod", "AddSession" }, | 142 | { "RequestMethod", "AddSession" }, |
142 | { "UserID", userID.ToString() } | 143 | { "UserID", userID.ToString() } |
143 | }; | 144 | }; |
145 | |||
144 | if (sessionID != UUID.Zero) | 146 | if (sessionID != UUID.Zero) |
145 | { | 147 | { |
146 | requestArgs["SessionID"] = sessionID.ToString(); | 148 | requestArgs["SessionID"] = sessionID.ToString(); |
147 | requestArgs["SecureSessionID"] = secureSessionID.ToString(); | 149 | requestArgs["SecureSessionID"] = secureSessionID.ToString(); |
148 | } | 150 | } |
149 | 151 | ||
150 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 152 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
151 | bool success = response["Success"].AsBoolean(); | 153 | bool success = response["Success"].AsBoolean(); |
152 | 154 | ||
153 | if (!success) | 155 | if (!success) |
@@ -158,15 +160,15 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
158 | 160 | ||
159 | public bool LogoutAgent(UUID sessionID) | 161 | public bool LogoutAgent(UUID sessionID) |
160 | { | 162 | { |
161 | // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); | 163 | // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); |
162 | 164 | ||
163 | NameValueCollection requestArgs = new NameValueCollection | 165 | NameValueCollection requestArgs = new NameValueCollection |
164 | { | 166 | { |
165 | { "RequestMethod", "RemoveSession" }, | 167 | { "RequestMethod", "RemoveSession" }, |
166 | { "SessionID", sessionID.ToString() } | 168 | { "SessionID", sessionID.ToString() } |
167 | }; | 169 | }; |
168 | 170 | ||
169 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 171 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
170 | bool success = response["Success"].AsBoolean(); | 172 | bool success = response["Success"].AsBoolean(); |
171 | 173 | ||
172 | if (!success) | 174 | if (!success) |
@@ -177,15 +179,15 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
177 | 179 | ||
178 | public bool LogoutRegionAgents(UUID regionID) | 180 | public bool LogoutRegionAgents(UUID regionID) |
179 | { | 181 | { |
180 | // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID); | 182 | // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID); |
181 | 183 | ||
182 | NameValueCollection requestArgs = new NameValueCollection | 184 | NameValueCollection requestArgs = new NameValueCollection |
183 | { | 185 | { |
184 | { "RequestMethod", "RemoveSessions" }, | 186 | { "RequestMethod", "RemoveSessions" }, |
185 | { "SceneID", regionID.ToString() } | 187 | { "SceneID", regionID.ToString() } |
186 | }; | 188 | }; |
187 | 189 | ||
188 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 190 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
189 | bool success = response["Success"].AsBoolean(); | 191 | bool success = response["Success"].AsBoolean(); |
190 | 192 | ||
191 | if (!success) | 193 | if (!success) |
@@ -202,49 +204,46 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
202 | 204 | ||
203 | public PresenceInfo GetAgent(UUID sessionID) | 205 | public PresenceInfo GetAgent(UUID sessionID) |
204 | { | 206 | { |
205 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent with sessionID " + sessionID); | 207 | OSDMap sessionResponse = GetSessionDataFromSessionID(sessionID); |
206 | 208 | if (sessionResponse == null) | |
207 | NameValueCollection requestArgs = new NameValueCollection | ||
208 | { | ||
209 | { "RequestMethod", "GetSession" }, | ||
210 | { "SessionID", sessionID.ToString() } | ||
211 | }; | ||
212 | |||
213 | OSDMap sessionResponse = WebUtil.PostToService(m_serverUrl, requestArgs); | ||
214 | if (sessionResponse["Success"].AsBoolean()) | ||
215 | { | 209 | { |
216 | UUID userID = sessionResponse["UserID"].AsUUID(); | 210 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString()); |
217 | m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); | 211 | return null; |
218 | |||
219 | requestArgs = new NameValueCollection | ||
220 | { | ||
221 | { "RequestMethod", "GetUser" }, | ||
222 | { "UserID", userID.ToString() } | ||
223 | }; | ||
224 | |||
225 | OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs); | ||
226 | if (userResponse["Success"].AsBoolean()) | ||
227 | return ResponseToPresenceInfo(sessionResponse, userResponse); | ||
228 | else | ||
229 | m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString()); | ||
230 | } | 212 | } |
231 | else | 213 | |
214 | UUID userID = sessionResponse["UserID"].AsUUID(); | ||
215 | OSDMap userResponse = GetUserData(userID); | ||
216 | if (userResponse == null) | ||
232 | { | 217 | { |
233 | m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session " + sessionID + ": " + sessionResponse["Message"].AsString()); | 218 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID.ToString(),userResponse["Message"].AsString()); |
219 | return null; | ||
234 | } | 220 | } |
235 | 221 | ||
236 | return null; | 222 | return ResponseToPresenceInfo(sessionResponse); |
237 | } | 223 | } |
238 | 224 | ||
239 | public PresenceInfo[] GetAgents(string[] userIDs) | 225 | public PresenceInfo[] GetAgents(string[] userIDs) |
240 | { | 226 | { |
241 | List<PresenceInfo> presences = new List<PresenceInfo>(userIDs.Length); | 227 | List<PresenceInfo> presences = new List<PresenceInfo>(); |
228 | |||
229 | NameValueCollection requestArgs = new NameValueCollection | ||
230 | { | ||
231 | { "RequestMethod", "GetSessions" }, | ||
232 | { "UserIDList", String.Join(",",userIDs) } | ||
233 | }; | ||
242 | 234 | ||
243 | for (int i = 0; i < userIDs.Length; i++) | 235 | OSDMap sessionListResponse = SimianGrid.PostToService(m_serverUrl, requestArgs); |
236 | if (! sessionListResponse["Success"].AsBoolean()) | ||
244 | { | 237 | { |
245 | UUID userID; | 238 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString()); |
246 | if (UUID.TryParse(userIDs[i], out userID) && userID != UUID.Zero) | 239 | return null; |
247 | presences.AddRange(GetSessions(userID)); | 240 | } |
241 | |||
242 | OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray; | ||
243 | for (int i = 0; i < sessionList.Count; i++) | ||
244 | { | ||
245 | OSDMap sessionInfo = sessionList[i] as OSDMap; | ||
246 | presences.Add(ResponseToPresenceInfo(sessionInfo)); | ||
248 | } | 247 | } |
249 | 248 | ||
250 | return presences.ToArray(); | 249 | return presences.ToArray(); |
@@ -262,7 +261,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
262 | 261 | ||
263 | public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) | 262 | public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) |
264 | { | 263 | { |
265 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID); | 264 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID); |
266 | 265 | ||
267 | // Remove the session to mark this user offline | 266 | // Remove the session to mark this user offline |
268 | if (!LogoutAgent(sessionID)) | 267 | if (!LogoutAgent(sessionID)) |
@@ -270,13 +269,13 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
270 | 269 | ||
271 | // Save our last position as user data | 270 | // Save our last position as user data |
272 | NameValueCollection requestArgs = new NameValueCollection | 271 | NameValueCollection requestArgs = new NameValueCollection |
273 | { | 272 | { |
274 | { "RequestMethod", "AddUserData" }, | 273 | { "RequestMethod", "AddUserData" }, |
275 | { "UserID", userID.ToString() }, | 274 | { "UserID", userID.ToString() }, |
276 | { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) } | 275 | { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) } |
277 | }; | 276 | }; |
278 | 277 | ||
279 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 278 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
280 | bool success = response["Success"].AsBoolean(); | 279 | bool success = response["Success"].AsBoolean(); |
281 | 280 | ||
282 | if (!success) | 281 | if (!success) |
@@ -287,16 +286,16 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
287 | 286 | ||
288 | public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | 287 | public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) |
289 | { | 288 | { |
290 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); | 289 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); |
291 | 290 | ||
292 | NameValueCollection requestArgs = new NameValueCollection | 291 | NameValueCollection requestArgs = new NameValueCollection |
293 | { | 292 | { |
294 | { "RequestMethod", "AddUserData" }, | 293 | { "RequestMethod", "AddUserData" }, |
295 | { "UserID", userID.ToString() }, | 294 | { "UserID", userID.ToString() }, |
296 | { "HomeLocation", SerializeLocation(regionID, position, lookAt) } | 295 | { "HomeLocation", SerializeLocation(regionID, position, lookAt) } |
297 | }; | 296 | }; |
298 | 297 | ||
299 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 298 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
300 | bool success = response["Success"].AsBoolean(); | 299 | bool success = response["Success"].AsBoolean(); |
301 | 300 | ||
302 | if (!success) | 301 | if (!success) |
@@ -312,24 +311,19 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
312 | 311 | ||
313 | public GridUserInfo GetGridUserInfo(string user) | 312 | public GridUserInfo GetGridUserInfo(string user) |
314 | { | 313 | { |
315 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); | 314 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); |
316 | 315 | ||
317 | UUID userID = new UUID(user); | 316 | UUID userID = new UUID(user); |
318 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); | 317 | OSDMap userResponse = GetUserData(userID); |
319 | 318 | ||
320 | NameValueCollection requestArgs = new NameValueCollection | 319 | if (userResponse == null) |
321 | { | 320 | { |
322 | { "RequestMethod", "GetUser" }, | 321 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}", userID); |
323 | { "UserID", userID.ToString() } | 322 | } |
324 | }; | ||
325 | 323 | ||
326 | OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs); | 324 | // Note that ResponseToGridUserInfo properly checks for and returns a null if passed a null. |
327 | if (userResponse["Success"].AsBoolean()) | 325 | return ResponseToGridUserInfo(userResponse); |
328 | return ResponseToGridUserInfo(userResponse); | ||
329 | else | ||
330 | m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString()); | ||
331 | 326 | ||
332 | return null; | ||
333 | } | 327 | } |
334 | 328 | ||
335 | #endregion | 329 | #endregion |
@@ -338,67 +332,51 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
338 | 332 | ||
339 | private OSDMap GetUserData(UUID userID) | 333 | private OSDMap GetUserData(UUID userID) |
340 | { | 334 | { |
341 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); | 335 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); |
342 | 336 | ||
343 | NameValueCollection requestArgs = new NameValueCollection | 337 | NameValueCollection requestArgs = new NameValueCollection |
344 | { | 338 | { |
345 | { "RequestMethod", "GetUser" }, | 339 | { "RequestMethod", "GetUser" }, |
346 | { "UserID", userID.ToString() } | 340 | { "UserID", userID.ToString() } |
347 | }; | 341 | }; |
348 | 342 | ||
349 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 343 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
350 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) | 344 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) |
351 | return response; | 345 | return response; |
352 | else | ||
353 | m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + response["Message"].AsString()); | ||
354 | 346 | ||
347 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}; {1}",userID.ToString(),response["Message"].AsString()); | ||
355 | return null; | 348 | return null; |
356 | } | 349 | } |
357 | 350 | ||
358 | private List<PresenceInfo> GetSessions(UUID userID) | 351 | private OSDMap GetSessionDataFromSessionID(UUID sessionID) |
359 | { | 352 | { |
360 | List<PresenceInfo> presences = new List<PresenceInfo>(1); | 353 | NameValueCollection requestArgs = new NameValueCollection |
361 | |||
362 | OSDMap userResponse = GetUserData(userID); | ||
363 | if (userResponse != null) | ||
364 | { | ||
365 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting sessions for " + userID); | ||
366 | |||
367 | NameValueCollection requestArgs = new NameValueCollection | ||
368 | { | 354 | { |
369 | { "RequestMethod", "GetSession" }, | 355 | { "RequestMethod", "GetSession" }, |
370 | { "UserID", userID.ToString() } | 356 | { "SessionID", sessionID.ToString() } |
371 | }; | 357 | }; |
372 | 358 | ||
373 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 359 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
374 | if (response["Success"].AsBoolean()) | 360 | if (response["Success"].AsBoolean()) |
375 | { | 361 | return response; |
376 | PresenceInfo presence = ResponseToPresenceInfo(response, userResponse); | ||
377 | if (presence != null) | ||
378 | presences.Add(presence); | ||
379 | } | ||
380 | // else | ||
381 | // { | ||
382 | // m_log.Debug("[SIMIAN PRESENCE CONNECTOR]: No session returned for " + userID + ": " + response["Message"].AsString()); | ||
383 | // } | ||
384 | } | ||
385 | 362 | ||
386 | return presences; | 363 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session data for {0}; {1}",sessionID.ToString(),response["Message"].AsString()); |
364 | return null; | ||
387 | } | 365 | } |
388 | 366 | ||
389 | private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) | 367 | private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) |
390 | { | 368 | { |
391 | // Save our current location as session data | 369 | // Save our current location as session data |
392 | NameValueCollection requestArgs = new NameValueCollection | 370 | NameValueCollection requestArgs = new NameValueCollection |
393 | { | 371 | { |
394 | { "RequestMethod", "UpdateSession" }, | 372 | { "RequestMethod", "UpdateSession" }, |
395 | { "SessionID", sessionID.ToString() }, | 373 | { "SessionID", sessionID.ToString() }, |
396 | { "SceneID", regionID.ToString() }, | 374 | { "SceneID", regionID.ToString() }, |
397 | { "ScenePosition", lastPosition.ToString() }, | 375 | { "ScenePosition", lastPosition.ToString() }, |
398 | { "SceneLookAt", lastLookAt.ToString() } | 376 | { "SceneLookAt", lastLookAt.ToString() } |
399 | }; | 377 | }; |
400 | 378 | ||
401 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 379 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
402 | bool success = response["Success"].AsBoolean(); | 380 | bool success = response["Success"].AsBoolean(); |
403 | 381 | ||
404 | if (!success) | 382 | if (!success) |
@@ -407,7 +385,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
407 | return success; | 385 | return success; |
408 | } | 386 | } |
409 | 387 | ||
410 | private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse) | 388 | private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse) |
411 | { | 389 | { |
412 | if (sessionResponse == null) | 390 | if (sessionResponse == null) |
413 | return null; | 391 | return null; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs index bd8069f..8fc766d 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs | |||
@@ -392,7 +392,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
392 | { "UserID", client.AgentId.ToString() } | 392 | { "UserID", client.AgentId.ToString() } |
393 | }; | 393 | }; |
394 | 394 | ||
395 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 395 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
396 | string email = response["Email"].AsString(); | 396 | string email = response["Email"].AsString(); |
397 | 397 | ||
398 | if (!response["Success"].AsBoolean()) | 398 | if (!response["Success"].AsBoolean()) |
@@ -425,7 +425,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
425 | estate.EstateID, admin.Name); | 425 | estate.EstateID, admin.Name); |
426 | 426 | ||
427 | estate.EstateOwner = admin.PrincipalID; | 427 | estate.EstateOwner = admin.PrincipalID; |
428 | estate.Save(); | 428 | scene.EstateDataService.StoreEstateSettings(estate); |
429 | } | 429 | } |
430 | else | 430 | else |
431 | { | 431 | { |
@@ -443,7 +443,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
443 | { key, OSDParser.SerializeJsonString(value) } | 443 | { key, OSDParser.SerializeJsonString(value) } |
444 | }; | 444 | }; |
445 | 445 | ||
446 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 446 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
447 | bool success = response["Success"].AsBoolean(); | 447 | bool success = response["Success"].AsBoolean(); |
448 | 448 | ||
449 | if (!success) | 449 | if (!success) |
@@ -462,7 +462,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
462 | { "UserID", userID.ToString() } | 462 | { "UserID", userID.ToString() } |
463 | }; | 463 | }; |
464 | 464 | ||
465 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 465 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
466 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) | 466 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) |
467 | { | 467 | { |
468 | return (OSDMap)response["User"]; | 468 | return (OSDMap)response["User"]; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs index 6e32b3a..698c4c0 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs | |||
@@ -165,7 +165,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
165 | { "NameQuery", query } | 165 | { "NameQuery", query } |
166 | }; | 166 | }; |
167 | 167 | ||
168 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 168 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
169 | if (response["Success"].AsBoolean()) | 169 | if (response["Success"].AsBoolean()) |
170 | { | 170 | { |
171 | OSDArray array = response["Users"] as OSDArray; | 171 | OSDArray array = response["Users"] as OSDArray; |
@@ -191,6 +191,11 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
191 | return accounts; | 191 | return accounts; |
192 | } | 192 | } |
193 | 193 | ||
194 | public void InvalidateCache(UUID userID) | ||
195 | { | ||
196 | m_accountCache.Remove(userID); | ||
197 | } | ||
198 | |||
194 | public bool StoreUserAccount(UserAccount data) | 199 | public bool StoreUserAccount(UserAccount data) |
195 | { | 200 | { |
196 | // m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); | 201 | // m_log.InfoFormat("[SIMIAN ACCOUNT CONNECTOR]: Storing user account for " + data.Name); |
@@ -204,7 +209,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
204 | { "AccessLevel", data.UserLevel.ToString() } | 209 | { "AccessLevel", data.UserLevel.ToString() } |
205 | }; | 210 | }; |
206 | 211 | ||
207 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 212 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
208 | 213 | ||
209 | if (response["Success"].AsBoolean()) | 214 | if (response["Success"].AsBoolean()) |
210 | { | 215 | { |
@@ -219,7 +224,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
219 | { "UserTitle", data.UserTitle } | 224 | { "UserTitle", data.UserTitle } |
220 | }; | 225 | }; |
221 | 226 | ||
222 | response = WebUtil.PostToService(m_serverUrl, requestArgs); | 227 | response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
223 | bool success = response["Success"].AsBoolean(); | 228 | bool success = response["Success"].AsBoolean(); |
224 | 229 | ||
225 | if (success) | 230 | if (success) |
@@ -252,7 +257,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
252 | string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)"; | 257 | string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)"; |
253 | // m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue); | 258 | // m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue); |
254 | 259 | ||
255 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 260 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
256 | if (response["Success"].AsBoolean()) | 261 | if (response["Success"].AsBoolean()) |
257 | { | 262 | { |
258 | OSDMap user = response["User"] as OSDMap; | 263 | OSDMap user = response["User"] as OSDMap; |