Mantis#2725. Thank you kindly, Diva, for a patch that:

Adds missing protocol pieces for EstablishAgentCommunication
event which allows the client to activate CAPS and the EQ for 
child agents.
0.6.1-post-fixes
Charles Krinke 2008-12-14 02:17:12 +00:00
parent 6cf0b81864
commit e6eb571c1d
12 changed files with 501 additions and 178 deletions

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Framework namespace OpenSim.Framework
@ -35,6 +36,7 @@ namespace OpenSim.Framework
public UUID AgentID; public UUID AgentID;
public UUID BaseFolder; public UUID BaseFolder;
public string CapsPath = String.Empty; public string CapsPath = String.Empty;
public Dictionary<ulong, string> ChildrenCapSeeds;
public bool child; public bool child;
public uint circuitcode; public uint circuitcode;
public string firstname; public string firstname;
@ -61,6 +63,7 @@ namespace OpenSim.Framework
InventoryFolder = new UUID(cAgent.InventoryFolder); InventoryFolder = new UUID(cAgent.InventoryFolder);
BaseFolder = new UUID(cAgent.BaseFolder); BaseFolder = new UUID(cAgent.BaseFolder);
CapsPath = cAgent.CapsPath; CapsPath = cAgent.CapsPath;
ChildrenCapSeeds = cAgent.ChildrenCapSeeds;
} }
} }
@ -70,6 +73,7 @@ namespace OpenSim.Framework
public Guid AgentID; public Guid AgentID;
public Guid BaseFolder; public Guid BaseFolder;
public string CapsPath = String.Empty; public string CapsPath = String.Empty;
public Dictionary<ulong, string> ChildrenCapSeeds;
public bool child; public bool child;
public uint circuitcode; public uint circuitcode;
public string firstname; public string firstname;
@ -100,6 +104,7 @@ namespace OpenSim.Framework
InventoryFolder = cAgent.InventoryFolder.Guid; InventoryFolder = cAgent.InventoryFolder.Guid;
BaseFolder = cAgent.BaseFolder.Guid; BaseFolder = cAgent.BaseFolder.Guid;
CapsPath = cAgent.CapsPath; CapsPath = cAgent.CapsPath;
ChildrenCapSeeds = cAgent.ChildrenCapSeeds;
} }
} }
} }

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Framework namespace OpenSim.Framework
@ -73,7 +74,9 @@ namespace OpenSim.Framework
bool PresenceChildStatus(UUID avatarID); bool PresenceChildStatus(UUID avatarID);
// Diva: get this out of here!!!
string GetCapsPath(UUID agentId); string GetCapsPath(UUID agentId);
Dictionary<ulong, string> GetChildrenSeeds(UUID agentId);
T RequestModuleInterface<T>(); T RequestModuleInterface<T>();
T[] RequestModuleInterfaces<T>(); T[] RequestModuleInterfaces<T>();

View File

@ -350,7 +350,7 @@ namespace OpenSim.Framework
public static bool IsOutsideView(uint oldx, uint newx, uint oldy, uint newy) public static bool IsOutsideView(uint oldx, uint newx, uint oldy, uint newy)
{ {
// Eventually this will be a function of the draw distance / camera position too. // Eventually this will be a function of the draw distance / camera position too.
return ((Math.Abs((int)(oldx - newx)) > 1) || (Math.Abs((int)(oldy - newy)) > 1)); return (((int)Math.Abs((int)(oldx - newx)) > 1) || ((int)Math.Abs((int)(oldy - newy)) > 1));
} }
public static string FieldToString(byte[] bytes) public static string FieldToString(byte[] bytes)

View File

@ -1327,6 +1327,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
agentData.firstname = m_firstName; agentData.firstname = m_firstName;
agentData.lastname = m_lastName; agentData.lastname = m_lastName;
agentData.CapsPath = m_scene.GetCapsPath(m_agentId); agentData.CapsPath = m_scene.GetCapsPath(m_agentId);
agentData.ChildrenCapSeeds = new Dictionary<ulong,string>(m_scene.GetChildrenSeeds(m_agentId));
return agentData; return agentData;
} }

View File

