Inheritance: INonSharedRegionModule, IScriptModule, IScriptEngine
        public void Init()
        {
            //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
//            Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
            m_xEngine = new XEngine();

            // Necessary to stop serialization complaining
            WorldCommModule wcModule = new WorldCommModule();

            IniConfigSource configSource = new IniConfigSource();

            IConfig startupConfig = configSource.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = configSource.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource);
            SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule);

            m_scene.EventManager.OnChatFromWorld += OnChatFromWorld;
            m_scene.StartScripts();
        }
Beispiel #2
0
        public EventManager(XEngine _ScriptEngine)
        {
            myScriptEngine = _ScriptEngine;

//            m_log.Info("[XEngine] Hooking up to server events");
            myScriptEngine.World.EventManager.OnAttach += attach;
            myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
            myScriptEngine.World.EventManager.OnObjectGrabbing += touch;
            myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
            myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;
            myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target;
            myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target;
            myScriptEngine.World.EventManager.OnScriptAtRotTargetEvent += at_rot_target;
            myScriptEngine.World.EventManager.OnScriptNotAtRotTargetEvent += not_at_rot_target;
            myScriptEngine.World.EventManager.OnScriptMovingStartEvent += moving_start;
            myScriptEngine.World.EventManager.OnScriptMovingEndEvent += moving_end;
            myScriptEngine.World.EventManager.OnScriptControlEvent += control;
            myScriptEngine.World.EventManager.OnScriptColliderStart += collision_start;
            myScriptEngine.World.EventManager.OnScriptColliding += collision;
            myScriptEngine.World.EventManager.OnScriptCollidingEnd += collision_end;
            myScriptEngine.World.EventManager.OnScriptLandColliderStart += land_collision_start;
            myScriptEngine.World.EventManager.OnScriptLandColliding += land_collision;
            myScriptEngine.World.EventManager.OnScriptLandColliderEnd += land_collision_end;
            IMoneyModule money = myScriptEngine.World.RequestModuleInterface<IMoneyModule>();
            if (money != null)
            {
                money.OnObjectPaid+=HandleObjectPaid;
            }
        }
Beispiel #3
0
        public EventManager(XEngine _ScriptEngine)
        {
            myScriptEngine = _ScriptEngine;

//            m_log.Info("[XEngine] Hooking up to server events");
            myScriptEngine.World.EventManager.OnAttach                    += attach;
            myScriptEngine.World.EventManager.OnObjectGrab                += touch_start;
            myScriptEngine.World.EventManager.OnObjectGrabbing            += touch;
            myScriptEngine.World.EventManager.OnObjectDeGrab              += touch_end;
            myScriptEngine.World.EventManager.OnScriptChangedEvent        += changed;
            myScriptEngine.World.EventManager.OnScriptAtTargetEvent       += at_target;
            myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent    += not_at_target;
            myScriptEngine.World.EventManager.OnScriptAtRotTargetEvent    += at_rot_target;
            myScriptEngine.World.EventManager.OnScriptNotAtRotTargetEvent += not_at_rot_target;
            myScriptEngine.World.EventManager.OnScriptMovingStartEvent    += moving_start;
            myScriptEngine.World.EventManager.OnScriptMovingEndEvent      += moving_end;
            myScriptEngine.World.EventManager.OnScriptControlEvent        += control;
            myScriptEngine.World.EventManager.OnScriptColliderStart       += collision_start;
            myScriptEngine.World.EventManager.OnScriptColliding           += collision;
            myScriptEngine.World.EventManager.OnScriptCollidingEnd        += collision_end;
            myScriptEngine.World.EventManager.OnScriptLandColliderStart   += land_collision_start;
            myScriptEngine.World.EventManager.OnScriptLandColliding       += land_collision;
            myScriptEngine.World.EventManager.OnScriptLandColliderEnd     += land_collision_end;
            IMoneyModule money = myScriptEngine.World.RequestModuleInterface <IMoneyModule>();

            if (money != null)
            {
                money.OnObjectPaid += HandleObjectPaid;
            }
        }
