aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorTom Grimshaw2010-06-12 04:36:14 -0700
committerTom Grimshaw2010-06-12 04:36:14 -0700
commit63531b1df5463d43821c91a26bd0f6414716d0d0 (patch)
tree381fddf86dbe4880b6e5114f3db8737fc9ecb53a /OpenSim/Services
parentGet rid of spamming SOG debug message (diff)
parentPreserving the link numbers is a serializer's highest duty. (diff)
downloadopensim-SC-63531b1df5463d43821c91a26bd0f6414716d0d0.zip
opensim-SC-63531b1df5463d43821c91a26bd0f6414716d0d0.tar.gz
opensim-SC-63531b1df5463d43821c91a26bd0f6414716d0d0.tar.bz2
opensim-SC-63531b1df5463d43821c91a26bd0f6414716d0d0.tar.xz
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs84
1 files changed, 81 insertions, 3 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
index 57924b7..6a61da6 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs
@@ -28,17 +28,18 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.Drawing;
32using System.Drawing.Imaging;
33using System.IO;
31using System.Net; 34using System.Net;
32using System.Reflection; 35using System.Reflection;
33using log4net; 36using log4net;
34using Mono.Addins; 37using Mono.Addins;
35using Nini.Config; 38using Nini.Config;
36using OpenSim.Framework; 39using OpenSim.Framework;
37using OpenSim.Framework.Servers.HttpServer;
38using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
41using OpenSim.Server.Base;
42using OpenMetaverse; 43using OpenMetaverse;
43using OpenMetaverse.StructuredData; 44using OpenMetaverse.StructuredData;
44 45
@@ -62,7 +63,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
62 #region ISharedRegionModule 63 #region ISharedRegionModule
63 64
64 public Type ReplaceableInterface { get { return null; } } 65 public Type ReplaceableInterface { get { return null; } }
65 public void RegionLoaded(Scene scene) { } 66 public void RegionLoaded(Scene scene) { if (!String.IsNullOrEmpty(m_serverUrl)) { UploadMapTile(scene); } }
66 public void PostInitialise() { } 67 public void PostInitialise() { }
67 public void Close() { } 68 public void Close() { }
68 69
@@ -358,6 +359,83 @@ namespace OpenSim.Services.Connectors.SimianGrid
358 359
359 #endregion IGridService 360 #endregion IGridService
360 361
362 private void UploadMapTile(IScene scene)
363 {
364 string errorMessage = null;
365
366 // Create a PNG map tile and upload it to the AddMapTile API
367 byte[] pngData = Utils.EmptyBytes;
368 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
369 if (tileGenerator == null)
370 {
371 m_log.Warn("[SIMIAN GRID CONNECTOR]: Cannot upload PNG map tile without an IMapImageGenerator");
372 return;
373 }
374
375 using (Image mapTile = tileGenerator.CreateMapTile("defaultstripe.png"))
376 {
377 using (MemoryStream stream = new MemoryStream())
378 {
379 mapTile.Save(stream, ImageFormat.Png);
380 pngData = stream.ToArray();
381 }
382 }
383
384 List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>()
385 {
386 new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()),
387 new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()),
388 new MultipartForm.File("Tile", "tile.png", "image/png", pngData)
389 };
390
391 // Make the remote storage request
392 try
393 {
394 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl);
395
396 HttpWebResponse response = MultipartForm.Post(request, postParameters);
397 using (Stream responseStream = response.GetResponseStream())
398 {
399 string responseStr = null;
400
401 try
402 {
403 responseStr = responseStream.GetStreamString();
404 OSD responseOSD = OSDParser.Deserialize(responseStr);
405 if (responseOSD.Type == OSDType.Map)
406 {
407 OSDMap responseMap = (OSDMap)responseOSD;
408 if (responseMap["Success"].AsBoolean())
409 m_log.Info("[SIMIAN GRID CONNECTOR]: Uploaded " + pngData.Length + " byte PNG map tile to AddMapTile");
410 else
411 errorMessage = "Upload failed: " + responseMap["Message"].AsString();
412 }
413 else
414 {
415 errorMessage = "Response format was invalid:\n" + responseStr;
416 }
417 }
418 catch (Exception ex)
419 {
420 if (!String.IsNullOrEmpty(responseStr))
421 errorMessage = "Failed to parse the response:\n" + responseStr;
422 else
423 errorMessage = "Failed to retrieve the response: " + ex.Message;
424 }
425 }
426 }
427 catch (WebException ex)
428 {
429 errorMessage = ex.Message;
430 }
431
432 if (!String.IsNullOrEmpty(errorMessage))
433 {
434 m_log.WarnFormat("[SIMIAN GRID CONNECTOR]: Failed to store {0} byte PNG map tile for {1}: {2}",
435 pngData.Length, scene.RegionInfo.RegionName, errorMessage);
436 }
437 }
438
361 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled) 439 private GridRegion GetNearestRegion(Vector3d position, bool onlyEnabled)
362 { 440 {
363 NameValueCollection requestArgs = new NameValueCollection 441 NameValueCollection requestArgs = new NameValueCollection