Пример #1
0
        public void OnRegisterCaps(UUID agentID, Caps caps)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
                m_log.DebugFormat("agentID {0} caps {1} region {2}", agentID, caps, m_scene.RegionInfo.RegionName);
            }
            // Register an event queue for the client


            // Let's instantiate a Queue for this agent right now
            TryGetQueue(agentID);

            UUID eventQueueGetUUID;

            lock (m_AvatarQueueUUIDMapping)
            {
                // Reuse open queues.  The client does!
                if (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                {
                    //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
                    eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
                }
                else
                {
                    eventQueueGetUUID = UUID.Random();
                    //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!");
                }
            }

            lock (m_QueueUUIDAvatarMapping)
            {
                if (!m_QueueUUIDAvatarMapping.ContainsKey(eventQueueGetUUID))
                {
                    m_QueueUUIDAvatarMapping.Add(eventQueueGetUUID, agentID);
                }
            }

            lock (m_AvatarQueueUUIDMapping)
            {
                if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                {
                    m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
                }
            }

            caps.RegisterPollHandler(
                "EventQueueGet",
                new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS));

            Random rnd = new Random(Environment.TickCount);

            lock (m_ids)
            {
                if (!m_ids.ContainsKey(agentID))
                {
                    m_ids.Add(agentID, rnd.Next(30000000));
                }
            }
        }
Пример #2
0
        public void OnRegisterCaps(UUID agentID, Caps caps)
        {
            // Register an event queue for the client

            m_log.DebugFormat(
                "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
                agentID, caps, m_scene.RegionInfo.RegionName);

            // Let's instantiate a Queue for this agent right now
            TryGetQueue(agentID);

            UUID eventQueueGetUUID;

            eventQueueGetUUID = m_AvatarQueueUUIDMapping.GetOrAddIfNotExists(agentID, delegate() { return(UUID.Random()); });

            m_QueueUUIDAvatarMapping[eventQueueGetUUID] = agentID;
            m_AvatarQueueUUIDMapping[agentID]           = eventQueueGetUUID;

            caps.RegisterPollHandler(
                "EventQueueGet",
                new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS));

            Random rnd = new Random(Environment.TickCount);

            try
            {
                m_ids.AddIfNotExists(agentID, delegate() { return(rnd.Next(30000000)); });
            }
            catch (ThreadedClasses.RwLockedDictionary <UUID, int> .KeyAlreadyExistsException)
            {
            }
        }
Пример #3
0
        private void RegisterFetchDescendentsCap(UUID agentID, Caps caps, string capName, string url)
        {
            string capUrl;

            // disable the cap clause
            if (url == "")
            {
                return;
            }
            // handled by the simulator
            else if (url == "localhost")
            {
                capUrl = "/" + UUID.Random();

                // Register this as a poll service
                PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(this, capUrl, agentID);
                //args.Type = PollServiceEventArgs.EventType.Inventory;

                caps.RegisterPollHandler(capName, args);
            }
            // external handler
            else
            {
                capUrl = url;
                IExternalCapsModule handler = Scene.RequestModuleInterface <IExternalCapsModule>();
                if (handler != null)
                {
                    handler.RegisterExternalUserCapsHandler(agentID, caps, capName, capUrl);
                }
                else
                {
                    caps.RegisterHandler(capName, capUrl);
                }
            }
        }
        public void OnRegisterCaps(UUID agentID, Caps caps)
        {
            // Register an event queue for the client

            m_log.DebugFormat(
                "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
                agentID, caps, m_scene.RegionInfo.RegionName);

            // Let's instantiate a Queue for this agent right now
            TryGetQueue(agentID);

            UUID eventQueueGetUUID;

            eventQueueGetUUID = m_AvatarQueueUUIDMapping.GetOrAddIfNotExists(agentID, delegate() { return UUID.Random(); });

            m_QueueUUIDAvatarMapping[eventQueueGetUUID] = agentID;
            m_AvatarQueueUUIDMapping[agentID] = eventQueueGetUUID;

            caps.RegisterPollHandler(
                "EventQueueGet",
                new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS));

            Random rnd = new Random(Environment.TickCount);
            try
            {
                m_ids.AddIfNotExists(agentID, delegate() { return rnd.Next(30000000); });
            }
            catch(ThreadedClasses.RwLockedDictionary<UUID, int>.KeyAlreadyExistsException)
            {

            }
        }
