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.
parent
7720be5a39
commit
35472b3666
|
@ -42,6 +42,8 @@ namespace OpenSim.Framework
|
|||
|
||||
public static uint DefaultHttpPort = 8002;
|
||||
public uint HttpPort = DefaultHttpPort;
|
||||
public uint DefaultX = 1000;
|
||||
public uint DefaultY = 1000;
|
||||
|
||||
private ConfigurationMember configMember;
|
||||
|
||||
|
@ -71,6 +73,10 @@ namespace OpenSim.Framework
|
|||
|
||||
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
|
||||
"Http Listener port", DefaultHttpPort.ToString(), false);
|
||||
configMember.addConfigurationOption("default_X", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
|
||||
"Known good region X", "1000", false);
|
||||
configMember.addConfigurationOption("default_Y", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
|
||||
"Known good region Y", "1000", false);
|
||||
}
|
||||
|
||||
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||
|
@ -95,6 +101,12 @@ namespace OpenSim.Framework
|
|||
case "http_port":
|
||||
HttpPort = (uint) configuration_result;
|
||||
break;
|
||||
case "default_X":
|
||||
DefaultX = (uint)configuration_result;
|
||||
break;
|
||||
case "default_Y":
|
||||
DefaultY = (uint)configuration_result;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -54,16 +54,19 @@ 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();
|
||||
try
|
||||
{
|
||||
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() + "], " +
|
||||
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" +
|
||||
|
@ -73,7 +76,7 @@ namespace OpenSim.Grid.UserServer
|
|||
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.SimPort = (Int32)SimInfo.serverPort;
|
||||
response.RegionX = SimInfo.regionLocX;
|
||||
response.RegionY = SimInfo.regionLocY;
|
||||
|
||||
|
@ -91,7 +94,7 @@ namespace OpenSim.Grid.UserServer
|
|||
SimParams["firstname"] = theUser.username;
|
||||
SimParams["lastname"] = theUser.surname;
|
||||
SimParams["agent_id"] = theUser.UUID.ToString();
|
||||
SimParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode);
|
||||
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();
|
||||
|
@ -106,24 +109,84 @@ namespace OpenSim.Grid.UserServer
|
|||
|
||||
MainLog.Instance.Verbose("Informing region --> " + SimInfo.httpServerURI);
|
||||
// Send
|
||||
try
|
||||
{
|
||||
|
||||
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;
|
||||
|
||||
default:
|
||||
throw;
|
||||
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
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,11 +166,12 @@ namespace OpenSim.Region.ClientStack
|
|||
//userEP);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
MainLog.Instance.Warn("client",
|
||||
"ClientView.PacketQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " +
|
||||
userEP.ToString() + " - killing thread");
|
||||
MainLog.Instance.Error(e.ToString());
|
||||
KillThread();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue