From 35472b36663fba7528358daa65e029d41ecde206 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Sun, 25 Nov 2007 21:21:44 +0000 Subject: Added new configuration item to User Server: X and Y of region to send user to if their logon region is down. Known good region, sort of. --- OpenSim/Grid/UserServer/UserLoginService.cs | 185 +++++++++++++++++++--------- 1 file changed, 124 insertions(+), 61 deletions(-) (limited to 'OpenSim/Grid/UserServer') diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index bbef4b2..0af5790 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs @@ -54,76 +54,139 @@ namespace OpenSim.Grid.UserServer /// The user profile public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) { - // Load information from the gridserver + bool tryDefault = false; + System.Console.WriteLine("Load information from the gridserver"); RegionProfileData SimInfo = new RegionProfileData(); - SimInfo = - SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, - m_config.GridSendKey, m_config.GridRecvKey); - - // Customise the response - // Home Location - response.Home = "{'region_handle':[r" + (SimInfo.regionLocX*256).ToString() + ",r" + - (SimInfo.regionLocY*256).ToString() + "], " + - "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + - theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + - "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + - theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; - - // Destination - MainLog.Instance.Verbose("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + - SimInfo.regionLocY); - response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); - response.SimPort = (Int32) SimInfo.serverPort; - response.RegionX = SimInfo.regionLocX; - response.RegionY = SimInfo.regionLocY; - - //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI - string capsPath = Util.GetRandomCapsPath(); - response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; - - // Notify the target of an incoming user - MainLog.Instance.Verbose("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); - - // Prepare notification - Hashtable SimParams = new Hashtable(); - SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); - SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); - SimParams["firstname"] = theUser.username; - SimParams["lastname"] = theUser.surname; - SimParams["agent_id"] = theUser.UUID.ToString(); - SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode); - SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); - SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); - SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); - SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString(); - SimParams["caps_path"] = capsPath; - ArrayList SendParams = new ArrayList(); - SendParams.Add(SimParams); - - // Update agent with target sim - theUser.currentAgent.currentRegion = SimInfo.UUID; - theUser.currentAgent.currentHandle = SimInfo.regionHandle; - - MainLog.Instance.Verbose("Informing region --> " + SimInfo.httpServerURI); - // Send try { + SimInfo = + SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, + m_config.GridSendKey, m_config.GridRecvKey); + + // Customise the response + System.Console.WriteLine("Home Location"); + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + + (SimInfo.regionLocY * 256).ToString() + "], " + + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; + + // Destination + MainLog.Instance.Verbose("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + + SimInfo.regionLocY); + response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); + response.SimPort = (Int32)SimInfo.serverPort; + response.RegionX = SimInfo.regionLocX; + response.RegionY = SimInfo.regionLocY; + + //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI + string capsPath = Util.GetRandomCapsPath(); + response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; + + // Notify the target of an incoming user + MainLog.Instance.Verbose("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); + + // Prepare notification + Hashtable SimParams = new Hashtable(); + SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); + SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); + SimParams["firstname"] = theUser.username; + SimParams["lastname"] = theUser.surname; + SimParams["agent_id"] = theUser.UUID.ToString(); + SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); + SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); + SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); + SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); + SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString(); + SimParams["caps_path"] = capsPath; + ArrayList SendParams = new ArrayList(); + SendParams.Add(SimParams); + + // Update agent with target sim + theUser.currentAgent.currentRegion = SimInfo.UUID; + theUser.currentAgent.currentHandle = SimInfo.regionHandle; + + MainLog.Instance.Verbose("Informing region --> " + SimInfo.httpServerURI); + // Send + XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); } - catch (WebException e) + catch (Exception e) { - switch (e.Status) + tryDefault = true; + } + if(tryDefault) + { + // Send him to default region instead + // Load information from the gridserver + + ulong defaultHandle = (((ulong)m_config.DefaultX * 256) << 32) | ((ulong) m_config.DefaultY * 256); + MainLog.Instance.Warn("Home region not available: sending to default region " + defaultHandle.ToString()); + SimInfo = new RegionProfileData(); + try { - case WebExceptionStatus.Timeout: - //TODO: Send him to nearby or default region instead - MainLog.Instance.Verbose("Unable to connect to " + SimInfo.regionName + " (" + SimInfo.serverURI + - ")"); - break; - - default: - throw; + SimInfo = + SimInfo.RequestSimProfileData(defaultHandle, m_config.GridServerURL, + m_config.GridSendKey, m_config.GridRecvKey); + + // Customise the response + System.Console.WriteLine("Home Location"); + response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + + (SimInfo.regionLocY * 256).ToString() + "], " + + "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + + "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; + + // Destination + MainLog.Instance.Verbose("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + + SimInfo.regionLocY); + response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString(); + response.SimPort = (Int32)SimInfo.serverPort; + response.RegionX = SimInfo.regionLocX; + response.RegionY = SimInfo.regionLocY; + + //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI + string capsPath = Util.GetRandomCapsPath(); + response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; + + // Notify the target of an incoming user + MainLog.Instance.Verbose("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")"); + + // Update agent with target sim + theUser.currentAgent.currentRegion = SimInfo.UUID; + theUser.currentAgent.currentHandle = SimInfo.regionHandle; + + // Prepare notification + Hashtable SimParams = new Hashtable(); + SimParams["session_id"] = theUser.currentAgent.sessionID.ToString(); + SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString(); + SimParams["firstname"] = theUser.username; + SimParams["lastname"] = theUser.surname; + SimParams["agent_id"] = theUser.UUID.ToString(); + SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); + SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString(); + SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString(); + SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString(); + SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString(); + SimParams["caps_path"] = capsPath; + ArrayList SendParams = new ArrayList(); + SendParams.Add(SimParams); + + MainLog.Instance.Verbose("Informing region --> " + SimInfo.httpServerURI); + // Send + XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); + XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); } + + catch (Exception e) + { + MainLog.Instance.Warn("Default region also not available"); + MainLog.Instance.Verbose(e.ToString()); + } + } } } -- cgit v1.1