Пример #5
0
        public void OnRegisterCaps(UUID agentID, Caps caps)
        {
            // Register an event queue for the client

            if (DebugLevel > 0)
                m_log.DebugFormat(
                    "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
                    agentID, caps, m_scene.RegionInfo.RegionName);

            // Let's instantiate a Queue for this agent right now
            TryGetQueue(agentID);

            UUID eventQueueGetUUID;

            lock (m_AvatarQueueUUIDMapping)
            {
                // Reuse open queues.  The client does!
                if (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                {
                    //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
                    eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
                }
                else
                {
                    eventQueueGetUUID = UUID.Random();
                    //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!");
                }
            }

            lock (m_QueueUUIDAvatarMapping)
            {
                if (!m_QueueUUIDAvatarMapping.ContainsKey(eventQueueGetUUID))
                    m_QueueUUIDAvatarMapping.Add(eventQueueGetUUID, agentID);
            }

            lock (m_AvatarQueueUUIDMapping)
            {
                if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                    m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
            }

            caps.RegisterPollHandler(
                "EventQueueGet",
                new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS));

            Random rnd = new Random(Environment.TickCount);
            lock (m_ids)
            {
                if (!m_ids.ContainsKey(agentID))
                    m_ids.Add(agentID, rnd.Next(30000000));
            }
        }
