aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/GridServer
diff options
context:
space:
mode:
authorlbsa712008-03-12 09:37:39 +0000
committerlbsa712008-03-12 09:37:39 +0000
commitd873a043dda68490ee47508c31d4c0f55ca0e21a (patch)
treef07a3f0c8e33f9c2b920cbd1f8f3c3242d477737 /OpenSim/Grid/GridServer
parent* Extracted RegionProfileData from Request (diff)
downloadopensim-SC_OLD-d873a043dda68490ee47508c31d4c0f55ca0e21a.zip
opensim-SC_OLD-d873a043dda68490ee47508c31d4c0f55ca0e21a.tar.gz
opensim-SC_OLD-d873a043dda68490ee47508c31d4c0f55ca0e21a.tar.bz2
opensim-SC_OLD-d873a043dda68490ee47508c31d4c0f55ca0e21a.tar.xz
* Refactored out creation of LoginResponse
* Refactored out ErrorResponse
Diffstat (limited to 'OpenSim/Grid/GridServer')
-rw-r--r--OpenSim/Grid/GridServer/GridManager.cs235
1 files changed, 121 insertions, 114 deletions
diff --git a/OpenSim/Grid/GridServer/GridManager.cs b/OpenSim/Grid/GridServer/GridManager.cs
index a6cefbc..69c56d2 100644
--- a/OpenSim/Grid/GridServer/GridManager.cs
+++ b/OpenSim/Grid/GridServer/GridManager.cs
@@ -239,6 +239,15 @@ namespace OpenSim.Grid.GridServer
239 return validated; 239 return validated;
240 } 240 }
241 241
242 private XmlRpcResponse ErrorResponse(string error)
243 {
244 XmlRpcResponse errorResponse = new XmlRpcResponse();
245 Hashtable errorResponseData = new Hashtable();
246 errorResponse.Value = errorResponseData;
247 errorResponseData["error"] = error;
248 return errorResponse;
249 }
250
242 /// <summary> 251 /// <summary>
243 /// Performed when a region connects to the grid server initially. 252 /// Performed when a region connects to the grid server initially.
244 /// </summary> 253 /// </summary>
@@ -246,9 +255,6 @@ namespace OpenSim.Grid.GridServer
246 /// <returns>Startup parameters</returns> 255 /// <returns>Startup parameters</returns>
247 public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request) 256 public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request)
248 { 257 {
249 XmlRpcResponse response = new XmlRpcResponse();
250 Hashtable responseData = new Hashtable();
251 response.Value = responseData;
252 258
253 RegionProfileData sim; 259 RegionProfileData sim;
254 RegionProfileData existingSim; 260 RegionProfileData existingSim;
@@ -258,13 +264,11 @@ namespace OpenSim.Grid.GridServer
258 264
259 if (requestData.ContainsKey("UUID") && LLUUID.TryParse((string)requestData["UUID"], out uuid)) 265 if (requestData.ContainsKey("UUID") && LLUUID.TryParse((string)requestData["UUID"], out uuid))
260 { 266 {
261 existingSim = getRegion(uuid);
262 } 267 }
263 else 268 else
264 { 269 {
265 m_log.Info("[GRID]: Region connected without a UUID, ignoring."); 270 m_log.Info("[GRID]: Region connected without a UUID, ignoring.");
266 responseData["error"] = "No UUID passed to grid server - unable to connect you"; 271 return ErrorResponse("No UUID passed to grid server - unable to connect you");
267 return response;
268 } 272 }
269 273
270 try 274 try
@@ -274,8 +278,7 @@ namespace OpenSim.Grid.GridServer
274 catch (FormatException e) 278 catch (FormatException e)
275 { 279 {
276 m_log.Info("[GRID]: Invalid login parameters, ignoring."); 280 m_log.Info("[GRID]: Invalid login parameters, ignoring.");
277 responseData["error"] = "Wrong format in login parameters. Please verify parameters."; 281 return ErrorResponse("Wrong format in login parameters. Please verify parameters.");
278 return response;
279 } 282 }
280 283
281 existingSim = getRegion(sim.regionHandle); 284 existingSim = getRegion(sim.regionHandle);
@@ -325,110 +328,10 @@ namespace OpenSim.Grid.GridServer
325 "Unable to add region " + sim.UUID.ToString() + " via " + kvp.Key); 328 "Unable to add region " + sim.UUID.ToString() + " via " + kvp.Key);
326 m_log.Warn("[storage]: " + e.ToString()); 329 m_log.Warn("[storage]: " + e.ToString());
327 } 330 }
328
329
330 if (getRegion(sim.regionHandle) == null)
331 {
332 responseData["error"] = "Unable to add new region";
333 return response;
334 }
335 } 331 }
336 332
333 XmlRpcResponse response = CreateLoginResponse(sim);
337 334
338
339 ArrayList SimNeighboursData = new ArrayList();
340
341 RegionProfileData neighbour;
342 Hashtable NeighbourBlock;
343
344 bool fastMode = false; // Only compatible with MySQL right now
345
346 if (fastMode)
347 {
348 Dictionary<ulong, RegionProfileData> neighbours =
349 getRegions(sim.regionLocX - 1, sim.regionLocY - 1, sim.regionLocX + 1,
350 sim.regionLocY + 1);
351
352 foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours)
353 {
354 NeighbourBlock = new Hashtable();
355 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(aSim.Value.serverIP.ToString()).ToString();
356 NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString();
357 NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString();
358 NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString();
359 NeighbourBlock["UUID"] = aSim.Value.UUID.ToString();
360 NeighbourBlock["regionHandle"] = aSim.Value.regionHandle.ToString();
361
362 if (aSim.Value.UUID != sim.UUID)
363 {
364 SimNeighboursData.Add(NeighbourBlock);
365 }
366 }
367 }
368 else
369 {
370 for (int x = -1; x < 2; x++)
371 for (int y = -1; y < 2; y++)
372 {
373 if (
374 getRegion(
375 Helpers.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
376 (uint)(sim.regionLocY + y) * Constants.RegionSize)) != null)
377 {
378 neighbour =
379 getRegion(
380 Helpers.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
381 (uint)(sim.regionLocY + y) * Constants.RegionSize));
382
383 NeighbourBlock = new Hashtable();
384 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString();
385 NeighbourBlock["sim_port"] = neighbour.serverPort.ToString();
386 NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString();
387 NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString();
388 NeighbourBlock["UUID"] = neighbour.UUID.ToString();
389 NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString();
390
391 if (neighbour.UUID != sim.UUID) SimNeighboursData.Add(NeighbourBlock);
392 }
393 }
394 }
395
396 responseData["UUID"] = sim.UUID.ToString();
397 responseData["region_locx"] = sim.regionLocX.ToString();
398 responseData["region_locy"] = sim.regionLocY.ToString();
399 responseData["regionname"] = sim.regionName;
400 responseData["estate_id"] = "1";
401 responseData["neighbours"] = SimNeighboursData;
402
403 responseData["sim_ip"] = sim.serverIP;
404 responseData["sim_port"] = sim.serverPort.ToString();
405 responseData["asset_url"] = sim.regionAssetURI;
406 responseData["asset_sendkey"] = sim.regionAssetSendKey;
407 responseData["asset_recvkey"] = sim.regionAssetRecvKey;
408 responseData["user_url"] = sim.regionUserURI;
409 responseData["user_sendkey"] = sim.regionUserSendKey;
410 responseData["user_recvkey"] = sim.regionUserRecvKey;
411 responseData["authkey"] = sim.regionSecret;
412
413 // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap)
414 responseData["data_uri"] = sim.regionDataURI;
415
416 responseData["allow_forceful_banlines"] = Config.AllowForcefulBanlines;
417
418 // Instead of sending a multitude of message servers to the registering sim
419 // we should probably be sending a single one and parhaps it's backup
420 // that has responsibility over routing it's messages.
421
422 // The Sim won't be contacting us again about any of the message server stuff during it's time up.
423
424 responseData["messageserver_count"] = _MessageServers.Count;
425
426 for (int i = 0; i < _MessageServers.Count; i++)
427 {
428 responseData["messageserver_uri" + i] = _MessageServers[i].URI;
429 responseData["messageserver_sendkey" + i] = _MessageServers[i].sendkey;
430 responseData["messageserver_recvkey" + i] = _MessageServers[i].recvkey;
431 }
432 return response; 335 return response;
433 } 336 }
434 else 337 else
@@ -446,18 +349,122 @@ namespace OpenSim.Grid.GridServer
446 " " + sim.regionLocY + " currently occupied by " + existingSim.regionName); 349 " " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
447 } 350 }
448 351
449 responseData["error"] = 352 return ErrorResponse("The key required to connect to your region did not match. Please check your send and recieve keys.");
450 "The key required to connect to your region did not match. Please check your send and recieve keys.";
451 return response;
452 } 353 }
453 } 354 }
454 else 355 else
455 { 356 {
456 m_log.Warn("[grid]: Failed to add new region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName); 357 m_log.Warn("[grid]: Failed to add new region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName);
457 responseData["error"] = "Another region already exists at that location. Try another"; 358 return ErrorResponse("Another region already exists at that location. Try another");
458 return response;
459 } 359 }
360 }
460 361
362 private XmlRpcResponse CreateLoginResponse(RegionProfileData sim)
363 {
364 XmlRpcResponse response = new XmlRpcResponse();
365 Hashtable responseData = new Hashtable();
366 response.Value = responseData;
367
368 ArrayList SimNeighboursData = GetSimNeighboursData(sim);
369
370 responseData["UUID"] = sim.UUID.ToString();
371 responseData["region_locx"] = sim.regionLocX.ToString();
372 responseData["region_locy"] = sim.regionLocY.ToString();
373 responseData["regionname"] = sim.regionName;
374 responseData["estate_id"] = "1";
375 responseData["neighbours"] = SimNeighboursData;
376
377 responseData["sim_ip"] = sim.serverIP;
378 responseData["sim_port"] = sim.serverPort.ToString();
379 responseData["asset_url"] = sim.regionAssetURI;
380 responseData["asset_sendkey"] = sim.regionAssetSendKey;
381 responseData["asset_recvkey"] = sim.regionAssetRecvKey;
382 responseData["user_url"] = sim.regionUserURI;
383 responseData["user_sendkey"] = sim.regionUserSendKey;
384 responseData["user_recvkey"] = sim.regionUserRecvKey;
385 responseData["authkey"] = sim.regionSecret;
386
387 // New! If set, use as URL to local sim storage (ie http://remotehost/region.yap)
388 responseData["data_uri"] = sim.regionDataURI;
389
390 responseData["allow_forceful_banlines"] = Config.AllowForcefulBanlines;
391
392 // Instead of sending a multitude of message servers to the registering sim
393 // we should probably be sending a single one and parhaps it's backup
394 // that has responsibility over routing it's messages.
395
396 // The Sim won't be contacting us again about any of the message server stuff during it's time up.
397
398 responseData["messageserver_count"] = _MessageServers.Count;
399
400 for (int i = 0; i < _MessageServers.Count; i++)
401 {
402 responseData["messageserver_uri" + i] = _MessageServers[i].URI;
403 responseData["messageserver_sendkey" + i] = _MessageServers[i].sendkey;
404 responseData["messageserver_recvkey" + i] = _MessageServers[i].recvkey;
405 }
406 return response;
407 }
408
409 private ArrayList GetSimNeighboursData(RegionProfileData sim)
410 {
411 ArrayList SimNeighboursData = new ArrayList();
412
413 RegionProfileData neighbour;
414 Hashtable NeighbourBlock;
415
416 bool fastMode = false; // Only compatible with MySQL right now
417
418 if (fastMode)
419 {
420 Dictionary<ulong, RegionProfileData> neighbours =
421 getRegions(sim.regionLocX - 1, sim.regionLocY - 1, sim.regionLocX + 1,
422 sim.regionLocY + 1);
423
424 foreach (KeyValuePair<ulong, RegionProfileData> aSim in neighbours)
425 {
426 NeighbourBlock = new Hashtable();
427 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(aSim.Value.serverIP.ToString()).ToString();
428 NeighbourBlock["sim_port"] = aSim.Value.serverPort.ToString();
429 NeighbourBlock["region_locx"] = aSim.Value.regionLocX.ToString();
430 NeighbourBlock["region_locy"] = aSim.Value.regionLocY.ToString();
431 NeighbourBlock["UUID"] = aSim.Value.UUID.ToString();
432 NeighbourBlock["regionHandle"] = aSim.Value.regionHandle.ToString();
433
434 if (aSim.Value.UUID != sim.UUID)
435 {
436 SimNeighboursData.Add(NeighbourBlock);
437 }
438 }
439 }
440 else
441 {
442 for (int x = -1; x < 2; x++)
443 for (int y = -1; y < 2; y++)
444 {
445 if (
446 getRegion(
447 Helpers.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
448 (uint)(sim.regionLocY + y) * Constants.RegionSize)) != null)
449 {
450 neighbour =
451 getRegion(
452 Helpers.UIntsToLong((uint)((sim.regionLocX + x) * Constants.RegionSize),
453 (uint)(sim.regionLocY + y) * Constants.RegionSize));
454
455 NeighbourBlock = new Hashtable();
456 NeighbourBlock["sim_ip"] = Util.GetHostFromDNS(neighbour.serverIP).ToString();
457 NeighbourBlock["sim_port"] = neighbour.serverPort.ToString();
458 NeighbourBlock["region_locx"] = neighbour.regionLocX.ToString();
459 NeighbourBlock["region_locy"] = neighbour.regionLocY.ToString();
460 NeighbourBlock["UUID"] = neighbour.UUID.ToString();
461 NeighbourBlock["regionHandle"] = neighbour.regionHandle.ToString();
462
463 if (neighbour.UUID != sim.UUID) SimNeighboursData.Add(NeighbourBlock);
464 }
465 }
466 }
467 return SimNeighboursData;
461 } 468 }
462 469
463 private RegionProfileData RegionFromRequest(Hashtable requestData) 470 private RegionProfileData RegionFromRequest(Hashtable requestData)