aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2009-09-22 11:58:40 -0700
committerDiva Canto2009-09-22 11:58:40 -0700
commit34f4738159300ab6370e3db47df5187b6cea8771 (patch)
treeb999ec7a07c4527bb38771ea6b02a8d77b5d0bdf /OpenSim
parentAdded Remote grid connector module. (diff)
downloadopensim-SC-34f4738159300ab6370e3db47df5187b6cea8771.zip
opensim-SC-34f4738159300ab6370e3db47df5187b6cea8771.tar.gz
opensim-SC-34f4738159300ab6370e3db47df5187b6cea8771.tar.bz2
opensim-SC-34f4738159300ab6370e3db47df5187b6cea8771.tar.xz
Added HGGridConnector and related code.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs304
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs64
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs34
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs155
5 files changed, 520 insertions, 39 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
new file mode 100644
index 0000000..b7e3213
--- /dev/null
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs
@@ -0,0 +1,304 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31
32using OpenSim.Framework;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Interfaces;
36using OpenSim.Server.Base;
37using OpenSim.Services.Connectors.Grid;
38
39using OpenMetaverse;
40using log4net;
41using Nini.Config;
42
43namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
44{
45 public class HGGridConnector : ISharedRegionModule, IGridService
46 {
47 private static readonly ILog m_log =
48 LogManager.GetLogger(
49 MethodBase.GetCurrentMethod().DeclaringType);
50
51 private bool m_Enabled = false;
52 private bool m_Initialized = false;
53
54 private IGridService m_GridServiceConnector;
55 private HypergridServiceConnector m_HypergridServiceConnector;
56
57 // Hyperlink regions are hyperlinks on the map
58 protected Dictionary<UUID, SimpleRegionInfo> m_HyperlinkRegions = new Dictionary<UUID, SimpleRegionInfo>();
59
60 // Known regions are home regions of visiting foreign users.
61 // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when
62 // the visitor goes away. They are mapped to X=0 on the map.
63 // This is key-ed on agent ID
64 protected Dictionary<UUID, SimpleRegionInfo> m_knownRegions = new Dictionary<UUID, SimpleRegionInfo>();
65
66 #region ISharedRegionModule
67
68 public Type ReplaceableInterface
69 {
70 get { return null; }
71 }
72
73 public string Name
74 {
75 get { return "HGGridServicesConnector"; }
76 }
77
78 public void Initialise(IConfigSource source)
79 {
80 IConfig moduleConfig = source.Configs["Modules"];
81 if (moduleConfig != null)
82 {
83 string name = moduleConfig.GetString("GridServices", "");
84 if (name == Name)
85 {
86 IConfig gridConfig = source.Configs["GridService"];
87 if (gridConfig == null)
88 {
89 m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
90 return;
91 }
92
93
94 InitialiseConnectorModule(source);
95
96 m_Enabled = true;
97 m_log.Info("[HGGRID CONNECTOR]: HG grid enabled");
98 }
99 }
100 }
101
102 private void InitialiseConnectorModule(IConfigSource source)
103 {
104 IConfig gridConfig = source.Configs["GridService"];
105 if (gridConfig == null)
106 {
107 m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini");
108 throw new Exception("Grid connector init error");
109 }
110
111 string module = gridConfig.GetString("GridServiceConnectorModule", String.Empty);
112 if (module == String.Empty)
113 {
114 m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService");
115 //return;
116 throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's");
117 }
118
119 Object[] args = new Object[] { source };
120 m_GridServiceConnector = ServerUtils.LoadPlugin<IGridService>(module, args);
121
122 }
123
124 public void PostInitialise()
125 {
126 }
127
128 public void Close()
129 {
130 }
131
132 public void AddRegion(Scene scene)
133 {
134 if (!m_Enabled)
135 return;
136
137 scene.RegisterModuleInterface<IGridService>(this);
138 }
139
140 public void RemoveRegion(Scene scene)
141 {
142 }
143
144 public void RegionLoaded(Scene scene)
145 {
146 if (m_Enabled && !m_Initialized)
147 {
148 m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService);
149 m_Initialized = true;
150 }
151 }
152
153 #endregion
154
155 #region IGridService
156
157 public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo)
158 {
159 // Region doesn't exist here. Trying to link remote region
160 if (regionInfo.RegionID.Equals(UUID.Zero))
161 {
162 m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort);
163 regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo);
164 if (!regionInfo.RegionID.Equals(UUID.Zero))
165 {
166 m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo);
167 m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID);
168
169 // Try get the map image
170 m_HypergridServiceConnector.GetMapImage(regionInfo);
171 return true;
172 }
173 else
174 {
175 m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")");
176 return false;
177 }
178 // Note that these remote regions aren't registered in localBackend, so return null, no local listeners
179 }
180 else // normal grid
181 return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo);
182 }
183
184 public bool DeregisterRegion(UUID regionID)
185 {
186 // Try the hyperlink collection
187 if (m_HyperlinkRegions.ContainsKey(regionID))
188 {
189 m_HyperlinkRegions.Remove(regionID);
190 return true;
191 }
192 // Try the foreign users home collection
193 if (m_knownRegions.ContainsKey(regionID))
194 {
195 m_knownRegions.Remove(regionID);
196 return true;
197 }
198 // Finally, try the normal route
199 return m_GridServiceConnector.DeregisterRegion(regionID);
200 }
201
202 public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID)
203 {
204 // No serving neighbours on hyperliked regions.
205 // Just the regular regions.
206 return m_GridServiceConnector.GetNeighbours(scopeID, regionID);
207 }
208
209 public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID)
210 {
211 // Try the hyperlink collection
212 if (m_HyperlinkRegions.ContainsKey(regionID))
213 return m_HyperlinkRegions[regionID];
214
215 // Try the foreign users home collection
216 if (m_knownRegions.ContainsKey(regionID))
217 return m_knownRegions[regionID];
218
219 // Finally, try the normal route
220 return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID);
221 }
222
223 public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y)
224 {
225 int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize;
226 int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize;
227 // Try the hyperlink collection
228 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
229 {
230 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
231 return r;
232 }
233
234 // Try the foreign users home collection
235 foreach (SimpleRegionInfo r in m_knownRegions.Values)
236 {
237 if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY))
238 return r;
239 }
240
241 // Finally, try the normal route
242 return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y);
243 }
244
245 public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName)
246 {
247 // Try normal grid first
248 SimpleRegionInfo region = m_GridServiceConnector.GetRegionByName(scopeID, regionName);
249 if (region != null)
250 return region;
251
252 // !!! Commenting until region name exists
253 //// Try the hyperlink collection
254 //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
255 //{
256 // if (r.RegionName == regionName)
257 // return r;
258 //}
259
260 //// Try the foreign users home collection
261 //foreach (SimpleRegionInfo r in m_knownRegions.Values)
262 //{
263 // if (r.RegionName == regionName)
264 // return r;
265 //}
266 return null;
267 }
268
269 public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber)
270 {
271 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>();
272
273 // Commenting until regionname exists
274 //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
275 // if ((r.RegionName != null) && r.RegionName.StartsWith(name))
276 // rinfos.Add(r);
277
278 rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber));
279 return rinfos;
280 }
281
282 public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
283 {
284 int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize;
285 int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize;
286 int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize;
287 int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize;
288
289 List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>();
290 foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
291 if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) &&
292 (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax))
293 rinfos.Add(r);
294
295 rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax));
296
297 return rinfos;
298 }
299
300 #endregion
301
302
303 }
304}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
index 74ece2e..3f29401 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs
@@ -50,6 +50,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
50 50
51 private bool m_Enabled = false; 51 private bool m_Enabled = false;
52 52
53 public LocalGridServicesConnector(IConfigSource source)
54 {
55 InitialiseService(source);
56 }
57
53 #region ISharedRegionModule 58 #region ISharedRegionModule
54 59
55 public Type ReplaceableInterface 60 public Type ReplaceableInterface
@@ -70,38 +75,43 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
70 string name = moduleConfig.GetString("GridServices", ""); 75 string name = moduleConfig.GetString("GridServices", "");
71 if (name == Name) 76 if (name == Name)
72 { 77 {
73 IConfig assetConfig = source.Configs["GridService"]; 78 InitialiseService(source);
74 if (assetConfig == null)
75 {
76 m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
77 return;
78 }
79
80 string serviceDll = assetConfig.GetString("LocalServiceModule",
81 String.Empty);
82
83 if (serviceDll == String.Empty)
84 {
85 m_log.Error("[GRID CONNECTOR]: No LocalServiceModule named in section GridService");
86 return;
87 }
88
89 Object[] args = new Object[] { source };
90 m_GridService =
91 ServerUtils.LoadPlugin<IGridService>(serviceDll,
92 args);
93
94 if (m_GridService == null)
95 {
96 m_log.Error("[GRID CONNECTOR]: Can't load asset service");
97 return;
98 }
99 m_Enabled = true; 79 m_Enabled = true;
100 m_log.Info("[GRID CONNECTOR]: Local grid connector enabled"); 80 m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled");
101 } 81 }
102 } 82 }
103 } 83 }
104 84
85 private void InitialiseService(IConfigSource source)
86 {
87 IConfig assetConfig = source.Configs["GridService"];
88 if (assetConfig == null)
89 {
90 m_log.Error("[LOCAL GRID CONNECTOR]: GridService missing from OpenSim.ini");
91 return;
92 }
93
94 string serviceDll = assetConfig.GetString("LocalServiceModule",
95 String.Empty);
96
97 if (serviceDll == String.Empty)
98 {
99 m_log.Error("[LOCAL GRID CONNECTOR]: No LocalServiceModule named in section GridService");
100 return;
101 }
102
103 Object[] args = new Object[] { source };
104 m_GridService =
105 ServerUtils.LoadPlugin<IGridService>(serviceDll,
106 args);
107
108 if (m_GridService == null)
109 {
110 m_log.Error("[LOCAL GRID CONNECTOR]: Can't load asset service");
111 return;
112 }
113 }
114
105 public void PostInitialise() 115 public void PostInitialise()
106 { 116 {
107 } 117 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
index b0cfc9c..22b1015 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs
@@ -47,6 +47,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
47 47
48 private bool m_Enabled = false; 48 private bool m_Enabled = false;
49 49
50 public RemoteGridServicesConnector(IConfigSource source)
51 {
52 InitialiseService(source);
53 }
54
55 #region ISharedRegionmodule
56
50 public Type ReplaceableInterface 57 public Type ReplaceableInterface
51 { 58 {
52 get { return null; } 59 get { return null; }
@@ -65,22 +72,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
65 string name = moduleConfig.GetString("GridServices", ""); 72 string name = moduleConfig.GetString("GridServices", "");
66 if (name == Name) 73 if (name == Name)
67 { 74 {
68 IConfig gridConfig = source.Configs["GridService"]; 75 InitialiseService(source);
69 if (gridConfig == null)
70 {
71 m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
72 return;
73 }
74
75 m_Enabled = true; 76 m_Enabled = true;
76 77 m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled");
77 base.Initialise(source);
78
79 m_log.Info("[GRID CONNECTOR]: Remote grid enabled");
80 } 78 }
81 } 79 }
82 } 80 }
83 81
82 private void InitialiseService(IConfigSource source)
83 {
84 IConfig gridConfig = source.Configs["GridService"];
85 if (gridConfig == null)
86 {
87 m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini");
88 return;
89 }
90
91 base.Initialise(source);
92 }
93
84 public void PostInitialise() 94 public void PostInitialise()
85 { 95 {
86 } 96 }
@@ -104,5 +114,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
104 public void RegionLoaded(Scene scene) 114 public void RegionLoaded(Scene scene)
105 { 115 {
106 } 116 }
117
118 #endregion
107 } 119 }
108} 120}
diff --git a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
index b80c479..7bf2e66 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerConnector.cs
@@ -49,7 +49,7 @@ namespace OpenSim.Server.Handlers.Grid
49 String.Empty); 49 String.Empty);
50 50
51 if (gridService == String.Empty) 51 if (gridService == String.Empty)
52 throw new Exception("No AuthenticationService in config file"); 52 throw new Exception("No GridService in config file");
53 53
54 Object[] args = new Object[] { config }; 54 Object[] args = new Object[] { config };
55 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); 55 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
new file mode 100644
index 0000000..f68c10a
--- /dev/null
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -0,0 +1,155 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Text;
32using System.Drawing;
33using System.Net;
34using System.Reflection;
35using OpenSim.Services.Interfaces;
36
37using OpenSim.Framework;
38
39using OpenMetaverse;
40using OpenMetaverse.Imaging;
41using log4net;
42using Nwc.XmlRpc;
43
44namespace OpenSim.Services.Connectors.Grid
45{
46 public class HypergridServiceConnector
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private IAssetService m_AssetService;
51
52 public HypergridServiceConnector(IAssetService assService)
53 {
54 m_AssetService = assService;
55 }
56
57 public UUID LinkRegion(SimpleRegionInfo info)
58 {
59 UUID uuid = UUID.Zero;
60
61 //Hashtable hash = new Hashtable();
62 //hash["region_name"] = info.RegionName;
63
64 //IList paramList = new ArrayList();
65 //paramList.Add(hash);
66
67 //XmlRpcRequest request = new XmlRpcRequest("link_region", paramList);
68 //string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
69 //m_log.Debug("[HGrid]: Linking to " + uri);
70 //XmlRpcResponse response = request.Send(uri, 10000);
71 //if (response.IsFault)
72 //{
73 // m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
74 //}
75 //else
76 //{
77 // hash = (Hashtable)response.Value;
78 // //foreach (Object o in hash)
79 // // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
80 // try
81 // {
82 // UUID.TryParse((string)hash["uuid"], out uuid);
83 // info.RegionID = uuid;
84 // if ((string)hash["handle"] != null)
85 // {
86 // info.regionSecret = (string)hash["handle"];
87 // //m_log.Debug(">> HERE: " + info.regionSecret);
88 // }
89 // if (hash["region_image"] != null)
90 // {
91 // UUID img = UUID.Zero;
92 // UUID.TryParse((string)hash["region_image"], out img);
93 // info.RegionSettings.TerrainImageID = img;
94 // }
95 // if (hash["region_name"] != null)
96 // {
97 // info.RegionName = (string)hash["region_name"];
98 // //m_log.Debug(">> " + info.RegionName);
99 // }
100 // if (hash["internal_port"] != null)
101 // {
102 // int port = Convert.ToInt32((string)hash["internal_port"]);
103 // info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
104 // //m_log.Debug(">> " + info.InternalEndPoint.ToString());
105 // }
106 // if (hash["remoting_port"] != null)
107 // {
108 // info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]);
109 // //m_log.Debug(">> " + info.RemotingPort);
110 // }
111
112 // }
113 // catch (Exception e)
114 // {
115 // m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
116 // }
117 //}
118 return uuid;
119 }
120
121 public void GetMapImage(SimpleRegionInfo info)
122 {
123 try
124 {
125 string regionimage = "regionImage" + info.RegionID.ToString();
126 regionimage = regionimage.Replace("-", "");
127
128 WebClient c = new WebClient();
129 string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage;
130 //m_log.Debug("JPEG: " + uri);
131 c.DownloadFile(uri, info.RegionID.ToString() + ".jpg");
132 Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg");
133 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
134 byte[] imageData = OpenJPEG.EncodeFromImage(m, true);
135 AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString());
136
137 // !!! for now
138 //info.RegionSettings.TerrainImageID = ass.FullID;
139
140 ass.Type = (int)AssetType.Texture;
141 ass.Temporary = true;
142 ass.Local = true;
143 ass.Data = imageData;
144
145 m_AssetService.Store(ass);
146
147 }
148 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
149 {
150 m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache");
151 }
152 }
153
154 }
155}