Added handlers to SceneGraph.OnObjectCreate event in both ScenePersistenceSyncModule
and ScriptEngineSyncModule, so that they can apply actor specific operations once an object is added to the local Scene.dsg
parent
d0b429c186
commit
e68a8f7710
|
@ -272,6 +272,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
m_log.Warn("[REGION SYNC MODULE]: StatsTimerElapsed -- NOT yet implemented.");
|
||||
}
|
||||
|
||||
//NOTE: We proably don't need to do this, and there might not be a need for OnPostSceneCreation event to let RegionSyncModule
|
||||
// and ActorSyncModules to gain some access to each other. We'll keep it here for a while, until we are sure it's not
|
||||
// needed.
|
||||
// Now the communication between RegionSyncModule and ActorSyncModules are through SceneGraph or Scene.EventManager events.
|
||||
public void OnPostSceneCreation(Scene createdScene)
|
||||
{
|
||||
//If this is the local scene the actor is working on, find out the actor type.
|
||||
|
@ -282,7 +286,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
return;
|
||||
}
|
||||
m_actorType = m_scene.ActorSyncModule.ActorType;
|
||||
m_log.Warn(LogHeader + " informed about ActorType: "+m_actorType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,13 +572,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
|
||||
private void HandleAddNewObject(SceneObjectGroup sog)
|
||||
{
|
||||
//RegionSyncModule only add object to SceneGraph. Any actor specific actions will be implemented
|
||||
//by each ActorSyncModule, which would be triggered its subcription to event SceneGraph.OnObjectCreate.
|
||||
bool attachToBackup = false;
|
||||
|
||||
//only need to persist the scene if this is the ScenePersistence
|
||||
if (m_actorType == DSGActorTypes.ScenePersistence)
|
||||
{
|
||||
attachToBackup = true;
|
||||
}
|
||||
if (m_scene.AddNewSceneObject(sog, attachToBackup))
|
||||
{
|
||||
m_log.Debug(LogHeader + ": added obj " + sog.UUID);
|
||||
|
|
|
@ -73,6 +73,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
|
||||
//Register for the OnPostSceneCreation event
|
||||
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
|
||||
|
||||
//Register for Scene/SceneGraph events
|
||||
m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScenePersistence_OnObjectCreate);
|
||||
}
|
||||
|
||||
//Called after AddRegion() has been called for all region modules of the scene.
|
||||
|
@ -137,6 +140,20 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ScenePersistence's actions upon an object is added to the local scene.
|
||||
/// </summary>
|
||||
private void ScenePersistence_OnObjectCreate(EntityBase entity)
|
||||
{
|
||||
if (entity is SceneObjectGroup)
|
||||
{
|
||||
m_log.Warn(LogHeader + ": link to backup for " + entity.UUID);
|
||||
SceneObjectGroup sog = (SceneObjectGroup)entity;
|
||||
sog.AttachToBackup();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion //ScenePersistenceSyncModule
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
|
||||
//Register for the OnPostSceneCreation event
|
||||
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
|
||||
|
||||
//Register for Scene/SceneGraph events
|
||||
m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScriptEngine_OnObjectCreate);
|
||||
}
|
||||
|
||||
//Called after AddRegion() has been called for all region modules of the scene.
|
||||
|
@ -136,6 +139,21 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Script Engine's action upon an object is added to the local scene
|
||||
/// </summary>
|
||||
private void ScriptEngine_OnObjectCreate(EntityBase entity)
|
||||
{
|
||||
if (entity is SceneObjectGroup)
|
||||
{
|
||||
m_log.Warn(LogHeader + ": start script for obj " + entity.UUID);
|
||||
SceneObjectGroup sog = (SceneObjectGroup)entity;
|
||||
sog.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, 0);
|
||||
sog.ResumeScripts();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion //ScriptEngineSyncModule
|
||||
|
||||
}
|
||||
|
|
|
@ -117,20 +117,22 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
// Create a thread for the receive loop
|
||||
m_rcvLoop = new Thread(new ThreadStart(ReceiveLoop));
|
||||
m_rcvLoop.Name = Description + " (ReceiveLoop)";
|
||||
m_log.WarnFormat("{0} Starting {1} thread", LogHeader, m_rcvLoop.Name);
|
||||
m_log.WarnFormat("{0} Starting {1} thread", Description, m_rcvLoop.Name);
|
||||
m_rcvLoop.Start();
|
||||
|
||||
// Create a thread for the send loop
|
||||
m_send_loop = new Thread(new ThreadStart(delegate() { SendLoop(); }));
|
||||
m_send_loop.Name = Description + " (SendLoop)";
|
||||
m_log.WarnFormat("{0} Starting {1} thread", LogHeader, m_send_loop.Name);
|
||||
m_log.WarnFormat("{0} Starting {1} thread", Description, m_send_loop.Name);
|
||||
m_send_loop.Start();
|
||||
}
|
||||
|
||||
public void Shutdown()
|
||||
{
|
||||
// The remote scene will remove our avatars automatically when we disconnect
|
||||
//m_rcvLoop.Abort();
|
||||
m_log.Warn(LogHeader + " shutdown connection");
|
||||
// Abort receive and send loop
|
||||
m_rcvLoop.Abort();
|
||||
m_send_loop.Abort();
|
||||
|
||||
// Close the connection
|
||||
m_tcpConnection.Client.Close();
|
||||
|
@ -157,7 +159,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("{0} has disconnected: {1} (SendLoop)", LogHeader, e.Message);
|
||||
m_log.ErrorFormat("{0} has disconnected: {1} (SendLoop)", Description, e.Message);
|
||||
}
|
||||
Shutdown();
|
||||
}
|
||||
|
@ -208,7 +210,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
}
|
||||
catch (IOException)
|
||||
{
|
||||
m_log.WarnFormat("{0}:{1} has disconnected.", LogHeader, m_connectorNum);
|
||||
m_log.WarnFormat("{0}:{1} has disconnected.", Description, m_connectorNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,6 +234,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
catch
|
||||
{
|
||||
//ShutdownClient();
|
||||
m_log.WarnFormat("{0}:{1} has disconnected.", Description, m_connectorNum);
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
|
@ -242,7 +245,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("{0} Encountered an exception: {1} (MSGTYPE = {2})", LogHeader, e.Message, msg.ToString());
|
||||
m_log.WarnFormat("{0} Encountered an exception: {1} (MSGTYPE = {2})", Description, e.Message, msg.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2256,7 +2256,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
try
|
||||
{
|
||||
m_log.Warn("TriggerOnPostSceneCreation");
|
||||
d(createdScene);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -1293,15 +1293,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
//SYMMETRIC SYNC (KittyL: started 12/23/2010)
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
m_regionSyncModule = RequestModuleInterface<IRegionSyncModule>();
|
||||
if (m_regionSyncModule == null)
|
||||
{
|
||||
m_log.Warn("Does not find a RegionSyncModule interface");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("SetModuleInterfaces: RegionSyncModule interface set.");
|
||||
}
|
||||
|
||||
m_DSGActorSyncModule = RequestModuleInterface<IDSGActorSyncModule>();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -373,23 +373,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
sceneObject.AttachToScene(m_parentScene);
|
||||
|
||||
//KittyL: edited to support script engine actor
|
||||
//if (sendClientUpdates)
|
||||
// sceneObject.ScheduleGroupForFullUpdate();
|
||||
if (sendClientUpdates)
|
||||
{
|
||||
sceneObject.ScheduleGroupForFullUpdate();
|
||||
}
|
||||
|
||||
Entities.Add(sceneObject);
|
||||
|
||||
//KittyL: edited to support script engine actor
|
||||
//if (attachToBackup)
|
||||
// sceneObject.AttachToBackup();
|
||||
if (attachToBackup && m_parentScene.IsAuthoritativeScene())
|
||||
{
|
||||
if (attachToBackup)
|
||||
sceneObject.AttachToBackup();
|
||||
}
|
||||
|
||||
if (OnObjectCreate != null)
|
||||
OnObjectCreate(sceneObject);
|
||||
|
|
Loading…
Reference in New Issue