Check if remote simulator is up before attempting teleport. Teleport to a remote region should now fail gracefully if remote simulator is down.

ThreadPoolClientBranch
Brian McBee 2008-01-20 19:12:00 +00:00
parent 8ffefd2bd6
commit 730e2d6d7c
5 changed files with 73 additions and 28 deletions

View File

@ -555,7 +555,7 @@ namespace OpenSim.Framework
void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID,
uint flags, string capsURL);
void SendTeleportFailed();
void SendTeleportFailed(string reason);
void SendTeleportLocationStart();
void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance);

View File

@ -890,11 +890,11 @@ namespace OpenSim.Region.ClientStack
/// <summary>
///
/// </summary>
public void SendTeleportFailed()
public void SendTeleportFailed(string reason)
{
TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
tpFailed.Info.AgentID = AgentId;
tpFailed.Info.Reason = Helpers.StringToField("unknown failure of teleport");
tpFailed.Info.Reason = Helpers.StringToField(reason);
OutPacket(tpFailed, ThrottleOutPacketType.Task);
}

View File

@ -594,28 +594,31 @@ namespace OpenSim.Region.Communications.OGS1
//don't want to be creating a new link to the remote instance every time like we are here
bool retValue = false;
OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting) Activator.GetObject(
typeof (OGS1InterRegionRemoting),
"tcp://" + regInfo.RemotingAddress +
":" + regInfo.RemotingPort +
"/InterRegions");
if (remObject != null)
checkRegion(regInfo.RemotingAddress, regInfo.RemotingPort);
if (Available)
{
retValue = remObject.InformRegionOfChildAgent(regionHandle, new sAgentCircuitData(agentData));
}
else
{
Console.WriteLine("remoting object not found");
}
remObject = null;
MainLog.Instance.Verbose("INTER",
gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " +
agentData.firstname + " " + agentData.lastname + " and got " +
retValue.ToString());
OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject(
typeof(OGS1InterRegionRemoting),
"tcp://" + regInfo.RemotingAddress +
":" + regInfo.RemotingPort +
"/InterRegions");
return retValue;
if (remObject != null)
{
retValue = remObject.InformRegionOfChildAgent(regionHandle, new sAgentCircuitData(agentData));
}
else
{
Console.WriteLine("remoting object not found");
}
remObject = null;
MainLog.Instance.Verbose("INTER",
gdebugRegionName + ": OGS1 tried to InformRegionOfChildAgent for " +
agentData.firstname + " " + agentData.lastname + " and got " +
retValue.ToString());
return retValue;
}
}
return false;
@ -1085,5 +1088,41 @@ namespace OpenSim.Region.Communications.OGS1
#endregion
#endregion
// helper to see if remote region is up
bool m_bAvailable = false;
int timeOut = 15000; //15 seconds
public void checkRegion(string address, uint port)
{
IPAddress ia = null;
IPAddress.TryParse(address, out ia);
IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port);
AsyncCallback ConnectedMethodCallback = new AsyncCallback(ConnectedMethod);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult ar = socket.BeginConnect(m_EndPoint, ConnectedMethodCallback, socket);
ar.AsyncWaitHandle.WaitOne(timeOut, false);
socket.Close();
}
public bool Available
{
get { return m_bAvailable; }
}
void ConnectedMethod(IAsyncResult ar)
{
Socket socket = (Socket)ar.AsyncState;
try
{
socket.EndConnect(ar);
m_bAvailable = true;
}
catch (Exception)
{
}
socket.Close();
}
}
}

View File

@ -420,11 +420,13 @@ namespace OpenSim.Region.Environment.Scenes
agent.InventoryFolder = LLUUID.Zero;
agent.startpos = position;
agent.child = true;
avatar.Close();
if (m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent) &&
m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId,
position, false)) ;
if(m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent))
{
avatar.Close();
m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId,
position, false);
AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo();
string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId);
avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4),
@ -443,6 +445,10 @@ namespace OpenSim.Region.Environment.Scenes
CloseChildAgentConnections(avatar);
}
}
else
{
avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
}
}
}
}

View File

@ -285,7 +285,7 @@ namespace SimpleApp
{
}
public virtual void SendTeleportFailed()
public virtual void SendTeleportFailed(string reason)
{
}