aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorlbsa712009-03-10 12:11:19 +0000
committerlbsa712009-03-10 12:11:19 +0000
commit0df0258087e18757a77514ac4cba8a50e01b27d5 (patch)
tree7896a546e9782c105f7bcbfa07cd7df0d5407929 /OpenSim/Framework/Communications
parent* Re-aligned CustomiseResponse function for imminent up-pulling (diff)
downloadopensim-SC_OLD-0df0258087e18757a77514ac4cba8a50e01b27d5.zip
opensim-SC_OLD-0df0258087e18757a77514ac4cba8a50e01b27d5.tar.gz
opensim-SC_OLD-0df0258087e18757a77514ac4cba8a50e01b27d5.tar.bz2
opensim-SC_OLD-0df0258087e18757a77514ac4cba8a50e01b27d5.tar.xz
*** POTENTIAL BREAKAGE ***
* Finally got to the point where I could pull up the CustomiseResponse function. Major de-duplication. * Introduced FromRegionInfo on RegionProfileData * This revision needs both grid and standalone testing galore. Work in progress!
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs150
1 files changed, 141 insertions, 9 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 36d7280..1e7faa5 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -78,15 +78,6 @@ 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>
90 /// If the user is already logged in, try to notify the region that the user they've got is dead. 81 /// If the user is already logged in, try to notify the region that the user they've got is dead.
91 /// </summary> 82 /// </summary>
92 /// <param name="theUser"></param> 83 /// <param name="theUser"></param>
@@ -872,5 +863,146 @@ namespace OpenSim.Framework.Communications
872 m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key); 863 m_log.InfoFormat("[LOGIN]: Login with web_login_key {0}", web_login_key);
873 } 864 }
874 } 865 }
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);
875 } 1007 }
876} 1008}