@ -202,6 +202,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
{ {
m_AvatarQueueUUIDMapping.Remove(ky); m_AvatarQueueUUIDMapping.Remove(ky);
m_scene.RemoveHTTPHandler("","/CAPS/EQG/" + ky.ToString() + "/"); m_scene.RemoveHTTPHandler("","/CAPS/EQG/" + ky.ToString() + "/");
m_log.Debug("[EVENTQUEUE]: Removing " + "/CAPS/EQG/" + ky.ToString() + "/");
} }
} }
@ -225,6 +226,7 @@ namespace OpenSim.Region.Environment.Modules.Framework
m_QueueUUIDAvatarMapping.Remove(ky); m_QueueUUIDAvatarMapping.Remove(ky);
} }
m_log.DebugFormat("[EVENTQUEUE]: Client {0} deregistered in region {1}.", AgentID, m_scene.RegionInfo.RegionName); m_log.DebugFormat("[EVENTQUEUE]: Client {0} deregistered in region {1}.", AgentID, m_scene.RegionInfo.RegionName);
} }
@ -326,13 +328,14 @@ namespace OpenSim.Region.Environment.Modules.Framework
if (element == null) if (element == null)
{ {
// m_log.ErrorFormat("[EVENTQUEUE]: Failed to process queue"); //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName);
if (thisID == -1) // close-request if (thisID == -1) // close-request
{ {
responsedata["int_response_code"] = 404; m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName);
responsedata["int_response_code"] = 404; //501; //410; //404;
responsedata["content_type"] = "text/plain"; responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false; responsedata["keepalive"] = false;
responsedata["str_response_string"] = ""; responsedata["str_response_string"] = "Closed EQG";
return responsedata; return responsedata;
} }
responsedata["int_response_code"] = 502; responsedata["int_response_code"] = 502;

View File

@ -80,15 +80,15 @@ namespace OpenSim.Region.Environment
public static OSD DisableSimulator(ulong Handle) public static OSD DisableSimulator(ulong Handle)
{ {
OSDMap llsdSimInfo = new OSDMap(1); //OSDMap llsdSimInfo = new OSDMap(1);
llsdSimInfo.Add("Handle", new OSDBinary(regionHandleToByteArray(Handle))); //llsdSimInfo.Add("Handle", new OSDBinary(regionHandleToByteArray(Handle)));
OSDArray arr = new OSDArray(1); //OSDArray arr = new OSDArray(1);
arr.Add(llsdSimInfo); //arr.Add(llsdSimInfo);
OSDMap llsdBody = new OSDMap(1); OSDMap llsdBody = new OSDMap(0);
llsdBody.Add("SimulatorInfo", arr); //llsdBody.Add("SimulatorInfo", arr);
return buildEvent("DisableSimulator", llsdBody); return buildEvent("DisableSimulator", llsdBody);
} }
@ -178,6 +178,16 @@ namespace OpenSim.Region.Environment
return buildEvent("ScriptRunningReply", body); return buildEvent("ScriptRunningReply", body);
} }
public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap)
{
OSDMap body = new OSDMap(3);
body.Add("agent-id", new OSDUUID(agentID));
body.Add("sim-ip-and-port", new OSDString(simIpAndPort));
body.Add("seed-capability", new OSDString(seedcap));
return buildEvent("EstablishAgentCommunication", body);
}
public static OSD KeepAliveEvent() public static OSD KeepAliveEvent()
{ {
return buildEvent("FAKEEVENT", new OSDMap()); return buildEvent("FAKEEVENT", new OSDMap());

View File

@ -108,6 +108,12 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle);
if (reg != null) if (reg != null)
{ {
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
/// ///
/// Hypergrid mod start /// Hypergrid mod start
/// ///
@ -130,11 +136,6 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
if (eq == null) if (eq == null)
avatar.ControllingClient.SendTeleportLocationStart(); avatar.ControllingClient.SendTeleportLocationStart();
AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
agent.startpos = position;
agent.child = true;
if (reg.RemotingAddress != "" && reg.RemotingPort != 0) if (reg.RemotingAddress != "" && reg.RemotingPort != 0)
{ {
@ -166,14 +167,42 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
// Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
// failure at this point (unlike a border crossing failure). So perhaps this can never fail // failure at this point (unlike a border crossing failure). So perhaps this can never fail
// once we reach here... // once we reach here...
avatar.Scene.RemoveCapsHandler(avatar.UUID); //avatar.Scene.RemoveCapsHandler(avatar.UUID);
agent.child = false;
m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agent); AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
agent.startpos = position;
agent.child = true;
if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
{
// brand new agent
agent.CapsPath = Util.GetRandomCapsPath();
}
else
{
// child agent already there
agent.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, reg.RegionHandle);
}
if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agent))
{
avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports.");
return;
}
// TODO Should construct this behind a method
string capsPath =
"http://" + reg.ExternalHostName + ":" + reg.HttpPort
+ "/CAPS/" + agent.CapsPath + "0000/";
if (eq != null) if (eq != null)
{ {
OSD Item = EventQueueHelper.EnableSimulator(realHandle, reg.ExternalEndPoint); OSD Item = EventQueueHelper.EnableSimulator(realHandle, reg.ExternalEndPoint);
eq.Enqueue(Item, avatar.UUID); eq.Enqueue(Item, avatar.UUID);
Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, reg.ExternalEndPoint.ToString(), capsPath);
eq.Enqueue(Item, avatar.UUID);
} }
else else
{ {
@ -181,18 +210,21 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
// TODO: make Event Queue disablable! // TODO: make Event Queue disablable!
} }
m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, if (!m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
position, false); position, false))
Thread.Sleep(2000); {
AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
// We should close that agent we just created over at destination...
List<ulong> lst = new List<ulong>();
lst.Add(reg.RegionHandle);
SendCloseChildAgentAsync(avatar.UUID, lst);
return;
}
// TODO Should construct this behind a method Thread.Sleep(2000);
string capsPath =
"http://" + reg.ExternalHostName + ":" + reg.HttpPort
+ "/CAPS/" + circuitdata.CapsPath + "0000/";
m_log.DebugFormat( m_log.DebugFormat(
"[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); "[CAPS]: Sending new CAPS seed url {0} to client {1}", agent.CapsPath, avatar.UUID);
/// ///
@ -215,7 +247,7 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
/// ///
avatar.MakeChildAgent(); avatar.MakeChildAgent();
Thread.Sleep(7000); Thread.Sleep(5000);
avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true); avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
if (KiPrimitive != null) if (KiPrimitive != null)
{ {
@ -223,29 +255,22 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid
} }
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
// Let's close some children agents // Let's close some children agents
if (isHyperLink) // close them all if (isHyperLink) // close them all
SendCloseChildAgentConnections(avatar.UUID, avatar.GetKnownRegionList()); SendCloseChildAgentConnections(avatar.UUID, avatar.KnownChildRegionHandles);
else // close just a few else // close just a few
avatar.CloseChildAgents(newRegionX, newRegionY); avatar.CloseChildAgents(newRegionX, newRegionY);
avatar.Close(); //avatar.Close();
// Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
/// ///
/// Hypergrid mod: extra check for isHyperLink /// Hypergrid mod: extra check for isHyperLink
/// ///
//if ((Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 1) || isHyperLink) //if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
//if (((int)Math.Abs((int)(newRegionX - oldRegionX)) > 1) || ((int)Math.Abs((int)(newRegionY - oldRegionY)) > 1) || isHyperLink) //{
if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) // CloseConnection(avatar.UUID);
{ //}
CloseConnection(avatar.UUID);
}
// if (teleport success) // seems to be always success here // if (teleport success) // seems to be always success here
// the user may change their profile information in other region, // the user may change their profile information in other region,
// so the userinfo in UserProfileCache is not reliable any more, delete it // so the userinfo in UserProfileCache is not reliable any more, delete it

