From 9892e115ccdcc8567087041917fb5c7694aa8836 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Thu, 28 Apr 2011 20:19:54 -0700
Subject: Fatpack message on agent transfers: 1 message only (UpdateAgent)
containing the agent and all attachments. Preserves backwards compatibility
-- older sims get passed attachments one by one. Meaning that I finally
introduced versioning in the simulation service.
---
OpenSim/Framework/ChildAgentDataUpdate.cs | 57 +++++++++++++++++++++---
OpenSim/Framework/Tests/MundaneFrameworkTests.cs | 2 +-
2 files changed, 53 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Framework')
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index ce0b2fb..a626b82 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -62,7 +62,7 @@ namespace OpenSim.Framework
UUID AgentID { get; set; }
OSDMap Pack();
- void Unpack(OSDMap map);
+ void Unpack(OSDMap map, IScene scene);
}
///
@@ -122,7 +122,7 @@ namespace OpenSim.Framework
return args;
}
- public void Unpack(OSDMap args)
+ public void Unpack(OSDMap args, IScene scene)
{
if (args.ContainsKey("region_handle"))
UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
@@ -329,6 +329,10 @@ namespace OpenSim.Framework
public string CallbackURI;
+ // These two must have the same Count
+ public List AttachmentObjects;
+ public List AttachmentObjectStates;
+
public virtual OSDMap Pack()
{
m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");
@@ -441,7 +445,30 @@ namespace OpenSim.Framework
if ((CallbackURI != null) && (!CallbackURI.Equals("")))
args["callback_uri"] = OSD.FromString(CallbackURI);
+ // Attachment objects for fatpack messages
+ if (AttachmentObjects != null)
+ {
+ int i = 0;
+ OSDArray attObjs = new OSDArray(AttachmentObjects.Count);
+ foreach (ISceneObject so in AttachmentObjects)
+ {
+ OSDMap info = new OSDMap(4);
+ info["sog"] = OSD.FromString(so.ToXml2());
+ info["extra"] = OSD.FromString(so.ExtraToXmlString());
+ info["modified"] = OSD.FromBoolean(so.HasGroupChanged);
+ try
+ {
+ info["state"] = OSD.FromString(AttachmentObjectStates[i++]);
+ }
+ catch (IndexOutOfRangeException e)
+ {
+ m_log.WarnFormat("[CHILD AGENT DATA]: scrtips list is shorter than object list.");
+ }
+ attObjs.Add(info);
+ }
+ args["attach_objects"] = attObjs;
+ }
return args;
}
@@ -450,7 +477,7 @@ namespace OpenSim.Framework
/// Avoiding reflection makes it painful to write, but that's the price!
///
///
- public virtual void Unpack(OSDMap args)
+ public virtual void Unpack(OSDMap args, IScene scene)
{
m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data");
@@ -628,6 +655,26 @@ namespace OpenSim.Framework
if (args["callback_uri"] != null)
CallbackURI = args["callback_uri"].AsString();
+
+ // Attachment objects
+ if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array)
+ {
+ OSDArray attObjs = (OSDArray)(args["attach_objects"]);
+ AttachmentObjects = new List();
+ AttachmentObjectStates = new List();
+ foreach (OSD o in attObjs)
+ {
+ if (o.Type == OSDType.Map)
+ {
+ OSDMap info = (OSDMap)o;
+ ISceneObject so = scene.DeserializeObject(info["sog"].AsString());
+ so.ExtraFromXmlString(info["extra"].AsString());
+ so.HasGroupChanged = info["modified"].AsBoolean();
+ AttachmentObjects.Add(so);
+ AttachmentObjectStates.Add(info["state"].AsString());
+ }
+ }
+ }
}
public AgentData()
@@ -655,9 +702,9 @@ namespace OpenSim.Framework
return base.Pack();
}
- public override void Unpack(OSDMap map)
+ public override void Unpack(OSDMap map, IScene scene)
{
- base.Unpack(map);
+ base.Unpack(map, scene);
}
}
}
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
index e7f8bfc..76de6be 100644
--- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
+++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
@@ -115,7 +115,7 @@ namespace OpenSim.Framework.Tests
position2 = new AgentPosition();
Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition");
- position2.Unpack(position1.Pack());
+ position2.Unpack(position1.Pack(), null);
Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed");
Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed");
--
cgit v1.1