aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/LoginService.cs
diff options
context:
space:
mode:
authorlbsa712009-03-11 19:19:48 +0000
committerlbsa712009-03-11 19:19:48 +0000
commit2133d358317f28fe54020207ed8fa59562e1d6eb (patch)
treedf648eee35bf347a7ba66a15bdec6a1b4082840b /OpenSim/Framework/Communications/LoginService.cs
parentThanks rtomita for a patch to fix inventory listings for clients using libomv... (diff)
downloadopensim-SC_OLD-2133d358317f28fe54020207ed8fa59562e1d6eb.zip
opensim-SC_OLD-2133d358317f28fe54020207ed8fa59562e1d6eb.tar.gz
opensim-SC_OLD-2133d358317f28fe54020207ed8fa59562e1d6eb.tar.bz2
opensim-SC_OLD-2133d358317f28fe54020207ed8fa59562e1d6eb.tar.xz
* Reverted r8750 to do another round of debugging on mantis #3287
Diffstat (limited to 'OpenSim/Framework/Communications/LoginService.cs')
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs150
1 files changed, 9 insertions, 141 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 1e7faa5..36d7280 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -78,6 +78,15 @@ namespace OpenSim.Framework.Communications
78 } 78 }
79 79
80 /// <summary> 80 /// <summary>
81 /// Customises the login response and fills in missing values. This method also tells the login region to
82 /// expect a client connection.
83 /// </summary>
84 /// <param name="response">The existing response</param>
85 /// <param name="theUser">The user profile</param>
86 /// <returns>true on success, false if the region was not successfully told to expect a user connection</returns>
87 public abstract bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest);
88
89 /// <summary>
81 /// If the user is already logged in, try to notify the region that the user they've got is dead. 90 /// If the user is already logged in, try to notify the region that the user they've got is dead.
82 /// </summary> 91 /// </summary>
83 /// <param name="theUser"></param> 92 /// <param name="theUser"></param>
@@ -863,146 +872,5 @@ namespace OpenSim.Framework.Communications
863 m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); 872 m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key);
864 } 873 }
865 } 874 }
866
867 /// <summary>
868 /// Customises the login response and fills in missing values. This method also tells the login region to
869 /// expect a client connection.
870 /// </summary>
871 /// <param name="response">The existing response</param>
872 /// <param name="theUser">The user profile</param>
873 /// <param name="startLocationRequest">The requested start location</param>
874 /// <returns>true on success, false if the region was not successfully told to expect a user connection</returns>
875 public bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest)
876 {
877 // add active gestures to login-response
878 AddActiveGestures(response, theUser);
879
880 // HomeLocation
881 RegionInfo homeInfo = null;
882
883 // use the homeRegionID if it is stored already. If not, use the regionHandle as before
884 UUID homeRegionId = theUser.HomeRegionID;
885 ulong homeRegionHandle = theUser.HomeRegion;
886 if (homeRegionId != UUID.Zero)
887 {
888 homeInfo = GetRegionInfo(homeRegionId);
889 }
890 else
891 {
892 homeInfo = GetRegionInfo(homeRegionHandle);
893 }
894
895 if (homeInfo != null)
896 {
897 response.Home =
898 string.Format(
899 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
900 (homeInfo.RegionLocX * Constants.RegionSize),
901 (homeInfo.RegionLocY * Constants.RegionSize),
902 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
903 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
904 }
905 else
906 {
907 m_log.InfoFormat("not found the region at {0} {1}", theUser.HomeRegionX, theUser.HomeRegionY);
908 // Emergency mode: Home-region isn't available, so we can't request the region info.
909 // Use the stored home regionHandle instead.
910 // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again
911 ulong regionX = homeRegionHandle >> 32;
912 ulong regionY = homeRegionHandle & 0xffffffff;
913 response.Home =
914 string.Format(
915 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
916 regionX, regionY,
917 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
918 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
919
920 m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}",
921 theUser.FirstName, theUser.SurName,
922 regionX, regionY);
923 }
924
925 // StartLocation
926 RegionInfo regionInfo = null;
927 if (startLocationRequest == "home")
928 {
929 regionInfo = homeInfo;
930 theUser.CurrentAgent.Position = theUser.HomeLocation;
931 response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]";
932 }
933 else if (startLocationRequest == "last")
934 {
935 UUID lastRegion = theUser.CurrentAgent.Region;
936 regionInfo = GetRegionInfo(lastRegion);
937 response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]";
938 }
939 else
940 {
941 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
942 Match uriMatch = reURI.Match(startLocationRequest);
943 if (uriMatch == null)
944 {
945 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest);
946 }
947 else
948 {
949 string region = uriMatch.Groups["region"].ToString();
950 regionInfo = RequestClosestRegion(region);
951 if (regionInfo == null)
952 {
953 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region);
954 }
955 else
956 {
957 theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value),
958 float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value));
959 }
960 }
961 response.LookAt = "[r0,r1,r0]";
962 // can be: last, home, safe, url
963 response.StartLocation = "url";
964 }
965
966 if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response)))
967 {
968 return true;
969 }
970
971 // StartLocation not available, send him to a nearby region instead
972 // regionInfo = m_gridService.RequestClosestRegion("");
973 //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName);
974
975 // Send him to default region instead
976 ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) |
977 ((ulong)m_defaultHomeY * Constants.RegionSize);
978
979 if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle))
980 {
981 m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region");
982 return false;
983 }
984
985 m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead");
986 regionInfo = GetRegionInfo(defaultHandle);
987
988 // Customise the response
989 //response.Home =
990 // string.Format(
991 // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
992 // (SimInfo.regionLocX * Constants.RegionSize),
993 // (SimInfo.regionLocY*Constants.RegionSize),
994 // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
995 // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
996 theUser.CurrentAgent.Position = new Vector3(128, 128, 0);
997 response.StartLocation = "safe";
998
999 return PrepareLoginToRegion(regionInfo, theUser, response);
1000 }
1001
1002 protected abstract RegionInfo RequestClosestRegion(string region);
1003 protected abstract RegionInfo GetRegionInfo(ulong homeRegionHandle);
1004 protected abstract RegionInfo GetRegionInfo(UUID homeRegionId);
1005 protected abstract void AddActiveGestures(LoginResponse response, UserProfileData theUser);
1006 protected abstract bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response);
1007 } 875 }
1008} 876}