View File

@ -649,8 +649,8 @@ namespace OpenSim.Region.Environment.Scenes
// Kick all ROOT agents with the message, 'The simulator is going down' // Kick all ROOT agents with the message, 'The simulator is going down'
ForEachScenePresence(delegate(ScenePresence avatar) ForEachScenePresence(delegate(ScenePresence avatar)
{ {
if (avatar.KnownChildRegions.Contains(RegionInfo.RegionHandle)) if (avatar.KnownChildRegionHandles.Contains(RegionInfo.RegionHandle))
avatar.KnownChildRegions.Remove(RegionInfo.RegionHandle); avatar.KnownChildRegionHandles.Remove(RegionInfo.RegionHandle);
if (!avatar.IsChildAgent) if (!avatar.IsChildAgent)
avatar.ControllingClient.Kick("The simulator is going down."); avatar.ControllingClient.Kick("The simulator is going down.");
@ -2657,7 +2657,7 @@ namespace OpenSim.Region.Environment.Scenes
GetAvatarAppearance(client, out appearance); GetAvatarAppearance(client, out appearance);
ScenePresence avatar = m_sceneGraph.CreateAndAddChildScenePresence(client, appearance); ScenePresence avatar = m_sceneGraph.CreateAndAddChildScenePresence(client, appearance);
avatar.KnownRegions = GetChildrenSeeds(avatar.UUID);
return avatar; return avatar;
} }
@ -2706,27 +2706,23 @@ namespace OpenSim.Region.Environment.Scenes
"[SCENE]: Removing {0} agent {1} from region {2}", "[SCENE]: Removing {0} agent {1} from region {2}",
(childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName);
if (avatar.IsChildAgent) m_sceneGraph.removeUserCount(!childagentYN);
{
m_sceneGraph.removeUserCount(false);
}
else
{
m_sceneGraph.removeUserCount(true);
m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat);
List<ulong> childknownRegions = new List<ulong>();
List<ulong> ckn = avatar.GetKnownRegionList();
for (int i = 0; i < ckn.Count; i++)
{
childknownRegions.Add(ckn[i]);
}
m_sceneGridService.SendCloseChildAgentConnections(agentID, childknownRegions);
RemoveCapsHandler(agentID); RemoveCapsHandler(agentID);
CommsManager.UserProfileCacheService.RemoveUser(agentID); CommsManager.UserProfileCacheService.RemoveUser(agentID);
}
if (!avatar.IsChildAgent)
{
m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat);
//List<ulong> childknownRegions = new List<ulong>();
//List<ulong> ckn = avatar.KnownChildRegionHandles;
//for (int i = 0; i < ckn.Count; i++)
//{
// childknownRegions.Add(ckn[i]);
//}
m_sceneGridService.SendCloseChildAgentConnections(agentID, avatar.KnownChildRegionHandles);
}
m_eventManager.TriggerClientClosed(agentID); m_eventManager.TriggerClientClosed(agentID);
} }
catch (NullReferenceException) catch (NullReferenceException)
@ -2792,7 +2788,7 @@ namespace OpenSim.Region.Environment.Scenes
for (int i = 0; i < regionslst.Count; i++) for (int i = 0; i < regionslst.Count; i++)
{ {
av.KnownChildRegions.Remove(regionslst[i]); av.KnownChildRegionHandles.Remove(regionslst[i]);
} }
} }
} }
@ -2875,8 +2871,8 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="agent"></param> /// <param name="agent"></param>
public void NewUserConnection(AgentCircuitData agent) public void NewUserConnection(AgentCircuitData agent)
{ {
m_log.DebugFormat("[CONNECTION DEBUGGING] Adding NewUserConnection for {0} with CC of {1}", agent.AgentID, m_log.DebugFormat("[CONNECTION DEBUGGING] Adding NewUserConnection for {0} in {1} with CC of {2}", agent.AgentID,
agent.circuitcode); RegionInfo.RegionName, agent.circuitcode);
if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) if (m_regInfo.EstateSettings.IsBanned(agent.AgentID))
{ {
@ -2885,13 +2881,16 @@ namespace OpenSim.Region.Environment.Scenes
agent.AgentID, RegionInfo.RegionName); agent.AgentID, RegionInfo.RegionName);
} }
/// Diva: Horrible stuff!
capsPaths[agent.AgentID] = agent.CapsPath; capsPaths[agent.AgentID] = agent.CapsPath;
//m_log.DebugFormat("------------>child seeds in {0}: {1}", RegionInfo.RegionName, ((agent.ChildrenCapSeeds == null) ? "null" : agent.ChildrenCapSeeds.Count.ToString()));
childrenSeeds[agent.AgentID] = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
AddCapsHandler(agent.AgentID);
if (!agent.child) if (!agent.child)
{ {
AddCapsHandler(agent.AgentID);
// Honor parcel landing type and position. // Honor parcel landing type and position.
ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
if (land != null) if (land != null)
@ -2966,14 +2965,22 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (RegionInfo.EstateSettings.IsBanned(agentId)) if (RegionInfo.EstateSettings.IsBanned(agentId))
return; return;
String capsObjectPath = GetCapsPath(agentId); String capsObjectPath = GetCapsPath(agentId);
m_log.DebugFormat( m_log.DebugFormat(
"[CAPS]: Setting up CAPS handler for root agent {0} in {1}", "[CAPS]: Setting up CAPS handler for agent {0} in {1}",
agentId, RegionInfo.RegionName); agentId, RegionInfo.RegionName);
Caps cap = Caps cap = null;
new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port, if (m_capsHandlers.TryGetValue(agentId, out cap))
{
m_log.DebugFormat("[CAPS] Attempt at registering twice for the same agent {0}. {1}. Ignoring.", agentId, capsObjectPath);
return;
}
cap = new Caps(AssetCache, m_httpListener, m_regInfo.ExternalHostName, m_httpListener.Port,
capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName); capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName);
cap.RegisterHandlers(); cap.RegisterHandlers();
@ -3005,6 +3012,12 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="agentId"></param> /// <param name="agentId"></param>
public void RemoveCapsHandler(UUID agentId) public void RemoveCapsHandler(UUID agentId)
{ {
if (childrenSeeds.ContainsKey(agentId))
{
//Console.WriteLine(" !!! Removing seeds for {0} in {1}", agentId, RegionInfo.RegionName);
childrenSeeds.Remove(agentId);
}
lock (m_capsHandlers) lock (m_capsHandlers)
{ {
if (m_capsHandlers.ContainsKey(agentId)) if (m_capsHandlers.ContainsKey(agentId))
@ -3094,7 +3107,6 @@ namespace OpenSim.Region.Environment.Scenes
public bool CloseConnection(UUID agentID) public bool CloseConnection(UUID agentID)
{ {
ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
if (presence != null) if (presence != null)
{ {
// Nothing is removed here, so down count it as such // Nothing is removed here, so down count it as such
@ -3108,11 +3120,18 @@ namespace OpenSim.Region.Environment.Scenes
// } // }
// Tell a single agent to disconnect from the region. // Tell a single agent to disconnect from the region.
IEventQueue eq = RequestModuleInterface<IEventQueue>();
if (eq != null)
{
OSD Item = EventQueueHelper.DisableSimulator(RegionInfo.RegionHandle);
eq.Enqueue(Item, agentID);
}
else
presence.ControllingClient.SendShutdownConnectionNotice(); presence.ControllingClient.SendShutdownConnectionNotice();
presence.ControllingClient.Close(true); presence.ControllingClient.Close(true);
}
}
return true; return true;
} }

View File

@ -216,8 +216,10 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary> /// <summary>
/// XXX These two methods are very temporary /// XXX These two methods are very temporary
/// XXX Diva: this is really truly horrible; must...move...to...LL client...stack...
/// </summary> /// </summary>
protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>(); protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>();
protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds = new Dictionary<UUID, Dictionary<ulong, string>>();
public string GetCapsPath(UUID agentId) public string GetCapsPath(UUID agentId)
{ {
if (capsPaths.ContainsKey(agentId)) if (capsPaths.ContainsKey(agentId))
@ -227,6 +229,51 @@ namespace OpenSim.Region.Environment.Scenes
return null; return null;
} }
public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
{
Dictionary<ulong, string> seeds = null;
if (childrenSeeds.TryGetValue(agentID, out seeds))
return seeds;
return new Dictionary<ulong, string>();
}
public void DropChildSeed(UUID agentID, ulong handle)
{
Dictionary<ulong, string> seeds;
if (childrenSeeds.TryGetValue(agentID, out seeds))
{
seeds.Remove(handle);
}
}
public string GetChildSeed(UUID agentID, ulong handle)
{
Dictionary<ulong, string> seeds;
if (childrenSeeds.TryGetValue(agentID, out seeds))
{
return seeds[handle];
}
return null;
}
public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> value)
{
//Console.WriteLine(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count);
childrenSeeds[agentID] = value;
}
public void DumpChildrenSeeds(UUID agentID)
{
Console.WriteLine("================ ChildrenSeed {0} ================", RegionInfo.RegionName);
foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID])
{
uint x, y;
Utils.LongToUInts(kvp.Key, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
Console.WriteLine(" >> {0}, {1}: {2}", x, y, kvp.Value);
}
}
/// <summary> /// <summary>
/// Returns a new unallocated local ID /// Returns a new unallocated local ID

View File

@ -255,7 +255,7 @@ namespace OpenSim.Region.Environment.Scenes
#region Inform Client of Neighbours #region Inform Client of Neighbours
private delegate void InformClientOfNeighbourDelegate( private delegate void InformClientOfNeighbourDelegate(
ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint);
private void InformClientOfNeighbourCompleted(IAsyncResult iar) private void InformClientOfNeighbourCompleted(IAsyncResult iar)
{ {
@ -273,28 +273,40 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="a"></param> /// <param name="a"></param>
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <param name="endPoint"></param> /// <param name="endPoint"></param>
private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, ulong regionHandle, private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg,
IPEndPoint endPoint) IPEndPoint endPoint)
{ {
m_log.Info("[INTERGRID]: Starting to inform client about neighbours"); uint x, y;
bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, a); Utils.LongToUInts(reg.RegionHandle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
m_log.Info("[INTERGRID]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
+ "/CAPS/" + a.CapsPath + "0000/";
bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
if (regionAccepted) if (regionAccepted)
{ {
IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>(); IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
if (eq != null) if (eq != null)
{ {
OSD Item = EventQueueHelper.EnableSimulator(regionHandle, endPoint); OSD Item = EventQueueHelper.EnableSimulator(reg.RegionHandle, endPoint);
eq.Enqueue(Item, avatar.UUID); eq.Enqueue(Item, avatar.UUID);
Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, endPoint.ToString(), capsPath);
eq.Enqueue(Item, avatar.UUID);
m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}", capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName);
} }
else else
{ {
avatar.ControllingClient.InformClientOfNeighbour(regionHandle, endPoint); avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
// TODO: make Event Queue disablable! // TODO: make Event Queue disablable!
} }
avatar.AddNeighbourRegion(regionHandle); m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString());
m_log.Info("[INTERGRID]: Completed inform client about neighbours");
} }
} }
@ -330,9 +342,32 @@ namespace OpenSim.Region.Environment.Scenes
neighbours = neighbours =
m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
if (neighbours != null) m_log.Debug("[SCM]: EnableChildAgents from " + avatar.Scene.RegionInfo.RegionName);
{
for (int i = 0; i < neighbours.Count; i++) /// We need to find the difference between the new regions where there are no child agents
/// and the regions where there are already child agents. We only send notification to the former.
List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
List<ulong> previousRegionNeighbourHandles = new List<ulong>(avatar.Scene.GetChildrenSeeds(avatar.UUID).Keys);
List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
//Dump("Current Neighbors", neighbourHandles);
//Dump("Previous Neighbours", previousRegionNeighbourHandles);
//Dump("New Neighbours", newRegions);
//Dump("Old Neighbours", oldRegions);
/// Update the scene presence's known regions here on this region
avatar.DropOldNeighbours(oldRegions);
/// Collect as many seeds as possible
Dictionary<ulong, string> seeds = new Dictionary<ulong, string>(avatar.Scene.GetChildrenSeeds(avatar.UUID));
if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
/// Create the necessary child agents
List<AgentCircuitData> cagents = new List<AgentCircuitData>();
foreach (SimpleRegionInfo neighbour in neighbours)
{ {
AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero; agent.BaseFolder = UUID.Zero;
@ -340,11 +375,39 @@ namespace OpenSim.Region.Environment.Scenes
agent.startpos = new Vector3(128, 128, 70); agent.startpos = new Vector3(128, 128, 70);
agent.child = true; agent.child = true;
InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; if (newRegions.Contains(neighbour.RegionHandle))
{
agent.CapsPath = Util.GetRandomCapsPath();
avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
seeds.Add(neighbour.RegionHandle, agent.CapsPath);
}
else
agent.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
cagents.Add(agent);
}
/// Update all child agent with everyone's seeds
foreach (AgentCircuitData a in cagents)
{
a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
}
// These two are the same thing!
avatar.Scene.SetChildrenSeed(avatar.UUID, seeds);
avatar.KnownRegions = seeds;
//avatar.Scene.DumpChildrenSeeds(avatar.UUID);
//avatar.DumpKnownRegions();
int count = 0;
foreach (SimpleRegionInfo neighbour in neighbours)
{
// Don't do it if there's already an agent in that region
if (newRegions.Contains(neighbour.RegionHandle))
{
InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
try try
{ {
d.BeginInvoke(avatar, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint, d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint,
InformClientOfNeighbourCompleted, InformClientOfNeighbourCompleted,
d); d);
} }
@ -352,10 +415,10 @@ namespace OpenSim.Region.Environment.Scenes
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
neighbours[i].ExternalHostName, neighbour.ExternalHostName,
neighbours[i].RegionHandle, neighbour.RegionHandle,
neighbours[i].RegionLocX, neighbour.RegionLocX,
neighbours[i].RegionLocY, neighbour.RegionLocY,
e); e);
// FIXME: Okay, even though we've failed, we're still going to throw the exception on, // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
@ -366,6 +429,11 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
else
m_log.Debug("[SCM]: Skipping common neighbor " + neighbour.RegionLocX + ", " + neighbour.RegionLocY);
count++;
} }
} }
@ -373,7 +441,7 @@ namespace OpenSim.Region.Environment.Scenes
/// This informs a single neighboring region about agent "avatar". /// This informs a single neighboring region about agent "avatar".
/// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary> /// </summary>
public void InformNeighborChildAgent(ScenePresence avatar, RegionInfo region, List<RegionInfo> neighbours) public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region, List<RegionInfo> neighbours)
{ {
AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero; agent.BaseFolder = UUID.Zero;
@ -382,7 +450,7 @@ namespace OpenSim.Region.Environment.Scenes
agent.child = true; agent.child = true;
InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
d.BeginInvoke(avatar, agent, region.RegionHandle, region.ExternalEndPoint, d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint,
InformClientOfNeighbourCompleted, InformClientOfNeighbourCompleted,
d); d);
} }
@ -463,10 +531,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
private void SendChildAgentDataUpdateAsync(ChildAgentDataUpdate cAgentData, ScenePresence presence) private void SendChildAgentDataUpdateAsync(ChildAgentDataUpdate cAgentData, ScenePresence presence)
{ {
//m_log.Info("[INTERGRID]: Informing neighbors about my agent."); m_log.Info("[INTERGRID]: Informing neighbors about my agent in " + presence.Scene.RegionInfo.RegionName);
try try
{ {
foreach (ulong regionHandle in presence.KnownChildRegions) foreach (ulong regionHandle in presence.KnownChildRegionHandles)
{ {
bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); bool regionAccepted = m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
@ -508,11 +576,12 @@ namespace OpenSim.Region.Environment.Scenes
/// This Closes child agents on neighboring regions /// This Closes child agents on neighboring regions
/// Calls an asynchronous method to do so.. so it doesn't lag the sim. /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary> /// </summary>
private void SendCloseChildAgentAsync(UUID agentID, List<ulong> regionlst) protected void SendCloseChildAgentAsync(UUID agentID, List<ulong> regionlst)
{ {
foreach (ulong regionHandle in regionlst) foreach (ulong regionHandle in regionlst)
{ {
m_log.Debug("[INTERGRID]: Sending close agent to " + regionHandle);
bool regionAccepted = m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); bool regionAccepted = m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
if (regionAccepted) if (regionAccepted)
@ -527,14 +596,14 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
// We remove the list of known regions from the agent's known region list through an event //// We remove the list of known regions from the agent's known region list through an event
// to scene, because, if an agent logged of, it's likely that there will be no scene presence //// to scene, because, if an agent logged of, it's likely that there will be no scene presence
// by the time we get to this part of the method. //// by the time we get to this part of the method.
handlerRemoveKnownRegionFromAvatar = OnRemoveKnownRegionFromAvatar; //handlerRemoveKnownRegionFromAvatar = OnRemoveKnownRegionFromAvatar;
if (handlerRemoveKnownRegionFromAvatar != null) //if (handlerRemoveKnownRegionFromAvatar != null)
{ //{
handlerRemoveKnownRegionFromAvatar(agentID, regionlst); // handlerRemoveKnownRegionFromAvatar(agentID, regionlst);
} //}
} }
private void SendCloseChildAgentCompleted(IAsyncResult iar) private void SendCloseChildAgentCompleted(IAsyncResult iar)
@ -643,12 +712,6 @@ namespace OpenSim.Region.Environment.Scenes
if (eq == null) if (eq == null)
avatar.ControllingClient.SendTeleportLocationStart(); avatar.ControllingClient.SendTeleportLocationStart();
AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
agent.startpos = position;
agent.child = true;
if (reg.RemotingAddress != "" && reg.RemotingPort != 0) if (reg.RemotingAddress != "" && reg.RemotingPort != 0)
{ {
// region is remote. see if it is up // region is remote. see if it is up
@ -662,6 +725,10 @@ namespace OpenSim.Region.Environment.Scenes
if (destRegionUp) if (destRegionUp)
{ {
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions // both regions
@ -675,33 +742,64 @@ namespace OpenSim.Region.Environment.Scenes
// the avatar.Close below will clear the child region list. We need this below for (possibly) // the avatar.Close below will clear the child region list. We need this below for (possibly)
// closing the child agents, so save it here (we need a copy as it is Clear()-ed). // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList()); //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
// Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
// failure at this point (unlike a border crossing failure). So perhaps this can never fail // failure at this point (unlike a border crossing failure). So perhaps this can never fail
// once we reach here... // once we reach here...
avatar.Scene.RemoveCapsHandler(avatar.UUID); //avatar.Scene.RemoveCapsHandler(avatar.UUID);
agent.child = false;
m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agent); AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero;
agent.InventoryFolder = UUID.Zero;
agent.startpos = position;
agent.child = true;
if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
{
// brand new agent
agent.CapsPath = Util.GetRandomCapsPath();
}
else
{
// child agent already there
agent.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, reg.RegionHandle);
}
if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agent))
{
avatar.ControllingClient.SendTeleportFailed("Destination is not accepting teleports.");
return;
}
// TODO Should construct this behind a method
string capsPath =
"http://" + reg.ExternalHostName + ":" + reg.HttpPort
+ "/CAPS/" + agent.CapsPath + "0000/";
if (eq != null) if (eq != null)
{ {
OSD Item = EventQueueHelper.EnableSimulator(reg.RegionHandle, reg.ExternalEndPoint); OSD Item = EventQueueHelper.EnableSimulator(reg.RegionHandle, reg.ExternalEndPoint);
eq.Enqueue(Item, avatar.UUID); eq.Enqueue(Item, avatar.UUID);
Item = EventQueueHelper.EstablishAgentCommunication(avatar.UUID, reg.ExternalEndPoint.ToString(), capsPath);
eq.Enqueue(Item, avatar.UUID);
} }
else else
{ {
avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, reg.ExternalEndPoint); avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, reg.ExternalEndPoint);
} }
m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, if (!m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
position, false); position, false))
Thread.Sleep(2000); {
AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
// We should close that agent we just created over at destination...
List<ulong> lst = new List<ulong>();
lst.Add(reg.RegionHandle);
SendCloseChildAgentAsync(avatar.UUID, lst);
return;
}
// TODO Should construct this behind a method Thread.Sleep(2000);
string capsPath =
"http://" + reg.ExternalHostName + ":" + reg.HttpPort
+ "/CAPS/" + circuitdata.CapsPath + "0000/";
m_log.DebugFormat( m_log.DebugFormat(
"[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
@ -720,26 +818,25 @@ namespace OpenSim.Region.Environment.Scenes
} }
avatar.MakeChildAgent(); avatar.MakeChildAgent();
Thread.Sleep(7000); Thread.Sleep(5000);
avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true); avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
if (KiPrimitive != null) if (KiPrimitive != null)
{ {
KiPrimitive(avatar.LocalId); KiPrimitive(avatar.LocalId);
} }
avatar.Close();
uint newRegionX = (uint)(reg.RegionHandle >> 40); // Let's close some children agents
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); avatar.CloseChildAgents(newRegionX, newRegionY);
uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); // Close this ScenePresence too
uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); //avatar.Close();
if (Util.fast_distance2d((int)(newRegionX - oldRegionX), (int)(newRegionY - oldRegionY)) > 3) // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
{
//SendCloseChildAgentConnections(avatar.UUID,avatar.GetKnownRegionList()); //if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
SendCloseChildAgentConnections(avatar.UUID, childRegions); //{
CloseConnection(avatar.UUID); // CloseConnection(avatar.UUID);
} //}
// if (teleport success) // seems to be always success here // if (teleport success) // seems to be always success here
// the user may change their profile information in other region, // the user may change their profile information in other region,
@ -775,6 +872,30 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
private List<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours)
{
List<ulong> handles = new List<ulong>();
foreach (SimpleRegionInfo reg in neighbours)
{
handles.Add(reg.RegionHandle);
}
return handles;
}
private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
{
return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
}
private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
{
return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
}
private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
{
return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
}
/// <summary> /// <summary>
/// Inform a neighbouring region that an avatar is about to cross into it. /// Inform a neighbouring region that an avatar is about to cross into it.
/// </summary> /// </summary>
@ -846,5 +967,18 @@ namespace OpenSim.Region.Environment.Scenes
{ {
return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber);
} }
private void Dump(string msg, List<ulong> handles)
{
Console.WriteLine("-------------- HANDLE DUMP ({0}) ---------", msg);
foreach (ulong handle in handles)
{
uint x, y;
Utils.LongToUInts(handle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
Console.WriteLine("({0}, {1})", x, y);
}
}
} }
} }