Пример #6
0
        public void OnRegisterCaps(UUID agentID, Caps caps)
        {
            // Register an event queue for the client

            if (DebugLevel > 0)
                m_log.DebugFormat(
                    "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
                    agentID, caps, m_scene.RegionInfo.RegionName);

            UUID eventQueueGetUUID;
            Queue<OSD> queue;
            Random rnd = new Random(Environment.TickCount);
            int nrnd = rnd.Next(30000000);
            if (nrnd < 0)
                nrnd = -nrnd;

            lock (queues)
            {
                if (queues.ContainsKey(agentID))
                    queue = queues[agentID];
                else
                    queue = null;

                if (queue == null)
                {
                    queue = new Queue<OSD>();
                    queues[agentID] = queue;

                    // push markers to handle old responses still waiting
                    // this will cost at most viewer getting two forced noevents
                    // even being a new queue better be safe 
                    queue.Enqueue(null);
                    queue.Enqueue(null); // one should be enough
                    
                    lock (m_AvatarQueueUUIDMapping)
                    {
                        eventQueueGetUUID = UUID.Random();
                        if (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                        {
                            // oops this should not happen ?
                            m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID without a queue");
                            eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
                        }
                        m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
                    }
                    lock (m_ids)
                    {
                        if (!m_ids.ContainsKey(agentID))
                            m_ids.Add(agentID, nrnd);
                        else
                            m_ids[agentID] = nrnd;
                    }
                }
                else
                {
                    // push markers to handle old responses still waiting
                    // this will cost at most viewer getting two forced noevents
                    // even being a new queue better be safe 
                    queue.Enqueue(null);
                    queue.Enqueue(null); // one should be enough

                    // reuse or not to reuse TODO FIX
                    lock (m_AvatarQueueUUIDMapping)
                    {
                        // Reuse open queues.  The client does!
                        // Its reuse caps path not queues those are been reused already
                        if (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                        {
                            m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
                            eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
                        }
                        else
                        {
                            eventQueueGetUUID = UUID.Random();
                            m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
                            m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!");
                        }
                    }
                    lock (m_ids)
                    {
                        // change to negative numbers so they are changed at end of sending first marker
                        // old data on a queue may be sent on a response for a new caps
                        // but at least will be sent with coerent IDs
                        if (!m_ids.ContainsKey(agentID))
                            m_ids.Add(agentID, -nrnd); // should not happen
                        else
                            m_ids[agentID] = -m_ids[agentID];
                    }
                }
            }

            caps.RegisterPollHandler(
                "EventQueueGet",
                new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS));
        }
Пример #7
0
        public void OnRegisterCaps(UUID agentID, Caps caps)
        {
            // Register an event queue for the client

            if (DebugLevel > 0)
            {
                m_log.DebugFormat(
                    "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
                    agentID, caps, m_scene.RegionInfo.RegionName);
            }

            UUID        eventQueueGetUUID;
            Queue <OSD> queue;
            Random      rnd  = new Random(Environment.TickCount);
            int         nrnd = rnd.Next(30000000);

            lock (queues)
            {
                if (queues.ContainsKey(agentID))
                {
                    queue = queues[agentID];
                }
                else
                {
                    queue = null;
                }

                if (queue == null)
                {
                    queue           = new Queue <OSD>();
                    queues[agentID] = queue;

                    lock (m_AvatarQueueUUIDMapping)
                    {
                        eventQueueGetUUID = UUID.Random();
                        while (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                        {
                            eventQueueGetUUID = UUID.Random();
                        }
                        m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
                    }
                    lock (m_ids)
                    {
                        if (!m_ids.ContainsKey(agentID))
                        {
                            m_ids.Add(agentID, nrnd);
                        }
                        else
                        {
                            m_ids[agentID]++;
                        }
                    }
                }
                else
                {
                    queue.Enqueue(null);
                    queue.Enqueue(null); // one should be enough
                    // reuse or not to reuse
                    lock (m_AvatarQueueUUIDMapping)
                    {
                        // Reuse open queues.  The client does!
                        // Its reuse caps path not queues those are been reused already
                        if (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                        {
                            m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
                            eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
                            lock (m_ids)
                            {
                                // change to negative numbers so they are changed at end of sending first marker
                                // old data on a queue may be sent on a response for a new caps
                                // but at least will be sent with coerent IDs
                                if (!m_ids.ContainsKey(agentID))
                                {
                                    m_ids.Add(agentID, -nrnd); // should not happen
                                }
                                else
                                {
                                    m_ids[agentID] = -m_ids[agentID];
                                }
                            }
                        }
                        else
                        {
                            eventQueueGetUUID = UUID.Random();
                            while (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                            {
                                eventQueueGetUUID = UUID.Random();
                            }
                            m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID);
                            m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!");
                            lock (m_ids)
                            {
                                if (!m_ids.ContainsKey(agentID))
                                {
                                    m_ids.Add(agentID, nrnd);
                                }
                                else
                                {
                                    m_ids[agentID]++;
                                }
                            }
                        }
                    }
                }
            }

            caps.RegisterPollHandler(
                "EventQueueGet",
                new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, Drop, agentID, SERVER_EQ_TIME_NO_EVENTS));
        }
Пример #8
0
        public void RegisterCaps(UUID agentID, Caps caps)
        {
            string hostName = m_scene.RegionInfo.ExternalHostName;
            uint   port     = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
            string protocol = "http";

            if (MainServer.Instance.UseSSL)
            {
                hostName = MainServer.Instance.SSLCommonName;
                port     = MainServer.Instance.SSLPort;
                protocol = "https";
            }

            string hgassets = null;

            if (m_UserManagement != null)
            {
                hgassets = m_UserManagement.GetUserServerURL(agentID, "AssetServerURI");
            }

            IExternalCapsModule handler = m_scene.RequestModuleInterface <IExternalCapsModule>();
            string baseURL = String.Format("{0}://{1}:{2}", protocol, hostName, port);

            if (m_GetTextureURL == "localhost")
            {
                string capUrl = "/" + UUID.Random();

                // Register this as a poll service
                PollServiceAssetEventArgs args = new PollServiceAssetEventArgs(capUrl, agentID, m_scene, hgassets);

                if (handler != null)
                {
                    handler.RegisterExternalUserCapsHandler(agentID, caps, "GetTexture", capUrl);
                }
                else
                {
                    caps.RegisterPollHandler("GetTexture", args);
                }
            }
            else
            {
                caps.RegisterHandler("GetTexture", m_GetTextureURL);
            }

            //GetMesh
            if (m_GetMeshURL == "localhost")
            {
                string capUrl = "/" + UUID.Random();

                PollServiceAssetEventArgs args = new PollServiceAssetEventArgs(capUrl, agentID, m_scene, hgassets);

                if (handler != null)
                {
                    handler.RegisterExternalUserCapsHandler(agentID, caps, "GetMesh", capUrl);
                }
                else
                {
                    caps.RegisterPollHandler("GetMesh", args);
                }
            }
            else if (m_GetMeshURL != string.Empty)
            {
                caps.RegisterHandler("GetMesh", m_GetMeshURL);
            }

            //GetMesh2
            if (m_GetMesh2URL == "localhost")
            {
                string capUrl = "/" + UUID.Random();

                PollServiceAssetEventArgs args = new PollServiceAssetEventArgs(capUrl, agentID, m_scene, hgassets);

                if (handler != null)
                {
                    handler.RegisterExternalUserCapsHandler(agentID, caps, "GetMesh2", capUrl);
                }
                else
                {
                    caps.RegisterPollHandler("GetMesh2", args);
                }
            }
            else if (m_GetMesh2URL != string.Empty)
            {
                caps.RegisterHandler("GetMesh2", m_GetMesh2URL);
            }

            //ViewerAsset
            if (m_GetAssetURL == "localhost")
            {
                string capUrl = "/" + UUID.Random();

                PollServiceAssetEventArgs args = new PollServiceAssetEventArgs(capUrl, agentID, m_scene, hgassets);

                if (handler != null)
                {
                    handler.RegisterExternalUserCapsHandler(agentID, caps, "ViewerAsset", capUrl);
                }
                else
                {
                    caps.RegisterPollHandler("ViewerAsset", args);
                }
            }
            else if (m_GetAssetURL != string.Empty)
            {
                caps.RegisterHandler("ViewerAsset", m_GetAssetURL);
            }
        }
Пример #9
0
        public void OnRegisterCaps(UUID agentID, Caps caps)
        {
            // Register an event queue for the client

            if (DebugLevel > 0)
            {
                m_log.DebugFormat(
                    "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
                    agentID, caps, m_scene.RegionInfo.RegionName);
            }

            UUID           eventQueueGetUUID;
            Queue <Byte[]> queue = null;

            lock (queues)
            {
                queues.TryGetValue(agentID, out queue);

                if (queue == null)
                {
                    queue           = new Queue <byte[]>();
                    queues[agentID] = queue;

                    lock (m_AvatarQueueUUIDMapping)
                    {
                        eventQueueGetUUID = UUID.Random();
                        m_AvatarQueueUUIDMapping[agentID] = eventQueueGetUUID;
                        lock (m_ids)
                        {
                            if (m_ids.ContainsKey(agentID))
                            {
                                m_ids[agentID]++;
                            }
                            else
                            {
                                Random rnd = new Random(Environment.TickCount);
                                m_ids[agentID] = rnd.Next(30000000);
                            }
                        }
                    }
                }
                else
                {
                    queue.Enqueue(null);

                    // reuse or not to reuse
                    lock (m_AvatarQueueUUIDMapping)
                    {
                        // Its reuse caps path not queues those are been reused already
                        if (m_AvatarQueueUUIDMapping.ContainsKey(agentID))
                        {
                            m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!");
                            eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID];
                            lock (m_ids)
                            {
                                // change to negative numbers so they are changed at end of sending first marker
                                // old data on a queue may be sent on a response for a new caps
                                // but at least will be sent with coerent IDs
                                if (m_ids.ContainsKey(agentID))
                                {
                                    m_ids[agentID] = -m_ids[agentID];
                                }
                                else
                                {
                                    Random rnd = new Random(Environment.TickCount);
                                    m_ids[agentID] = -rnd.Next(30000000);
                                }
                            }
                        }
                        else
                        {
                            eventQueueGetUUID = UUID.Random();
                            m_AvatarQueueUUIDMapping[agentID] = eventQueueGetUUID;
                            lock (m_ids)
                            {
                                if (m_ids.ContainsKey(agentID))
                                {
                                    m_ids[agentID]++;
                                }
                                else
                                {
                                    Random rnd = new Random(Environment.TickCount);
                                    m_ids.Add(agentID, rnd.Next(30000000));
                                }
                            }
                        }
                    }
                }
            }

            caps.RegisterPollHandler(
                "EventQueueGet",
                new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, Drop, agentID, VIEWERKEEPALIVE));
        }