Add funtions in RegionSyncModule and (Actor)SyncModules to correctly process SyncStop.

E.g. script engine will save script states and delete objects in local scene copy;
ScenePersistence still maintains object copies, though.
dsg
Huaiyu (Kitty) Liu 2010-12-28 15:58:16 -08:00
parent 130915f669
commit 821f80bf3f
3 changed files with 42 additions and 1 deletions

View File

@ -556,6 +556,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//Shutdown all sync connectors //Shutdown all sync connectors
StopAllSyncConnectors(); StopAllSyncConnectors();
} }
//Trigger SyncStop event, ActorSyncModules can then take actor specific action if needed.
//For instance, script engine will save script states
//save script state and stop script instances
m_scene.EventManager.TriggerOnSymmetricSyncStop();
} }
private void SyncStatus(Object[] args) private void SyncStatus(Object[] args)
@ -854,6 +860,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
/// <param name="sog"></param> /// <param name="sog"></param>
private void RegionSyncModule_OnObjectBeingRemovedFromScene(SceneObjectGroup sog) private void RegionSyncModule_OnObjectBeingRemovedFromScene(SceneObjectGroup sog)
{ {
//m_log.DebugFormat("RegionSyncModule_OnObjectBeingRemovedFromScene called at time {0}:{1}:{2}", DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond);
//Only send the message out if this is a relay node for sync messages, or this actor caused deleting the object //Only send the message out if this is a relay node for sync messages, or this actor caused deleting the object
if (m_isSyncRelay || CheckObjectForSendingUpdate(sog)) if (m_isSyncRelay || CheckObjectForSendingUpdate(sog))
{ {

View File

@ -84,6 +84,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//Register for Scene/SceneGraph events //Register for Scene/SceneGraph events
m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScriptEngine_OnObjectCreate); m_scene.SceneGraph.OnObjectCreate += new ObjectCreateDelegate(ScriptEngine_OnObjectCreate);
m_scene.EventManager.OnSymmetricSyncStop += ScriptEngine_OnSymmetricSyncStop;
} }
//Called after AddRegion() has been called for all region modules of the scene. //Called after AddRegion() has been called for all region modules of the scene.
@ -167,6 +168,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
} }
public void ScriptEngine_OnSymmetricSyncStop()
{
//Inform script engine to save script states and stop scripts
m_scene.EventManager.TriggerScriptEngineSyncStop();
//remove all objects
m_scene.DeleteAllSceneObjects();
}
#endregion //ScriptEngineSyncModule #endregion //ScriptEngineSyncModule
} }

View File

@ -2183,7 +2183,7 @@ namespace OpenSim.Region.Framework.Scenes
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat( m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerOnSceneObjectLoaded failed - continuing. {0} {1}", "[EVENT MANAGER]: Delegate for TriggerScriptEngineSyncStop failed - continuing. {0} {1}",
e.Message, e.StackTrace); e.Message, e.StackTrace);
} }
} }
@ -2267,6 +2267,30 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} }
public delegate void SymmetricSyncStop();
public event SymmetricSyncStop OnSymmetricSyncStop;
public void TriggerOnSymmetricSyncStop()
{
SymmetricSyncStop handlerSymmetricSyncStop = OnSymmetricSyncStop;
if (handlerSymmetricSyncStop != null)
{
foreach (SymmetricSyncStop d in handlerSymmetricSyncStop.GetInvocationList())
{
try
{
d();
}
catch (Exception e)
{
m_log.ErrorFormat(
"[EVENT MANAGER]: Delegate for TriggerOnSymmetricSyncStop failed - continuing. {0} {1}",
e.Message, e.StackTrace);
}
}
}
}
//end of SYMMETRIC SYNC //end of SYMMETRIC SYNC
} }
} }