View File

@ -910,18 +910,21 @@ namespace OpenSim.Region.Environment.Scenes
{ {
ScenePresence presence; ScenePresence presence;
if (ScenePresences.TryGetValue(avatarId, out presence)) if (ScenePresences.TryGetValue(avatarId, out presence))
{
if (!presence.IsChildAgent)
{ {
avatar = presence; avatar = presence;
return true; return true;
}
else //if (!presence.IsChildAgent)
{ //{
m_log.WarnFormat( // avatar = presence;
"[INNER SCENE]: Requested avatar {0} could not be found in scene {1} since it is only registered as a child agent!", // return true;
avatarId, m_parentScene.RegionInfo.RegionName); //}
} //else
//{
// m_log.WarnFormat(
// "[INNER SCENE]: Requested avatar {0} could not be found in scene {1} since it is only registered as a child agent!",
// avatarId, m_parentScene.RegionInfo.RegionName);
//}
} }
avatar = null; avatar = null;

View File

@ -188,8 +188,9 @@ namespace OpenSim.Region.Environment.Scenes
protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); protected List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>();
//neighbouring regions we have enabled a child agent in // neighbouring regions we have enabled a child agent in
private readonly List<ulong> m_knownChildRegions = new List<ulong>(); // holds the seed cap for the child agent in that region
private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
/// <summary> /// <summary>
/// Implemented Control Flags /// Implemented Control Flags
@ -483,9 +484,38 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary> /// <summary>
/// These are the region handles known by the avatar. /// These are the region handles known by the avatar.
/// </summary> /// </summary>
public List<ulong> KnownChildRegions public List<ulong> KnownChildRegionHandles
{
get
{
if (m_knownChildRegions.Count == 0)
return new List<ulong>();
else
return new List<ulong>(m_knownChildRegions.Keys);
}
}
public Dictionary<ulong, string> KnownRegions
{ {
get { return m_knownChildRegions; } get { return m_knownChildRegions; }
set
{
//Console.WriteLine(" !! Setting known regions in {0} to {1}", Scene.RegionInfo.RegionName, value.Count);
m_knownChildRegions = value;
}
}
public void DumpKnownRegions()
{
Console.WriteLine("================ KnownRegions {0} ================", Scene.RegionInfo.RegionName);
foreach (KeyValuePair<ulong, string> kvp in KnownRegions)
{
uint x, y;
Utils.LongToUInts(kvp.Key, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
Console.WriteLine(" >> {0}, {1}: {2}", x, y, kvp.Value);
}
} }
public AnimationSet Animations public AnimationSet Animations
@ -529,6 +559,8 @@ namespace OpenSim.Region.Environment.Scenes
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid); CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(m_uuid);
if (userInfo != null) if (userInfo != null)
userInfo.OnItemReceived += ItemReceived; userInfo.OnItemReceived += ItemReceived;
m_log.Info("[AVATAR]: New ScenePresence in " + Scene.RegionInfo.RegionName);
} }
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams, public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
@ -743,6 +775,8 @@ namespace OpenSim.Region.Environment.Scenes
"[SCENE]: Upgrading child to root agent for {0} in {1}", "[SCENE]: Upgrading child to root agent for {0} in {1}",
Name, m_scene.RegionInfo.RegionName); Name, m_scene.RegionInfo.RegionName);
m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count);
IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>();
if (gm != null) if (gm != null)
m_grouptitle = gm.GetGroupTitle(m_uuid); m_grouptitle = gm.GetGroupTitle(m_uuid);
@ -881,25 +915,43 @@ namespace OpenSim.Region.Environment.Scenes
SendFullUpdateToAllClients(); SendFullUpdateToAllClients();
} }
public void AddNeighbourRegion(ulong regionHandle) public void AddNeighbourRegion(ulong regionHandle, string cap)
{ {
if (!m_knownChildRegions.Contains(regionHandle)) lock (m_knownChildRegions)
{ {
m_knownChildRegions.Add(regionHandle); if (!m_knownChildRegions.ContainsKey(regionHandle))
{
uint x, y;
Utils.LongToUInts(regionHandle, out x, out y);
m_knownChildRegions.Add(regionHandle, cap);
}
} }
} }
public void RemoveNeighbourRegion(ulong regionHandle) public void RemoveNeighbourRegion(ulong regionHandle)
{ {
if (m_knownChildRegions.Contains(regionHandle)) lock (m_knownChildRegions)
{
if (m_knownChildRegions.ContainsKey(regionHandle))
{ {
m_knownChildRegions.Remove(regionHandle); m_knownChildRegions.Remove(regionHandle);
//Console.WriteLine(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count);
}
}
}
public void DropOldNeighbours(List<ulong> oldRegions)
{
foreach (ulong handle in oldRegions)
{
RemoveNeighbourRegion(handle);
Scene.DropChildSeed(UUID, handle);
} }
} }
public List<ulong> GetKnownRegionList() public List<ulong> GetKnownRegionList()
{ {
return m_knownChildRegions; return new List<ulong>(m_knownChildRegions.Keys);
} }
#endregion #endregion
@ -1856,6 +1908,7 @@ namespace OpenSim.Region.Environment.Scenes
#region Overridden Methods #region Overridden Methods
int x = 0;
public override void Update() public override void Update()
{ {
SendPrimUpdates(); SendPrimUpdates();
@ -1896,6 +1949,9 @@ namespace OpenSim.Region.Environment.Scenes
CheckForBorderCrossing(); CheckForBorderCrossing();
CheckForSignificantMovement(); // sends update to the modules. CheckForSignificantMovement(); // sends update to the modules.
} }
//if ((x++ % 30) == 0)
// Console.WriteLine(" >> In {0} known regions: {0}, seeds:{1}", Scene.RegionInfo.RegionName, KnownRegions.Count, Scene.GetChildrenSeeds(UUID));
} }
#endregion #endregion
@ -2338,7 +2394,7 @@ namespace OpenSim.Region.Environment.Scenes
// When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar // When the neighbour is informed of the border crossing, it will set up CAPS handlers for the avatar
// This means we need to remove the current caps handler here and possibly compensate later, // This means we need to remove the current caps handler here and possibly compensate later,
// in case both scenes are being hosted on the same region server. Messy // in case both scenes are being hosted on the same region server. Messy
m_scene.RemoveCapsHandler(UUID); //m_scene.RemoveCapsHandler(UUID);
newpos = newpos + (vel); newpos = newpos + (vel);
CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(UUID); CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(UUID);
@ -2358,10 +2414,14 @@ namespace OpenSim.Region.Environment.Scenes
{ {
AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
//Console.WriteLine("BEFORE CROSS");
//Scene.DumpChildrenSeeds(UUID);
//DumpKnownRegions();
// TODO Should construct this behind a method // TODO Should construct this behind a method
string capsPath = string capsPath =
"http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
+ "/CAPS/" + circuitdata.CapsPath + "0000/"; + "/CAPS/" + m_knownChildRegions[neighbourRegion.RegionHandle] /*circuitdata.CapsPath*/ + "0000/";
m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, m_uuid); m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, m_uuid);
@ -2386,6 +2446,8 @@ namespace OpenSim.Region.Environment.Scenes
CrossAttachmentsIntoNewRegion(neighbourHandle, true); CrossAttachmentsIntoNewRegion(neighbourHandle, true);
// m_scene.SendKillObject(m_localId); // m_scene.SendKillObject(m_localId);
// Next, let's close the child agent connections that are too far away.
CloseChildAgents(neighbourx, neighboury);
m_scene.NotifyMyCoarseLocationChange(); m_scene.NotifyMyCoarseLocationChange();
// the user may change their profile information in other region, // the user may change their profile information in other region,
@ -2401,6 +2463,11 @@ namespace OpenSim.Region.Environment.Scenes
m_scene.AddCapsHandler(UUID); m_scene.AddCapsHandler(UUID);
} }
} }
//Console.WriteLine("AFTER CROSS");
//Scene.DumpChildrenSeeds(UUID);
//DumpKnownRegions();
} }
/// <summary> /// <summary>
@ -2413,31 +2480,36 @@ namespace OpenSim.Region.Environment.Scenes
public void CloseChildAgents(uint newRegionX, uint newRegionY) public void CloseChildAgents(uint newRegionX, uint newRegionY)
{ {
List<ulong> byebyeRegions = new List<ulong>(); List<ulong> byebyeRegions = new List<ulong>();
m_log.DebugFormat("[AVATAR]: Closing child agents. Checking {0} regions in {1}", m_knownChildRegions.Keys.Count, Scene.RegionInfo.RegionName);
//DumpKnownRegions();
foreach (ulong handle in m_knownChildRegions) lock (m_knownChildRegions)
{
foreach (ulong handle in m_knownChildRegions.Keys)
{ {
uint x, y; uint x, y;
Utils.LongToUInts(handle, out x, out y); Utils.LongToUInts(handle, out x, out y);
x = x / Constants.RegionSize; x = x / Constants.RegionSize;
y = y / Constants.RegionSize; y = y / Constants.RegionSize;
//Console.WriteLine("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
//Console.WriteLine("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
if (Util.IsOutsideView(x, newRegionX, y, newRegionY)) if (Util.IsOutsideView(x, newRegionX, y, newRegionY))
{ {
Console.WriteLine("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs(x-newRegionX));
Console.WriteLine("---> y: " + y + "; newy:" + newRegionY);
byebyeRegions.Add(handle); byebyeRegions.Add(handle);
} }
} }
}
if (byebyeRegions.Count > 0)
{
m_log.Info("[AVATAR]: Closing " + byebyeRegions.Count + " child agents");
m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions);
}
foreach (ulong handle in byebyeRegions) foreach (ulong handle in byebyeRegions)
{ {
RemoveNeighbourRegion(handle); RemoveNeighbourRegion(handle);
} }
if (byebyeRegions.Count > 0)
{
m_log.Info("[AVATAR]: Closing " + byebyeRegions.Count + " child agents");
m_scene.SceneGridService.SendCloseChildAgentConnections(m_controllingClient.AgentId, byebyeRegions);
}
} }
@ -2940,7 +3012,8 @@ namespace OpenSim.Region.Environment.Scenes
m_DrawDistance = (float)info.GetValue("m_DrawDistance", typeof(float)); m_DrawDistance = (float)info.GetValue("m_DrawDistance", typeof(float));
m_appearance = (AvatarAppearance)info.GetValue("m_appearance", typeof(AvatarAppearance)); m_appearance = (AvatarAppearance)info.GetValue("m_appearance", typeof(AvatarAppearance));
m_knownChildRegions = (List<ulong>)info.GetValue("m_knownChildRegions", typeof(List<ulong>));
m_knownChildRegions = (Dictionary<ulong, string>)info.GetValue("m_knownChildRegions", typeof(Dictionary<ulong, string>));
posLastSignificantMove posLastSignificantMove
= new Vector3( = new Vector3(