SyncOutPrimUpdates linked with EncodePrimProperties and SendPrimUpdateToRelevantSyncConnectors.

dsg
Huaiyu (Kitty) Liu 2011-04-11 15:43:58 -07:00
parent a06dad37fd
commit 9d3de471a5
2 changed files with 55 additions and 7 deletions

View File

@ -3108,12 +3108,47 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_primPropertyUpdates.Clear();
}
//Enqueue sync message for sending out
if (primPropertyUpdates.Count > 0)
{
//OSDMap propertiesToSync = m_primSyncInfoManager.EncodePrimProperties(part, propertiesWithSyncInfoUpdated);
//Starting a new thread to prepare sync message and enqueue it to SyncConnectors
System.Threading.ThreadPool.QueueUserWorkItem(delegate
{
//OSDMap syncData = new OSDMap();
//syncData["primCount"] = OSD.FromInteger(primPropertyUpdates.Count);
//OSDArray primDataArray = new OSDArray();
//syncData["primData"] = (OSD)primDataArray;
foreach (KeyValuePair<UUID, HashSet<SceneObjectPartProperties>> updatedPrimProperties in primPropertyUpdates)
{
UUID primUUID = updatedPrimProperties.Key;
HashSet<SceneObjectPartProperties> updatedProperties = updatedPrimProperties.Value;
OSDMap syncData = m_primSyncInfoManager.EncodePrimProperties(primUUID, updatedProperties);
SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedObject, OSDParser.SerializeJsonString(syncData));
SendPrimUpdateToRelevantSyncConnectors(primUUID, syncMsg);
}
// Indicate that the current batch of updates has been completed
Interlocked.Exchange(ref m_sendingPrimPropertyUpdates, 0);
});
}
else
{
Interlocked.Exchange(ref m_sendingPrimPropertyUpdates, 0);
}
}
//Object updates are sent by enqueuing into each connector's outQueue.
private void SendPrimUpdateToRelevantSyncConnectors(UUID primUUID, SymmetricSyncMessage syncMsg)
{
SceneObjectPart updatedPart = m_scene.GetSceneObjectPart(primUUID);
if (updatedPart == null)
return;
HashSet<SyncConnector> syncConnectors = GetSyncConnectorsForPrimUpdates(updatedPart);
foreach (SyncConnector connector in syncConnectors)
{
connector.EnqueueOutgoingUpdate(updatedPart.UUID, syncMsg.ToBytes());
}
}
@ -5180,13 +5215,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
}
}
public OSDMap EncodePrimProperties(SceneObjectPart part, List<SceneObjectPartProperties> updatedProperties)
public OSDMap EncodePrimProperties(UUID primUUID, HashSet<SceneObjectPartProperties> updatedProperties)
{
OSDMap data = new OSDMap();
data["primUUID"] = OSDMap.FromUUID(part.UUID);
data["primUUID"] = OSDMap.FromUUID(primUUID);
OSDArray propertyData = new OSDArray();
data["propertyData"] = propertyData;
foreach (SceneObjectPartProperties property in updatedProperties)
{
// data[property.ToString()] =
propertyData.Add(m_primsInSync[primUUID].EncodeUpdatedProperties(updatedProperties));
}
return data;

View File

@ -32,6 +32,12 @@ using OpenMetaverse;
namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{
public enum SyncConnectorState
{
Idle, //not connected
Initialization, //initializing local copy of Scene
Syncing, //done initialization, in normal process of syncing terrain, objects, etc
}
// For implementations, a lot was copied from RegionSyncClientView, especially the SendLoop/ReceiveLoop.
public class SyncConnector : ISyncStatistics
{
@ -53,11 +59,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private long bytesIn=0;
private long bytesOut=0;
private DateTime lastStatTime;
// A queue for outgoing traffic.
private BlockingUpdateQueue m_outQ = new BlockingUpdateQueue();
private RegionSyncModule m_regionSyncModule = null;
//members for keeping track of state of this connector
private SyncConnectorState m_syncState = SyncConnectorState.Idle;
// unique connector number across all regions
private static int m_connectorNum = 0;
public int ConnectorNum