aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/Grid
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors/Grid')
-rw-r--r--OpenSim/Services/Connectors/Grid/GridServiceConnector.cs449
-rw-r--r--OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs252
2 files changed, 701 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
new file mode 100644
index 0000000..ba46b0d
--- /dev/null
+++ b/OpenSim/Services/Connectors/Grid/GridServiceConnector.cs
@@ -0,0 +1,449 @@
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 log4net;
29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Server.Base;
40using OpenMetaverse;
41
42namespace OpenSim.Services.Connectors
43{
44 public class GridServicesConnector : IGridService
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 private string m_ServerURI = String.Empty;
51
52 public GridServicesConnector()
53 {
54 }
55
56 public GridServicesConnector(string serverURI)
57 {
58 m_ServerURI = serverURI.TrimEnd('/');
59 }
60
61 public GridServicesConnector(IConfigSource source)
62 {
63 Initialise(source);
64 }
65
66 public virtual void Initialise(IConfigSource source)
67 {
68 IConfig gridConfig = source.Configs["GridService"];
69 if (gridConfig == null)
70 {
71 m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini");
72 throw new Exception("Grid connector init error");
73 }
74
75 string serviceURI = gridConfig.GetString("GridServerURI",
76 String.Empty);
77
78 if (serviceURI == String.Empty)
79 {
80 m_log.Error("[GRID CONNECTOR]: No Server URI named in section GridService");
81 throw new Exception("Grid connector init error");
82 }
83 m_ServerURI = serviceURI;
84 }
85
86
87 #region IGridService
88
89 public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo)
90 {
91 Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
92 Dictionary<string, string> sendData = new Dictionary<string,string>();
93 foreach (KeyValuePair<string, object> kvp in rinfo)
94 sendData[kvp.Key] = (string)kvp.Value;
95
96 sendData["SCOPEID"] = scopeID.ToString();
97 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
98 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
99 sendData["METHOD"] = "register";
100
101 string reqString = ServerUtils.BuildQueryString(sendData);
102 //m_log.DebugFormat("[GRID CONNECTOR]: queryString = {0}", reqString);
103 try
104 {
105 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
106 m_ServerURI + "/grid",
107 reqString);
108 if (reply != string.Empty)
109 {
110 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
111
112 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
113 return true;
114 }
115 else
116 m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");
117 }
118 catch (Exception e)
119 {
120 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
121 }
122
123 return false;
124 }
125
126 public virtual bool DeregisterRegion(UUID regionID)
127 {
128 Dictionary<string, string> sendData = new Dictionary<string, string>();
129
130 sendData["REGIONID"] = regionID.ToString();
131
132 sendData["METHOD"] = "deregister";
133
134 try
135 {
136 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
137 m_ServerURI + "/grid",
138 ServerUtils.BuildQueryString(sendData));
139
140 if (reply != string.Empty)
141 {
142 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
143
144 if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
145 return true;
146 }
147 else
148 m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply");
149 }
150 catch (Exception e)
151 {
152 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
153 }
154
155 return false;
156 }
157
158 public virtual List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID)
159 {
160 Dictionary<string, string> sendData = new Dictionary<string, string>();
161
162 sendData["SCOPEID"] = scopeID.ToString();
163 sendData["REGIONID"] = regionID.ToString();
164
165 sendData["METHOD"] = "get_neighbours";
166
167 List<GridRegion> rinfos = new List<GridRegion>();
168
169 string reqString = ServerUtils.BuildQueryString(sendData);
170 string reply = string.Empty;
171 try
172 {
173 reply = SynchronousRestFormsRequester.MakeRequest("POST",
174 m_ServerURI + "/grid",
175 reqString);
176 }
177 catch (Exception e)
178 {
179 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
180 return rinfos;
181 }
182
183 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
184
185 if (replyData != null)
186 {
187 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
188 //m_log.DebugFormat("[GRID CONNECTOR]: get neighbours returned {0} elements", rinfosList.Count);
189 foreach (object r in rinfosList)
190 {
191 if (r is Dictionary<string, object>)
192 {
193 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
194 rinfos.Add(rinfo);
195 }
196 else
197 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received invalid response type {2}",
198 scopeID, regionID, r.GetType());
199 }
200 }
201 else
202 m_log.DebugFormat("[GRID CONNECTOR]: GetNeighbours {0}, {1} received null response",
203 scopeID, regionID);
204
205 return rinfos;
206 }
207
208 public virtual GridRegion GetRegionByUUID(UUID scopeID, UUID regionID)
209 {
210 Dictionary<string, string> sendData = new Dictionary<string, string>();
211
212 sendData["SCOPEID"] = scopeID.ToString();
213 sendData["REGIONID"] = regionID.ToString();
214
215 sendData["METHOD"] = "get_region_by_uuid";
216
217 string reply = string.Empty;
218 try
219 {
220 reply = SynchronousRestFormsRequester.MakeRequest("POST",
221 m_ServerURI + "/grid",
222 ServerUtils.BuildQueryString(sendData));
223 }
224 catch (Exception e)
225 {
226 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
227 return null;
228 }
229
230 GridRegion rinfo = null;
231
232 if (reply != string.Empty)
233 {
234 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
235
236 if ((replyData != null) && (replyData["result"] != null))
237 {
238 if (replyData["result"] is Dictionary<string, object>)
239 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
240 //else
241 // m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
242 // scopeID, regionID);
243 }
244 else
245 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID {0}, {1} received null response",
246 scopeID, regionID);
247 }
248 else
249 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByUUID received null reply");
250
251 return rinfo;
252 }
253
254 public virtual GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
255 {
256 Dictionary<string, string> sendData = new Dictionary<string, string>();
257
258 sendData["SCOPEID"] = scopeID.ToString();
259 sendData["X"] = x.ToString();
260 sendData["Y"] = y.ToString();
261
262 sendData["METHOD"] = "get_region_by_position";
263 string reply = string.Empty;
264 try
265 {
266 reply = SynchronousRestFormsRequester.MakeRequest("POST",
267 m_ServerURI + "/grid",
268 ServerUtils.BuildQueryString(sendData));
269 }
270 catch (Exception e)
271 {
272 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
273 return null;
274 }
275
276 GridRegion rinfo = null;
277 if (reply != string.Empty)
278 {
279 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
280
281 if ((replyData != null) && (replyData["result"] != null))
282 {
283 if (replyData["result"] is Dictionary<string, object>)
284 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
285 else
286 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received invalid response",
287 scopeID, x, y);
288 }
289 else
290 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1}-{2} received null response",
291 scopeID, x, y);
292 }
293 else
294 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition received null reply");
295
296 return rinfo;
297 }
298
299 public virtual GridRegion GetRegionByName(UUID scopeID, string regionName)
300 {
301 Dictionary<string, string> sendData = new Dictionary<string, string>();
302
303 sendData["SCOPEID"] = scopeID.ToString();
304 sendData["NAME"] = regionName;
305
306 sendData["METHOD"] = "get_region_by_name";
307 string reply = string.Empty;
308 try
309 {
310 reply = SynchronousRestFormsRequester.MakeRequest("POST",
311 m_ServerURI + "/grid",
312 ServerUtils.BuildQueryString(sendData));
313 }
314 catch (Exception e)
315 {
316 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
317 return null;
318 }
319
320 GridRegion rinfo = null;
321 if (reply != string.Empty)
322 {
323 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
324
325 if ((replyData != null) && (replyData["result"] != null))
326 {
327 if (replyData["result"] is Dictionary<string, object>)
328 rinfo = new GridRegion((Dictionary<string, object>)replyData["result"]);
329 }
330 else
331 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByPosition {0}, {1} received null response",
332 scopeID, regionName);
333 }
334 else
335 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionByName received null reply");
336
337 return rinfo;
338 }
339
340 public virtual List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber)
341 {
342 Dictionary<string, string> sendData = new Dictionary<string, string>();
343
344 sendData["SCOPEID"] = scopeID.ToString();
345 sendData["NAME"] = name;
346 sendData["MAX"] = maxNumber.ToString();
347
348 sendData["METHOD"] = "get_regions_by_name";
349 List<GridRegion> rinfos = new List<GridRegion>();
350 string reply = string.Empty;
351 try
352 {
353 reply = SynchronousRestFormsRequester.MakeRequest("POST",
354 m_ServerURI + "/grid",
355 ServerUtils.BuildQueryString(sendData));
356 }
357 catch (Exception e)
358 {
359 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
360 return rinfos;
361 }
362
363 if (reply != string.Empty)
364 {
365 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
366
367 if (replyData != null)
368 {
369 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
370 foreach (object r in rinfosList)
371 {
372 if (r is Dictionary<string, object>)
373 {
374 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
375 rinfos.Add(rinfo);
376 }
377 else
378 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received invalid response",
379 scopeID, name, maxNumber);
380 }
381 }
382 else
383 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName {0}, {1}, {2} received null response",
384 scopeID, name, maxNumber);
385 }
386 else
387 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionsByName received null reply");
388
389 return rinfos;
390 }
391
392 public virtual List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax)
393 {
394 Dictionary<string, string> sendData = new Dictionary<string, string>();
395
396 sendData["SCOPEID"] = scopeID.ToString();
397 sendData["XMIN"] = xmin.ToString();
398 sendData["XMAX"] = xmax.ToString();
399 sendData["YMIN"] = ymin.ToString();
400 sendData["YMAX"] = ymax.ToString();
401
402 sendData["METHOD"] = "get_region_range";
403
404 List<GridRegion> rinfos = new List<GridRegion>();
405 string reply = string.Empty;
406 try
407 {
408 reply = SynchronousRestFormsRequester.MakeRequest("POST",
409 m_ServerURI + "/grid",
410 ServerUtils.BuildQueryString(sendData));
411
412 //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply);
413 }
414 catch (Exception e)
415 {
416 m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
417 return rinfos;
418 }
419
420 if (reply != string.Empty)
421 {
422 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
423
424 if (replyData != null)
425 {
426 Dictionary<string, object>.ValueCollection rinfosList = replyData.Values;
427 foreach (object r in rinfosList)
428 {
429 if (r is Dictionary<string, object>)
430 {
431 GridRegion rinfo = new GridRegion((Dictionary<string, object>)r);
432 rinfos.Add(rinfo);
433 }
434 }
435 }
436 else
437 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange {0}, {1}-{2} {3}-{4} received null response",
438 scopeID, xmin, xmax, ymin, ymax);
439 }
440 else
441 m_log.DebugFormat("[GRID CONNECTOR]: GetRegionRange received null reply");
442
443 return rinfos;
444 }
445
446 #endregion
447
448 }
449}
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
new file mode 100644
index 0000000..3d7f112
--- /dev/null
+++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs
@@ -0,0 +1,252 @@
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;
36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
37
38using OpenSim.Framework;
39
40using OpenMetaverse;
41using OpenMetaverse.Imaging;
42using log4net;
43using Nwc.XmlRpc;
44
45namespace OpenSim.Services.Connectors.Grid
46{
47 public class HypergridServiceConnector
48 {
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 private IAssetService m_AssetService;
52
53 public HypergridServiceConnector(IAssetService assService)
54 {
55 m_AssetService = assService;
56 }
57
58 public UUID LinkRegion(GridRegion info, out ulong realHandle)
59 {
60 UUID uuid = UUID.Zero;
61 realHandle = 0;
62
63 Hashtable hash = new Hashtable();
64 hash["region_name"] = info.RegionName;
65
66 IList paramList = new ArrayList();
67 paramList.Add(hash);
68
69 XmlRpcRequest request = new XmlRpcRequest("link_region", paramList);
70 string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/";
71 m_log.Debug("[HGrid]: Linking to " + uri);
72 XmlRpcResponse response = null;
73 try
74 {
75 response = request.Send(uri, 10000);
76 }
77 catch (Exception e)
78 {
79 m_log.Debug("[HGrid]: Exception " + e.Message);
80 return uuid;
81 }
82
83 if (response.IsFault)
84 {
85 m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString);
86 }
87 else
88 {
89 hash = (Hashtable)response.Value;
90 //foreach (Object o in hash)
91 // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value);
92 try
93 {
94 UUID.TryParse((string)hash["uuid"], out uuid);
95 m_log.Debug(">> HERE, uuid: " + uuid);
96 info.RegionID = uuid;
97 if ((string)hash["handle"] != null)
98 {
99 realHandle = Convert.ToUInt64((string)hash["handle"]);
100 m_log.Debug(">> HERE, realHandle: " + realHandle);
101 }
102 //if (hash["region_image"] != null)
103 //{
104 // UUID img = UUID.Zero;
105 // UUID.TryParse((string)hash["region_image"], out img);
106 // info.RegionSettings.TerrainImageID = img;
107 //}
108 if (hash["region_name"] != null)
109 {
110 info.RegionName = (string)hash["region_name"];
111 //m_log.Debug(">> " + info.RegionName);
112 }
113 if (hash["internal_port"] != null)
114 {
115 int port = Convert.ToInt32((string)hash["internal_port"]);
116 info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
117 //m_log.Debug(">> " + info.InternalEndPoint.ToString());
118 }
119
120 }
121 catch (Exception e)
122 {
123 m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace);
124 }
125 }
126 return uuid;
127 }
128
129 public void GetMapImage(GridRegion info)
130 {
131 try
132 {
133 string regionimage = "regionImage" + info.RegionID.ToString();
134 regionimage = regionimage.Replace("-", "");
135
136 WebClient c = new WebClient();
137 string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage;
138 //m_log.Debug("JPEG: " + uri);
139 c.DownloadFile(uri, info.RegionID.ToString() + ".jpg");
140 Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg");
141 //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width);
142 byte[] imageData = OpenJPEG.EncodeFromImage(m, true);
143 AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString());
144
145 // !!! for now
146 //info.RegionSettings.TerrainImageID = ass.FullID;
147
148 ass.Type = (int)AssetType.Texture;
149 ass.Temporary = true;
150 ass.Local = true;
151 ass.Data = imageData;
152
153 m_AssetService.Store(ass);
154
155 }
156 catch // LEGIT: Catching problems caused by OpenJPEG p/invoke
157 {
158 m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache");
159 }
160 }
161
162 public bool InformRegionOfUser(GridRegion regInfo, AgentCircuitData agentData, GridRegion home, string userServer, string assetServer, string inventoryServer)
163 {
164 string capsPath = agentData.CapsPath;
165 Hashtable loginParams = new Hashtable();
166 loginParams["session_id"] = agentData.SessionID.ToString();
167
168 loginParams["firstname"] = agentData.firstname;
169 loginParams["lastname"] = agentData.lastname;
170
171 loginParams["agent_id"] = agentData.AgentID.ToString();
172 loginParams["circuit_code"] = agentData.circuitcode.ToString();
173 loginParams["startpos_x"] = agentData.startpos.X.ToString();
174 loginParams["startpos_y"] = agentData.startpos.Y.ToString();
175 loginParams["startpos_z"] = agentData.startpos.Z.ToString();
176 loginParams["caps_path"] = capsPath;
177
178 if (home != null)
179 {
180 loginParams["region_uuid"] = home.RegionID.ToString();
181 loginParams["regionhandle"] = home.RegionHandle.ToString();
182 loginParams["home_address"] = home.ExternalHostName;
183 loginParams["home_port"] = home.HttpPort.ToString();
184 loginParams["internal_port"] = home.InternalEndPoint.Port.ToString();
185
186 m_log.Debug(" --------- Home -------");
187 m_log.Debug(" >> " + loginParams["home_address"] + " <<");
188 m_log.Debug(" >> " + loginParams["region_uuid"] + " <<");
189 m_log.Debug(" >> " + loginParams["regionhandle"] + " <<");
190 m_log.Debug(" >> " + loginParams["home_port"] + " <<");
191 m_log.Debug(" --------- ------------ -------");
192 }
193 else
194 m_log.WarnFormat("[HGrid]: Home region not found for {0} {1}", agentData.firstname, agentData.lastname);
195
196 loginParams["userserver_id"] = userServer;
197 loginParams["assetserver_id"] = assetServer;
198 loginParams["inventoryserver_id"] = inventoryServer;
199
200
201 ArrayList SendParams = new ArrayList();
202 SendParams.Add(loginParams);
203
204 // Send
205 string uri = "http://" + regInfo.ExternalHostName + ":" + regInfo.HttpPort + "/";
206 //m_log.Debug("XXX uri: " + uri);
207 XmlRpcRequest request = new XmlRpcRequest("expect_hg_user", SendParams);
208 XmlRpcResponse reply;
209 try
210 {
211 reply = request.Send(uri, 6000);
212 }
213 catch (Exception e)
214 {
215 m_log.Warn("[HGrid]: Failed to notify region about user. Reason: " + e.Message);
216 return false;
217 }
218
219 if (!reply.IsFault)
220 {
221 bool responseSuccess = true;
222 if (reply.Value != null)
223 {
224 Hashtable resp = (Hashtable)reply.Value;
225 if (resp.ContainsKey("success"))
226 {
227 if ((string)resp["success"] == "FALSE")
228 {
229 responseSuccess = false;
230 }
231 }
232 }
233 if (responseSuccess)
234 {
235 m_log.Info("[HGrid]: Successfully informed remote region about user " + agentData.AgentID);
236 return true;
237 }
238 else
239 {
240 m_log.ErrorFormat("[HGrid]: Region responded that it is not available to receive clients");
241 return false;
242 }
243 }
244 else
245 {
246 m_log.ErrorFormat("[HGrid]: XmlRpc request to region failed with message {0}, code {1} ", reply.FaultString, reply.FaultCode);
247 return false;
248 }
249 }
250
251 }
252}