diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs index 3132eb75c6..6a7b622644 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs @@ -113,6 +113,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat if (c.Channel == DEBUG_CHANNEL) c.Type = ChatTypeEnum.DebugChannel; + if (c.Message.Length > 1100) + c.Message = c.Message.Substring(0, 1000); + // chat works by redistributing every incoming chat // message to each avatar in the scene Vector3 pos = new Vector3(128, 128, 30); diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs index 64e8c8072c..51d5006eb4 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs @@ -44,7 +44,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces { Scene World { get; } IConfig Config { get; } - Object AsyncCommands { get; } ILog Log { get; } string ScriptEngineName { get; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index f331b5c632..fabcc2c987 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -47,66 +47,86 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private static Thread cmdHandlerThread; private static int cmdHandlerThreadCycleSleepms; - private static List m_Managers = new List(); - public IScriptEngine m_ScriptEngine; + private static List m_Scenes = new List(); + private static List m_ScriptEngines = + new List(); - private Dataserver m_Dataserver; - private Timer m_Timer; - private HttpRequest m_HttpRequest; - private Listener m_Listener; - private SensorRepeat m_SensorRepeat; - private XmlRequest m_XmlRequest; + public IScriptEngine m_ScriptEngine; + private IScene m_Scene; + + private static Dictionary m_Dataserver = + new Dictionary(); + private static Dictionary m_Timer = + new Dictionary(); + private static Dictionary m_Listener = + new Dictionary(); + private static Dictionary m_HttpRequest = + new Dictionary(); + private static Dictionary m_SensorRepeat = + new Dictionary(); + private static Dictionary m_XmlRequest = + new Dictionary(); public Dataserver DataserverPlugin { - get { return m_Dataserver; } + get { return m_Dataserver[m_Scene]; } } public Timer TimerPlugin { - get { return m_Timer; } + get { return m_Timer[m_Scene]; } } public HttpRequest HttpRequestPlugin { - get { return m_HttpRequest; } + get { return m_HttpRequest[m_Scene]; } } public Listener ListenerPlugin { - get { return m_Listener; } + get { return m_Listener[m_Scene]; } } public SensorRepeat SensorRepeatPlugin { - get { return m_SensorRepeat; } + get { return m_SensorRepeat[m_Scene]; } } public XmlRequest XmlRequestPlugin { - get { return m_XmlRequest; } + get { return m_XmlRequest[m_Scene]; } } - public AsyncCommandManager[] Managers + public IScriptEngine[] ScriptEngines { - get { return m_Managers.ToArray(); } + get { return m_ScriptEngines.ToArray(); } } public AsyncCommandManager(IScriptEngine _ScriptEngine) { m_ScriptEngine = _ScriptEngine; - if (!m_Managers.Contains(this)) - m_Managers.Add(this); + m_Scene = m_ScriptEngine.World; + + if (!m_Scenes.Contains(m_Scene)) + m_Scenes.Add(m_Scene); + if (!m_ScriptEngines.Contains(m_ScriptEngine)) + m_ScriptEngines.Add(m_ScriptEngine); ReadConfig(); // Create instances of all plugins - m_Dataserver = new Dataserver(this); - m_Timer = new Timer(this); - m_HttpRequest = new HttpRequest(this); - m_Listener = new Listener(this); - m_SensorRepeat = new SensorRepeat(this); - m_XmlRequest = new XmlRequest(this); + if (!m_Dataserver.ContainsKey(m_Scene)) + m_Dataserver[m_Scene] = new Dataserver(this); + if (!m_Timer.ContainsKey(m_Scene)) + m_Timer[m_Scene] = new Timer(this); + if (!m_HttpRequest.ContainsKey(m_Scene)) + m_HttpRequest[m_Scene] = new HttpRequest(this); + if (!m_Listener.ContainsKey(m_Scene)) + m_Listener[m_Scene] = new Listener(this); + if (!m_SensorRepeat.ContainsKey(m_Scene)) + m_SensorRepeat[m_Scene] = new SensorRepeat(this); + if (!m_XmlRequest.ContainsKey(m_Scene)) + m_XmlRequest[m_Scene] = new XmlRequest(this); StartThread(); } @@ -127,26 +147,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void ReadConfig() { - cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100); +// cmdHandlerThreadCycleSleepms = m_ScriptEngine.Config.GetInt("AsyncLLCommandLoopms", 100); + // TODO: Make this sane again + cmdHandlerThreadCycleSleepms = 100; } ~AsyncCommandManager() { // Shut down thread - try - { - if (cmdHandlerThread != null) - { - if (cmdHandlerThread.IsAlive == true) - { - cmdHandlerThread.Abort(); - //cmdHandlerThread.Join(); - } - } - } - catch - { - } +// try +// { +// if (cmdHandlerThread != null) +// { +// if (cmdHandlerThread.IsAlive == true) +// { +// cmdHandlerThread.Abort(); +// //cmdHandlerThread.Join(); +// } +// } +// } +// catch +// { +// } } /// @@ -162,10 +184,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { Thread.Sleep(cmdHandlerThreadCycleSleepms); - foreach (AsyncCommandManager m in m_Managers) - { - m.DoOneCmdHandlerPass(); - } + DoOneCmdHandlerPass(); } } catch @@ -174,20 +193,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } - public void DoOneCmdHandlerPass() + private static void DoOneCmdHandlerPass() { - // Check timers - m_Timer.CheckTimerEvents(); - // Check HttpRequests - m_HttpRequest.CheckHttpRequests(); - // Check XMLRPCRequests - m_XmlRequest.CheckXMLRPCRequests(); - // Check Listeners - m_Listener.CheckListeners(); - // Check Sensors - m_SensorRepeat.CheckSenseRepeaterEvents(); - // Check dataserver - m_Dataserver.ExpireRequests(); + foreach (IScene s in m_Scenes) + { + // Check timers + m_Timer[s].CheckTimerEvents(); + // Check HttpRequests + m_HttpRequest[s].CheckHttpRequests(); + // Check XMLRPCRequests + m_XmlRequest[s].CheckXMLRPCRequests(); + // Check Listeners + m_Listener[s].CheckListeners(); + // Check Sensors + m_SensorRepeat[s].CheckSenseRepeaterEvents(); + // Check dataserver + m_Dataserver[s].ExpireRequests(); + } } /// @@ -195,38 +217,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// /// /// - public void RemoveScript(uint localID, UUID itemID) + public static void RemoveScript(IScene scene, uint localID, UUID itemID) { // Remove a specific script // Remove dataserver events - m_Dataserver.RemoveEvents(localID, itemID); + m_Dataserver[scene].RemoveEvents(localID, itemID); // Remove from: Timers - m_Timer.UnSetTimerEvents(localID, itemID); + m_Timer[scene].UnSetTimerEvents(localID, itemID); // Remove from: HttpRequest IHttpRequests iHttpReq = - m_ScriptEngine.World.RequestModuleInterface(); + scene.RequestModuleInterface(); iHttpReq.StopHttpRequest(localID, itemID); - IWorldComm comms = m_ScriptEngine.World.RequestModuleInterface(); + IWorldComm comms = scene.RequestModuleInterface(); comms.DeleteListener(itemID); - IXMLRPC xmlrpc = m_ScriptEngine.World.RequestModuleInterface(); + IXMLRPC xmlrpc = scene.RequestModuleInterface(); xmlrpc.DeleteChannels(itemID); xmlrpc.CancelSRDRequests(itemID); // Remove Sensors - m_SensorRepeat.UnSetSenseRepeaterEvents(localID, itemID); + m_SensorRepeat[scene].UnSetSenseRepeaterEvents(localID, itemID); } - public Object[] GetSerializationData(UUID itemID) + public static Object[] GetSerializationData(IScene scene, UUID itemID) { List data = new List(); - Object[] listeners=m_Listener.GetSerializationData(itemID); + Object[] listeners=m_Listener[scene].GetSerializationData(itemID); if (listeners.Length > 0) { data.Add("listener"); @@ -234,7 +256,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api data.AddRange(listeners); } - Object[] timers=m_Timer.GetSerializationData(itemID); + Object[] timers=m_Timer[scene].GetSerializationData(itemID); if (timers.Length > 0) { data.Add("timer"); @@ -242,7 +264,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api data.AddRange(timers); } - Object[] sensors=m_SensorRepeat.GetSerializationData(itemID); + Object[] sensors=m_SensorRepeat[scene].GetSerializationData(itemID); if (sensors.Length > 0) { data.Add("sensor"); @@ -253,8 +275,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return data.ToArray(); } - public void CreateFromData(uint localID, UUID itemID, UUID hostID, - Object[] data) + public static void CreateFromData(IScene scene, uint localID, + UUID itemID, UUID hostID, Object[] data) { int idx = 0; int len; @@ -275,15 +297,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (type) { case "listener": - m_Listener.CreateFromData(localID, itemID, hostID, - item); + m_Listener[scene].CreateFromData(localID, itemID, + hostID, item); break; case "timer": - m_Timer.CreateFromData(localID, itemID, hostID, item); + m_Timer[scene].CreateFromData(localID, itemID, + hostID, item); break; case "sensor": - m_SensorRepeat.CreateFromData(localID, itemID, hostID, - item); + m_SensorRepeat[scene].CreateFromData(localID, + itemID, hostID, item); break; } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 512fcd96fd..552d47c7f7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -92,7 +92,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_ScriptDistanceFactor = config.Configs["XEngine"]. GetFloat("ScriptDistanceLimitFactor", 1.0f); - AsyncCommands = (AsyncCommandManager)ScriptEngine.AsyncCommands; + AsyncCommands = new AsyncCommandManager(ScriptEngine); } private DateTime m_timer = DateTime.Now; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs index 92f603d274..3d3fb05b90 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/HttpRequest.cs @@ -77,9 +77,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins new LSL_Types.LSLString(httpInfo.response_body) }; - foreach (AsyncCommandManager m in m_CmdManager.Managers) + foreach (IScriptEngine e in m_CmdManager.ScriptEngines) { - if (m.m_ScriptEngine.PostObjectEvent(httpInfo.localID, + if (e.PostObjectEvent(httpInfo.localID, new EventParams("http_response", resobj, new DetectParams[0]))) break; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs index 3f3cf3967b..a7699a1811 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/XmlRequest.cs @@ -71,9 +71,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins new LSL_Types.LSLString(rInfo.GetStrVal()) }; - foreach (AsyncCommandManager m in m_CmdManager.Managers) + foreach (IScriptEngine e in m_CmdManager.ScriptEngines) { - if (m.m_ScriptEngine.PostScriptEvent( + if (e.PostScriptEvent( rInfo.GetItemID(), new EventParams( "remote_data", resobj, new DetectParams[0]))) @@ -100,9 +100,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins new LSL_Types.LSLString(srdInfo.sdata) }; - foreach (AsyncCommandManager m in m_CmdManager.Managers) + foreach (IScriptEngine e in m_CmdManager.ScriptEngines) { - if (m.m_ScriptEngine.PostScriptEvent( + if (e.PostScriptEvent( srdInfo.m_itemID, new EventParams( "remote_data", resobj, new DetectParams[0]))) diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 3a8c4da235..14ac2564c7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -246,8 +246,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance ScriptSerializer.Deserialize(xml, this); - AsyncCommandManager async = (AsyncCommandManager)m_Engine.AsyncCommands; - async.CreateFromData( + AsyncCommandManager.CreateFromData(m_Engine.World, m_LocalID, m_ItemID, m_ObjectID, PluginData); @@ -337,6 +336,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance public void DestroyScriptInstance() { ReleaseControls(); + AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID); } public void RemoveState() @@ -554,8 +554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance // m_Engine.Log.DebugFormat("[Script] Script {0}.{1} state set to {2}", // m_PrimName, m_ScriptName, data.Params[0].ToString()); m_State=data.Params[0].ToString(); - AsyncCommandManager async = (AsyncCommandManager)m_Engine.AsyncCommands; - async.RemoveScript( + AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID); SceneObjectPart part = m_Engine.World.GetSceneObjectPart( @@ -691,8 +690,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); part.GetInventoryItem(m_ItemID).PermsMask = 0; part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; - AsyncCommandManager async = (AsyncCommandManager)m_Engine.AsyncCommands; - async.RemoveScript(m_LocalID, m_ItemID); + AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID); m_EventQueue.Clear(); m_Script.ResetVars(); m_State = "default"; @@ -717,8 +715,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance SceneObjectPart part=m_Engine.World.GetSceneObjectPart(m_LocalID); part.GetInventoryItem(m_ItemID).PermsMask = 0; part.GetInventoryItem(m_ItemID).PermsGranter = UUID.Zero; - AsyncCommandManager async = (AsyncCommandManager)m_Engine.AsyncCommands; - async.RemoveScript(m_LocalID, m_ItemID); + AsyncCommandManager.RemoveScript(m_Engine.World, m_LocalID, m_ItemID); m_EventQueue.Clear(); m_Script.ResetVars(); @@ -775,8 +772,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance return; } - AsyncCommandManager async = (AsyncCommandManager)m_Engine.AsyncCommands; - PluginData = async.GetSerializationData(m_ItemID); + PluginData = AsyncCommandManager.GetSerializationData(m_Engine.World, m_ItemID); string xml = ScriptSerializer.Serialize(this); diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index a6416c67eb..2e5c62772a 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -76,7 +76,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine #pragma warning restore 414 private int m_EventLimit; private bool m_KillTimedOutScripts; - private AsyncCommandManager m_AsyncCommands; bool m_firstStart = true; private static List m_ScriptEngines = @@ -142,11 +141,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine get { return m_ScriptConfig; } } - public Object AsyncCommands - { - get { return (Object)m_AsyncCommands; } - } - // // IRegionModule functions // @@ -239,8 +233,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_Scene.EventManager.OnStopScript += OnStopScript; m_Scene.EventManager.OnShutdown += OnShutdown; - m_AsyncCommands = new AsyncCommandManager(this); - if (m_SleepTime > 0) { m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance), @@ -574,8 +566,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (!m_Scripts.ContainsKey(itemID)) return; - m_AsyncCommands.RemoveScript(localID, itemID); - IScriptInstance instance=m_Scripts[itemID]; m_Scripts.Remove(itemID);