Beispiel #4
0
        public void Init()
        {
            m_osChatMessageReceived = null;
            m_chatMessagesReceived  = 0;
            m_chatMessagesThreshold = 0;
            m_chatEvent             = new AutoResetEvent(false);
            m_stoppedEvent          = new AutoResetEvent(false);

            //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
//            Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
            m_xEngine            = new OpenSim.Region.ScriptEngine.XEngine.XEngine();
            m_xEngine.DebugLevel = 1;

            IniConfigSource configSource = new IniConfigSource();

            IConfig startupConfig = configSource.AddConfig("Startup");

            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = configSource.AddConfig("XEngine");

            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            xEngineConfig.Set("ScriptStopStrategy", "co-op");

            // Make sure loops aren't actually being terminated by a script delay wait.
            xEngineConfig.Set("ScriptDelayFactor", 0);

            // This is really just set for debugging the test.
            xEngineConfig.Set("WriteScriptSourceToDebugFile", true);

            // Set to false if we need to debug test so the old scripts don't get wiped before each separate test
//            xEngineConfig.Set("DeleteScriptsOnStartup", false);

            // This is not currently used at all for co-op termination.  Bumping up to demonstrate that co-op termination
            // has an effect - without it tests will fail due to a 120 second wait for the event to finish.
            xEngineConfig.Set("WaitForEventCompletionOnScriptStop", 120000);

            IConfig config = configSource.AddConfig("OSSL");

            config.Set("DebuggerSafe", false);
            config.Set("AllowOSFunctions", "true");
            config.Set("OSFunctionThreatLevel", "Severe");

            m_scene = new SceneHelpers().SetupScene("My Test", TestHelpers.ParseTail(0x9999), 1000, 1000, configSource);
            SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine);
            m_scene.StartScripts();
        }
        private void AddScriptingConfig(IConfigSource config, XEngine.XEngine xEngine, List<object> modules)
        {
            IConfig startupConfig = config.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = config.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            modules.Add(xEngine);
        }
        private Scene CreateScriptingEnabledTestScene(XEngine.XEngine xEngine)
        {
            IConfigSource config = new IniConfigSource();
            List<object> modules = new List<object>();

            AddCommonConfig(config, modules);
            AddScriptingConfig(config, xEngine, modules);

            Scene scene
                = new SceneHelpers().SetupScene(
                    "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config);
            SceneHelpers.SetupSceneModules(scene, config, modules.ToArray());

            scene.StartScripts();

            return scene;
        }
        public void Init()
        {
            m_osChatMessageReceived = null;
            m_chatMessagesReceived = 0;
            m_chatMessagesThreshold = 0;
            m_chatEvent = new AutoResetEvent(false);
            m_stoppedEvent = new AutoResetEvent(false);

            //AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory + "/bin");
//            Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);
            m_xEngine = new OpenSim.Region.ScriptEngine.XEngine.XEngine();
            m_xEngine.DebugLevel = 1;

            IniConfigSource configSource = new IniConfigSource();
            
            IConfig startupConfig = configSource.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = configSource.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            xEngineConfig.Set("ScriptStopStrategy", "co-op");

            // Make sure loops aren't actually being terminated by a script delay wait.
            xEngineConfig.Set("ScriptDelayFactor", 0);

            // This is really just set for debugging the test.
            xEngineConfig.Set("WriteScriptSourceToDebugFile", true);

            // Set to false if we need to debug test so the old scripts don't get wiped before each separate test
//            xEngineConfig.Set("DeleteScriptsOnStartup", false);

            // This is not currently used at all for co-op termination.  Bumping up to demonstrate that co-op termination
            // has an effect - without it tests will fail due to a 120 second wait for the event to finish.
            xEngineConfig.Set("WaitForEventCompletionOnScriptStop", 120000);

            m_scene = new SceneHelpers().SetupScene("My Test", TestHelpers.ParseTail(0x9999), 1000, 1000, configSource);
            SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine);
            m_scene.StartScripts();
        }
Beispiel #8
0
        public void TestPostAssetRewrite()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            XEngine xengine = new OpenSim.Region.ScriptEngine.XEngine.XEngine();

            xengine.DebugLevel = 1;

            IniConfigSource configSource = new IniConfigSource();

            IConfig startupConfig = configSource.AddConfig("Startup");

            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = configSource.AddConfig("XEngine");

            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");
            xEngineConfig.Set("AppDomainLoading", "false");

            string homeUrl       = "http://hg.HomeTestPostAssetRewriteGrid.com";
            string foreignUrl    = "http://hg.ForeignTestPostAssetRewriteGrid.com";
            int    soIdTail      = 0x1;
            UUID   assetId       = TestHelpers.ParseTail(0x10);
            UUID   userId        = TestHelpers.ParseTail(0x100);
            UUID   sceneId       = TestHelpers.ParseTail(0x1000);
            string userFirstName = "TestPostAsset";
            string userLastName  = "Rewrite";
            int    soPartsCount  = 3;

            Scene scene = new SceneHelpers().SetupScene("TestPostAssetRewriteScene", sceneId, 1000, 1000, configSource);

            SceneHelpers.SetupSceneModules(scene, configSource, xengine);
            scene.StartScripts();

            HGAssetMapper hgam = new HGAssetMapper(scene, homeUrl);
            UserAccount   ua
                = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "password");

            SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, soPartsCount, ua.PrincipalID, "part", soIdTail);

            RezScript(
                scene, so.UUID, "default { state_entry() { llSay(0, \"Hello World\"); } }", "item1", ua.PrincipalID);

            AssetBase asset = AssetHelpers.CreateAsset(assetId, so);

            asset.CreatorID = foreignUrl;
            hgam.PostAsset(foreignUrl, asset);

            // Check transformed asset.
            AssetBase ncAssetGet = scene.AssetService.Get(assetId.ToString());

            Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID);
            string      xmlData          = Utils.BytesToString(ncAssetGet.Data);
            XmlDocument ncAssetGetXmlDoc = new XmlDocument();

            ncAssetGetXmlDoc.XmlResolver = null;
            ncAssetGetXmlDoc.LoadXml(xmlData);

//            Console.WriteLine(ncAssetGetXmlDoc.OuterXml);

            XmlNodeList creatorDataNodes = ncAssetGetXmlDoc.GetElementsByTagName("CreatorData");

            Assert.AreEqual(soPartsCount, creatorDataNodes.Count);
            //Console.WriteLine("creatorDataNodes {0}", creatorDataNodes.Count);

            foreach (XmlNode creatorDataNode in creatorDataNodes)
            {
                Assert.AreEqual(
                    string.Format("{0};{1} {2}", homeUrl, ua.FirstName, ua.LastName), creatorDataNode.InnerText);
            }

            // Check that saved script nodes have attributes
            XmlNodeList savedScriptStateNodes = ncAssetGetXmlDoc.GetElementsByTagName("SavedScriptState");

            Assert.AreEqual(1, savedScriptStateNodes.Count);
            Assert.AreEqual(1, savedScriptStateNodes[0].Attributes.Count);
            XmlNode uuidAttribute = savedScriptStateNodes[0].Attributes.GetNamedItem("UUID");

            Assert.NotNull(uuidAttribute);
            // XXX: To check the actual UUID attribute we would have to do some work to retreive the UUID of the task
            // item created earlier.
        }
        public void TestPostAssetRewrite()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            XEngine xengine = new OpenSim.Region.ScriptEngine.XEngine.XEngine();
            xengine.DebugLevel = 1;

            IniConfigSource configSource = new IniConfigSource();

            IConfig startupConfig = configSource.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");

            IConfig xEngineConfig = configSource.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");
            xEngineConfig.Set("AppDomainLoading", "false");

            string homeUrl = "http://hg.HomeTestPostAssetRewriteGrid.com";
            string foreignUrl = "http://hg.ForeignTestPostAssetRewriteGrid.com";
            int soIdTail = 0x1;
            UUID assetId = TestHelpers.ParseTail(0x10);
            UUID userId = TestHelpers.ParseTail(0x100);
            UUID sceneId = TestHelpers.ParseTail(0x1000);
            string userFirstName = "TestPostAsset";
            string userLastName = "Rewrite";
            int soPartsCount = 3;

            Scene scene = new SceneHelpers().SetupScene("TestPostAssetRewriteScene", sceneId, 1000, 1000, configSource);
            SceneHelpers.SetupSceneModules(scene, configSource, xengine);
            scene.StartScripts();

            HGAssetMapper hgam = new HGAssetMapper(scene, homeUrl);
            UserAccount ua 
                = UserAccountHelpers.CreateUserWithInventory(scene, userFirstName, userLastName, userId, "password");

            SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, soPartsCount, ua.PrincipalID, "part", soIdTail);
            RezScript(
                scene, so.UUID, "default { state_entry() { llSay(0, \"Hello World\"); } }", "item1", ua.PrincipalID);

            AssetBase asset = AssetHelpers.CreateAsset(assetId, so);
            asset.CreatorID = foreignUrl;
            hgam.PostAsset(foreignUrl, asset);

            // Check transformed asset.
            AssetBase ncAssetGet = scene.AssetService.Get(assetId.ToString());
            Assert.AreEqual(foreignUrl, ncAssetGet.CreatorID);
            string xmlData = Utils.BytesToString(ncAssetGet.Data);
            XmlDocument ncAssetGetXmlDoc = new XmlDocument();
            ncAssetGetXmlDoc.LoadXml(xmlData);

//            Console.WriteLine(ncAssetGetXmlDoc.OuterXml);

            XmlNodeList creatorDataNodes = ncAssetGetXmlDoc.GetElementsByTagName("CreatorData");

            Assert.AreEqual(soPartsCount, creatorDataNodes.Count);
            //Console.WriteLine("creatorDataNodes {0}", creatorDataNodes.Count);

            foreach (XmlNode creatorDataNode in creatorDataNodes)
            {
                Assert.AreEqual(
                    string.Format("{0};{1} {2}", homeUrl, ua.FirstName, ua.LastName), creatorDataNode.InnerText);
            }

            // Check that saved script nodes have attributes
            XmlNodeList savedScriptStateNodes = ncAssetGetXmlDoc.GetElementsByTagName("SavedScriptState");

            Assert.AreEqual(1, savedScriptStateNodes.Count);
            Assert.AreEqual(1, savedScriptStateNodes[0].Attributes.Count);
            XmlNode uuidAttribute = savedScriptStateNodes[0].Attributes.GetNamedItem("UUID");
            Assert.NotNull(uuidAttribute);
            // XXX: To check the actual UUID attribute we would have to do some work to retreive the UUID of the task
            // item created earlier. 
        }