public FetchInventory2ServerConnector(IConfigSource config, IHttpServer server, string configName)
            : base(config, server, configName)
        {
            if (configName != String.Empty)
                m_ConfigName = configName;

            IConfig serverConfig = config.Configs[m_ConfigName];
            if (serverConfig == null)
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));

            string invService = serverConfig.GetString("InventoryService", String.Empty);

            if (invService == String.Empty)
                throw new Exception("No InventoryService in config file");

            Object[] args = new Object[] { config };
            m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);

            if (m_InventoryService == null)
                throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName));

            FetchInventory2Handler fiHandler = new FetchInventory2Handler(m_InventoryService);
            IRequestHandler reqHandler
                = new RestStreamHandler("POST", "/CAPS/FetchInventory/", fiHandler.FetchInventoryRequest);
            server.AddStreamHandler(reqHandler);
        }
Beispiel #2
0
        public FetchInventory2ServerConnector(IConfigSource config, IHttpServer server, string configName)
            : base(config, server, configName)
        {
            if (configName != String.Empty)
            {
                m_ConfigName = configName;
            }

            IConfig serverConfig = config.Configs[m_ConfigName];

            if (serverConfig == null)
            {
                throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
            }

            string invService = serverConfig.GetString("InventoryService", String.Empty);

            if (invService == String.Empty)
            {
                throw new Exception("No InventoryService in config file");
            }

            Object[] args = new Object[] { config };
            m_InventoryService = ServerUtils.LoadPlugin <IInventoryService>(invService, args);

            if (m_InventoryService == null)
            {
                throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName));
            }

            FetchInventory2Handler fiHandler = new FetchInventory2Handler(m_InventoryService, UUID.Zero);
            IRequestHandler        reqHandler
                = new RestStreamHandler(
                      "POST", "/CAPS/FetchInventory/", fiHandler.FetchInventoryRequest, "FetchInventory", null);

            server.AddStreamHandler(reqHandler);
        }
        public void RegionLoaded(Scene s)
        {
            if (!Enabled)
                return;

            m_inventoryService = m_scene.InventoryService;

            // We'll reuse the same handler for all requests.
            if (m_fetchInventory2Url == "localhost")
                m_fetchHandler = new FetchInventory2Handler(m_inventoryService);

            m_scene.EventManager.OnRegisterCaps += RegisterCaps;
        }
        public void Test_002_RequestMany()
        {
            TestHelpers.InMethod();

            Init();

            FetchInventory2Handler handler = new FetchInventory2Handler(m_scene.InventoryService, m_userID);
            TestOSHttpRequest req = new TestOSHttpRequest();
            TestOSHttpResponse resp = new TestOSHttpResponse();

            string request = "<llsd><map><key>items</key><array>";
            request += "<map><key>item_id</key><uuid>10000000-0000-0000-0000-000000000001</uuid></map>"; // Notecard 1
            request += "<map><key>item_id</key><uuid>10000000-0000-0000-0000-000000000002</uuid></map>"; // Notecard 2
            request += "<map><key>item_id</key><uuid>10000000-0000-0000-0000-000000000003</uuid></map>"; // Notecard 3
            request += "<map><key>item_id</key><uuid>10000000-0000-0000-0000-000000000004</uuid></map>"; // Notecard 4
            request += "<map><key>item_id</key><uuid>10000000-0000-0000-0000-000000000005</uuid></map>"; // Notecard 5
            request += "</array></map></llsd>";

            string llsdresponse = handler.FetchInventoryRequest(request, "/FETCH", string.Empty, req, resp);

            Assert.That(llsdresponse != null, Is.True, "Incorrect null response");
            Assert.That(llsdresponse != string.Empty, Is.True, "Incorrect empty response");
            Assert.That(llsdresponse.Contains(m_userID.ToString()), Is.True, "Response should contain userID");

            Console.WriteLine(llsdresponse);
            Assert.That(llsdresponse.Contains("10000000-0000-0000-0000-000000000001"), Is.True, "Response does not contain notecard 1");
            Assert.That(llsdresponse.Contains("10000000-0000-0000-0000-000000000002"), Is.True, "Response does not contain notecard 2");
            Assert.That(llsdresponse.Contains("10000000-0000-0000-0000-000000000003"), Is.True, "Response does not contain notecard 3");
            Assert.That(llsdresponse.Contains("10000000-0000-0000-0000-000000000004"), Is.True, "Response does not contain notecard 4");
            Assert.That(llsdresponse.Contains("10000000-0000-0000-0000-000000000005"), Is.True, "Response does not contain notecard 5");
        }
        private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url)
        {
            string capUrl;

            if (url == "localhost")
            {
                capUrl = "/CAPS/" + UUID.Random();

                FetchInventory2Handler fetchHandler = new FetchInventory2Handler(m_inventoryService, agentID);

                IRequestHandler reqHandler
                    = new RestStreamHandler(
                        "POST", capUrl, fetchHandler.FetchInventoryRequest, capName, agentID.ToString());

                caps.RegisterHandler(capName, reqHandler);
            }
            else
            {
                capUrl = url;

                caps.RegisterHandler(capName, capUrl);
            }

//            m_log.DebugFormat(
//                "[FETCH INVENTORY2 MODULE]: Registered capability {0} at {1} in region {2} for {3}",
//                capName, capUrl, m_scene.RegionInfo.RegionName, agentID);
        }