aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2008-08-30 12:58:54 +0000
committerAdam Frisby2008-08-30 12:58:54 +0000
commit50a62145ad554277281a3166de0a29353adb07c4 (patch)
tree1fe7c14665d95c530f26b861ce301cdd5a757c52 /OpenSim
parent* Added "File Asset Client" to OpenSim Asset Server-types. (diff)
downloadopensim-SC-50a62145ad554277281a3166de0a29353adb07c4.zip
opensim-SC-50a62145ad554277281a3166de0a29353adb07c4.tar.gz
opensim-SC-50a62145ad554277281a3166de0a29353adb07c4.tar.bz2
opensim-SC-50a62145ad554277281a3166de0a29353adb07c4.tar.xz
* Initial inspection of UserLoginService.cs, cleaned up source code slightly to make it easier to work with.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Util.cs10
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs61
2 files changed, 37 insertions, 34 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 2a21221..09bf029 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -362,6 +362,16 @@ namespace OpenSim.Framework
362 } 362 }
363 363
364 /// <summary> 364 /// <summary>
365 /// Converts a URL to a IPAddress
366 /// </summary>
367 /// <param name="url">URL Standard Format</param>
368 /// <returns>A resolved IP Address</returns>
369 public static IPAddress GetHostFromURL(string url)
370 {
371 return GetHostFromDNS(url.Split(new char[] {'/', ':'})[3]);
372 }
373
374 /// <summary>
365 /// Returns a IP address from a specified DNS, favouring IPv4 addresses. 375 /// Returns a IP address from a specified DNS, favouring IPv4 addresses.
366 /// </summary> 376 /// </summary>
367 /// <param name="dnsAddress">DNS Hostname</param> 377 /// <param name="dnsAddress">DNS Hostname</param>
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index e897787..972f363 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -36,7 +36,6 @@ using OpenSim.Data;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications; 37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache; 38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Servers;
40 39
41namespace OpenSim.Grid.UserServer 40namespace OpenSim.Grid.UserServer
42{ 41{
@@ -51,7 +50,7 @@ namespace OpenSim.Grid.UserServer
51 50
52 public event UserLoggedInAtLocation OnUserLoggedInAtLocation; 51 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
53 52
54 private UserLoggedInAtLocation handlerUserLoggedInAtLocation = null; 53 private UserLoggedInAtLocation handlerUserLoggedInAtLocation;
55 54
56 public UserConfig m_config; 55 public UserConfig m_config;
57 56
@@ -66,7 +65,7 @@ namespace OpenSim.Grid.UserServer
66 65
67 public override void LogOffUser(UserProfileData theUser, string message) 66 public override void LogOffUser(UserProfileData theUser, string message)
68 { 67 {
69 RegionProfileData SimInfo = null; 68 RegionProfileData SimInfo;
70 try 69 try
71 { 70 {
72 SimInfo = RegionProfileData.RequestSimProfileData( 71 SimInfo = RegionProfileData.RequestSimProfileData(
@@ -131,6 +130,7 @@ namespace OpenSim.Grid.UserServer
131 /// </summary> 130 /// </summary>
132 /// <param name="response">The existing response</param> 131 /// <param name="response">The existing response</param>
133 /// <param name="theUser">The user profile</param> 132 /// <param name="theUser">The user profile</param>
133 /// <param name="startLocationRequest">Destination of the user</param>
134 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) 134 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest)
135 { 135 {
136 bool tryDefault = false; 136 bool tryDefault = false;
@@ -139,8 +139,8 @@ namespace OpenSim.Grid.UserServer
139 139
140 try 140 try
141 { 141 {
142 RegionProfileData SimInfo = null; 142 RegionProfileData SimInfo;
143 RegionProfileData HomeInfo = null; 143 RegionProfileData HomeInfo;
144 int start_x = -1; 144 int start_x = -1;
145 int start_y = -1; 145 int start_y = -1;
146 int start_z = -1; 146 int start_z = -1;
@@ -178,7 +178,6 @@ namespace OpenSim.Grid.UserServer
178 m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" + startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]); 178 m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" + startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]);
179 if (startLocationRequestParsed[0] == "last") 179 if (startLocationRequestParsed[0] == "last")
180 { 180 {
181 // TODO: Parse out startlocationrequest string in the format; 'uri:RegionName&X&Y&Z'
182 SimInfo = 181 SimInfo =
183 RegionProfileData.RequestSimProfileData( 182 RegionProfileData.RequestSimProfileData(
184 theUser.CurrentAgent.Handle, m_config.GridServerURL, 183 theUser.CurrentAgent.Handle, m_config.GridServerURL,
@@ -209,19 +208,18 @@ namespace OpenSim.Grid.UserServer
209 // Customise the response 208 // Customise the response
210 //CFK: This is redundant and the next message should always appear. 209 //CFK: This is redundant and the next message should always appear.
211 //CFK: m_log.Info("[LOGIN]: Home Location"); 210 //CFK: m_log.Info("[LOGIN]: Home Location");
212 response.Home = "{'region_handle':[r" + (HomeInfo.regionLocX * Constants.RegionSize).ToString() + ",r" + 211 response.Home = string.Format("{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
213 (HomeInfo.regionLocY * Constants.RegionSize).ToString() + "], " + 212 (HomeInfo.regionLocX * Constants.RegionSize),
214 "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" + 213 (HomeInfo.regionLocY * Constants.RegionSize),
215 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " + 214 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
216 "'look_at':[r" + theUser.HomeLookAt.X.ToString() + ",r" + 215 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
217 theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]}";
218 216
219 // Destination 217 // Destination
220 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into 218 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
221 //CFK: the next one for X & Y and comment this one. 219 //CFK: the next one for X & Y and comment this one.
222 //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + 220 //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX +
223 //CFK: "; Region Y: " + SimInfo.regionLocY); 221 //CFK: "; Region Y: " + SimInfo.regionLocY);
224 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString(); 222 response.SimAddress = Util.GetHostFromURL(SimInfo.serverURI).ToString();
225 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]); 223 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]);
226 response.RegionX = SimInfo.regionLocX; 224 response.RegionX = SimInfo.regionLocX;
227 response.RegionY = SimInfo.regionLocY; 225 response.RegionY = SimInfo.regionLocY;
@@ -323,7 +321,7 @@ namespace OpenSim.Grid.UserServer
323 ulong defaultHandle = (((ulong)m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong)m_config.DefaultY * Constants.RegionSize); 321 ulong defaultHandle = (((ulong)m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong)m_config.DefaultY * Constants.RegionSize);
324 322
325 m_log.Warn( 323 m_log.Warn(
326 "[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString()); 324 "[LOGIN]: Home region not available: sending to default " + defaultHandle);
327 325
328 try 326 try
329 { 327 {
@@ -333,18 +331,20 @@ namespace OpenSim.Grid.UserServer
333 331
334 // Customise the response 332 // Customise the response
335 m_log.Info("[LOGIN]: Home Location"); 333 m_log.Info("[LOGIN]: Home Location");
336 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" + 334 response.Home =
337 (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " + 335 string.Format(
338 "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" + 336 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
339 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " + 337 (SimInfo.regionLocX*Constants.RegionSize),
340 "'look_at':[r" + theUser.HomeLocation.X.ToString() + ",r" + 338 (SimInfo.regionLocY*Constants.RegionSize),
341 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "]}"; 339 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
340 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
341
342 342
343 // Destination 343 // Destination
344 m_log.Info("[LOGIN]: " + 344 m_log.Info("[LOGIN]: " +
345 "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + 345 "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
346 SimInfo.regionLocY); 346 SimInfo.regionLocY);
347 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString(); 347 response.SimAddress = Util.GetHostFromURL(SimInfo.serverURI).ToString();
348 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]); 348 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]);
349 response.RegionX = SimInfo.regionLocX; 349 response.RegionX = SimInfo.regionLocX;
350 response.RegionY = SimInfo.regionLocY; 350 response.RegionY = SimInfo.regionLocY;
@@ -394,7 +394,6 @@ namespace OpenSim.Grid.UserServer
394 if ((string)resp["success"] == "FALSE") 394 if ((string)resp["success"] == "FALSE")
395 { 395 {
396 responseSuccess = false; 396 responseSuccess = false;
397 tryDefault = true;
398 } 397 }
399 } 398 }
400 } 399 }
@@ -424,7 +423,7 @@ namespace OpenSim.Grid.UserServer
424 catch (Exception e) 423 catch (Exception e)
425 { 424 {
426 m_log.Warn("[LOGIN]: Default region also not available"); 425 m_log.Warn("[LOGIN]: Default region also not available");
427 m_log.Warn("[LOGIN]: " + e.ToString()); 426 m_log.Warn("[LOGIN]: " + e);
428 } 427 }
429 } 428 }
430 } 429 }
@@ -455,10 +454,7 @@ namespace OpenSim.Grid.UserServer
455 + " Please contact your inventory service provider for more information.", 454 + " Please contact your inventory service provider for more information.",
456 userID)); 455 userID));
457 } 456 }
458 else 457 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID);
459 {
460 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID);
461 }
462 458
463 folders = m_inventoryService.GetInventorySkeleton(userID); 459 folders = m_inventoryService.GetInventorySkeleton(userID);
464 } 460 }
@@ -488,13 +484,10 @@ namespace OpenSim.Grid.UserServer
488 484
489 return new InventoryData(AgentInventoryArray, rootID); 485 return new InventoryData(AgentInventoryArray, rootID);
490 } 486 }
491 else 487 throw new Exception(
492 { 488 String.Format(
493 throw new Exception( 489 "A root inventory folder for user {0} could not be retrieved from the inventory service",
494 String.Format( 490 userID));
495 "A root inventory folder for user {0} could not be retrieved from the inventory service",
496 userID));
497 }
498 } 491 }
499 } 492 }
500} 493}