Added SymmetricSyncMessage.cs to git index.
Added ScriptEngineSyncModule.cs with basic implementation. Code now good for script engine to initilaize local scene by synch'ing with ScenePersistence's copy. Fixed a bug in SyncStart(), so that it won't read in remote listeners' config info every time SyncStart() is called.dsg
parent
d63e3db533
commit
d0b429c186
|
@ -315,14 +315,14 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
//And for now, we assume there is only 1 remote listener to connect to.
|
||||
private void GetRemoteSyncListenerInfo()
|
||||
{
|
||||
//For now, we assume there is only one remote listener to connect to. Later on,
|
||||
//we may need to modify the code to read in multiple listeners.
|
||||
string addr = m_sysConfig.GetString("SyncListenerIPAddress", "127.0.0.1");
|
||||
int port = m_sysConfig.GetInt("SyncListenerPort", 13000);
|
||||
RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port);
|
||||
|
||||
if (m_remoteSyncListeners == null)
|
||||
{
|
||||
m_remoteSyncListeners = new HashSet<RegionSyncListenerInfo>();
|
||||
}
|
||||
m_remoteSyncListeners = new HashSet<RegionSyncListenerInfo>();
|
||||
|
||||
m_remoteSyncListeners.Add(info);
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,10 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
}
|
||||
else
|
||||
{
|
||||
GetRemoteSyncListenerInfo();
|
||||
if (m_remoteSyncListeners == null)
|
||||
{
|
||||
GetRemoteSyncListenerInfo();
|
||||
}
|
||||
StartSyncConnections();
|
||||
DoInitialSync();
|
||||
}
|
||||
|
|
|
@ -33,19 +33,19 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
m_active = false;
|
||||
if (syncConfig == null)
|
||||
{
|
||||
m_log.Warn("[Scene Persistence Sync MODULE] No RegionSyncModule config section found. Shutting down.");
|
||||
m_log.Warn(LogHeader + " No RegionSyncModule config section found. Shutting down.");
|
||||
return;
|
||||
}
|
||||
else if (!syncConfig.GetBoolean("Enabled", false))
|
||||
{
|
||||
m_log.Warn("[Scene Persistence Sync MODULE] RegionSyncModule is not enabled. Shutting down.");
|
||||
m_log.Warn(LogHeader + " RegionSyncModule is not enabled. Shutting down.");
|
||||
return;
|
||||
}
|
||||
|
||||
string actorType = syncConfig.GetString("DSGActorType", "").ToLower();
|
||||
if (!actorType.Equals("scene_persistence"))
|
||||
{
|
||||
m_log.Warn("[Scene Persistence Sync MODULE]: not configured as Scene Persistence Actor. Shut down.");
|
||||
m_log.Warn(LogHeader + ": not configured as Scene Persistence Actor. Shut down.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
|
||||
|
||||
|
||||
#endregion //IRegionModule
|
||||
#endregion //INonSharedRegionModule
|
||||
|
||||
#region IDSGActorSyncModule members and functions
|
||||
|
||||
|
@ -116,7 +116,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
|||
get { return m_actorType; }
|
||||
}
|
||||
|
||||
#endregion //INonSharedRegionModule
|
||||
#endregion //IDSGActorSyncModule
|
||||
|
||||
#region ScenePersistenceSyncModule memebers and functions
|
||||
private ILog m_log;
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* Copyright (c) Contributors: TO BE FILLED
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Client;
|
||||
using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using log4net;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using Mono.Addins;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||
{
|
||||
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AttachmentsModule")]
|
||||
public class ScriptEngineSyncModule : INonSharedRegionModule, IDSGActorSyncModule
|
||||
{
|
||||
#region INonSharedRegionModule
|
||||
|
||||
public void Initialise(IConfigSource config)
|
||||
{
|
||||
m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
IConfig syncConfig = config.Configs["RegionSyncModule"];
|
||||
m_active = false;
|
||||
if (syncConfig == null)
|
||||
{
|
||||
m_log.Warn(LogHeader + " No RegionSyncModule config section found. Shutting down.");
|
||||
return;
|
||||
}
|
||||
else if (!syncConfig.GetBoolean("Enabled", false))
|
||||
{
|
||||
m_log.Warn(LogHeader + " RegionSyncModule is not enabled. Shutting down.");
|
||||
return;
|
||||
}
|
||||
|
||||
string actorType = syncConfig.GetString("DSGActorType", "").ToLower();
|
||||
if (!actorType.Equals("script_engine"))
|
||||
{
|
||||
m_log.Warn(LogHeader + ": not configured as Scene Persistence Actor. Shut down.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_active = true;
|
||||
|
||||
m_log.Warn(LogHeader + " Initialised");
|
||||
|
||||
}
|
||||
|
||||
//Called after Initialise()
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (!m_active)
|
||||
return;
|
||||
m_log.Warn(LogHeader + " AddRegion() called");
|
||||
//connect with scene
|
||||
m_scene = scene;
|
||||
|
||||
//register the module with SceneGraph. If needed, SceneGraph checks the module's ActorType to know what type of module it is.
|
||||
m_scene.RegisterModuleInterface<IDSGActorSyncModule>(this);
|
||||
|
||||
// Setup the command line interface
|
||||
//m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
|
||||
//InstallInterfaces();
|
||||
|
||||
//Register for the OnPostSceneCreation event
|
||||
//m_scene.EventManager.OnPostSceneCreation += OnPostSceneCreation;
|
||||
}
|
||||
|
||||
//Called after AddRegion() has been called for all region modules of the scene.
|
||||
//NOTE::However, at this point, Scene may not have requested all the needed region module interfaces yet.
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
if (!m_active)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public Type ReplaceableInterface
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
m_scene = null;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "ScriptEngineSyncModule"; }
|
||||
}
|
||||
|
||||
#endregion //INonSharedRegionModule
|
||||
|
||||
#region IDSGActorSyncModule members and functions
|
||||
|
||||
private DSGActorTypes m_actorType = DSGActorTypes.ScriptEngine;
|
||||
public DSGActorTypes ActorType
|
||||
{
|
||||
get { return m_actorType; }
|
||||
}
|
||||
|
||||
#endregion //IDSGActorSyncModule
|
||||
|
||||
|
||||
#region ScriptEngineSyncModule memebers and functions
|
||||
private ILog m_log;
|
||||
private bool m_active = false;
|
||||
public bool Active
|
||||
{
|
||||
get { return m_active; }
|
||||
}
|
||||
|
||||
private Scene m_scene;
|
||||
|
||||
private string LogHeader = "[ScriptEngineSyncModule]";
|
||||
|
||||
public void OnPostSceneCreation(Scene createdScene)
|
||||
{
|
||||
//If this is the local scene the actor is working on, do something
|
||||
if (createdScene == m_scene)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion //ScriptEngineSyncModule
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
* Copyright (c) Contributors: TO BE FILLED
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
|
||||
{
|
||||
//Initial code in SymmetricSyncMessage copied from RegionSyncMessage.
|
||||
|
||||
/// <summary>
|
||||
/// Types of symmetric sync messages among actors.
|
||||
/// NOTE:: To enable message subscription, we may need to move the definition of MsgType to, say IRegionSyncModule, so that it can be exposed to other region modules.
|
||||
/// </summary>
|
||||
public class SymmetricSyncMessage
|
||||
{
|
||||
#region MsgType Enum
|
||||
public enum MsgType
|
||||
{
|
||||
Null,
|
||||
//ConnectSyncClient,
|
||||
//DisconnectSyncClient,
|
||||
// CM -> SIM(Scene)
|
||||
ActorConnect,
|
||||
AgentAdd,
|
||||
AgentUpdate,
|
||||
AgentRemove,
|
||||
AgentRequestSit,
|
||||
AgentSit,
|
||||
GrabObject,
|
||||
GrabUpdate,
|
||||
DeGrabObject,
|
||||
StartAnim,
|
||||
StopAnim,
|
||||
GetTerrain,
|
||||
GetObjects,
|
||||
SubscribeObjects,
|
||||
GetAvatars,
|
||||
SubscribeAvatars,
|
||||
ChatFromClient,
|
||||
AvatarTeleportOut, // An LLClientView (real client) was converted to a RegionSyncAvatar
|
||||
AvatarTeleportIn, // A RegionSyncAvatar was converted to an LLClientView (real client)
|
||||
// SIM -> CM
|
||||
Terrain,
|
||||
NewObject, // objects
|
||||
UpdatedObject, // objects
|
||||
RemovedObject, // objects
|
||||
NewAvatar, // avatars
|
||||
UpdatedAvatar, // avatars
|
||||
AnimateAvatar,
|
||||
AvatarAppearance,
|
||||
RemovedAvatar, // avatars
|
||||
BalanceClientLoad, // Tells CM a client load target and a place to teleport the extras
|
||||
ChatFromSim,
|
||||
SitResponse,
|
||||
SendAnimations,
|
||||
// BIDIR
|
||||
EchoRequest,
|
||||
EchoResponse,
|
||||
RegionName,
|
||||
RegionStatus,
|
||||
//Added by KittyL
|
||||
// Actor -> Scene
|
||||
// ActorType, //to register the type (e.g. Client Manager or Script Engine) with Scene when sync channel is initialized
|
||||
//SetObjectProperty,
|
||||
// ActorStop,
|
||||
ResetScene,
|
||||
OnRezScript,
|
||||
OnScriptReset,
|
||||
OnUpdateScript,
|
||||
//QuarkSubscription,
|
||||
|
||||
// Scene -> Script Engine
|
||||
//NewObjectWithScript,
|
||||
//SceneLocation,
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Member Data
|
||||
private MsgType m_type;
|
||||
private byte[] m_data;
|
||||
static ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public SymmetricSyncMessage(MsgType type, byte[] data)
|
||||
{
|
||||
m_type = type;
|
||||
m_data = data;
|
||||
}
|
||||
|
||||
public SymmetricSyncMessage(MsgType type, string msg)
|
||||
{
|
||||
m_type = type;
|
||||
m_data = System.Text.Encoding.ASCII.GetBytes(msg);
|
||||
}
|
||||
|
||||
public SymmetricSyncMessage(MsgType type)
|
||||
{
|
||||
m_type = type;
|
||||
m_data = new byte[0];
|
||||
}
|
||||
|
||||
public SymmetricSyncMessage(Stream stream)
|
||||
{
|
||||
//ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
//try
|
||||
{
|
||||
m_type = (MsgType)Utils.BytesToInt(GetBytesFromStream(stream, 4));
|
||||
int length = Utils.BytesToInt(GetBytesFromStream(stream, 4));
|
||||
m_data = GetBytesFromStream(stream, length);
|
||||
//log.WarnFormat("RegionSyncMessage Constructed {0} ({1} bytes)", m_type.ToString(), length);
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] GetBytesFromStream(Stream stream, int count)
|
||||
{
|
||||
// Loop to receive the message length
|
||||
byte[] ret = new byte[count];
|
||||
int i = 0;
|
||||
while (i < count)
|
||||
{
|
||||
i += stream.Read(ret, i, count - i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
public MsgType Type
|
||||
{
|
||||
get { return m_type; }
|
||||
}
|
||||
|
||||
public int Length
|
||||
{
|
||||
get { return m_data.Length; }
|
||||
}
|
||||
|
||||
public byte[] Data
|
||||
{
|
||||
get { return m_data; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Conversions
|
||||
public byte[] ToBytes()
|
||||
{
|
||||
byte[] buf = new byte[m_data.Length + 8];
|
||||
Utils.IntToBytes((int)m_type, buf, 0);
|
||||
Utils.IntToBytes(m_data.Length, buf, 4);
|
||||
Array.Copy(m_data, 0, buf, 8, m_data.Length);
|
||||
return buf;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0} ({1} bytes)", m_type.ToString(), m_data.Length.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public static void HandleSuccess(string header, RegionSyncMessage msg, string message)
|
||||
{
|
||||
m_log.WarnFormat("{0} Handled {1}: {2}", header, msg.ToString(), message);
|
||||
}
|
||||
|
||||
public static void HandleTrivial(string header, RegionSyncMessage msg, string message)
|
||||
{
|
||||
m_log.WarnFormat("{0} Issue handling {1}: {2}", header, msg.ToString(), message);
|
||||
}
|
||||
|
||||
public static void HandleWarning(string header, RegionSyncMessage msg, string message)
|
||||
{
|
||||
m_log.WarnFormat("{0} Warning handling {1}: {2}", header, msg.ToString(), message);
|
||||
}
|
||||
|
||||
public static void HandleError(string header, RegionSyncMessage msg, string message)
|
||||
{
|
||||
m_log.WarnFormat("{0} Error handling {1}: {2}", header, msg.ToString(), message);
|
||||
}
|
||||
|
||||
public static bool HandlerDebug(string header, RegionSyncMessage msg, string message)
|
||||
{
|
||||
m_log.WarnFormat("{0} DBG ({1}): {2}", header, msg.ToString(), message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue