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.

This commit is contained in:
Brian McBee
2007-11-25 21:21:44 +00:00
parent 7720be5a39
commit 35472b3666
3 changed files with 138 additions and 62 deletions

View File

@@ -54,76 +54,139 @@ namespace OpenSim.Grid.UserServer
/// <param name="theUser">The user profile</param>
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)
{
case WebExceptionStatus.Timeout:
//TODO: Send him to nearby or default region instead
MainLog.Instance.Verbose("Unable to connect to " + SimInfo.regionName + " (" + SimInfo.serverURI +
")");
break;
tryDefault = true;
}
if(tryDefault)
{
// Send him to default region instead
// Load information from the gridserver
default:
throw;
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
{
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());
}
}
}
}