Esempio n. 1
0
        public bool Enqueue(OSD ev, UUID avatarID)
        {
            //m_log.DebugFormat("[EVENTQUEUE]: Enqueuing event for {0} in region {1}", avatarID, m_scene.RegionInfo.RegionName);
            try
            {
                ThreadedClasses.BlockingQueue <OSD> queue = GetQueue(avatarID);
                if (queue != null)
                {
                    queue.Enqueue(ev);
                }
                else if (DebugLevel > 0)
                {
                    ScenePresence sp = m_scene.GetScenePresence(avatarID);

                    // This assumes that an NPC should never have a queue.
                    if (sp != null && sp.PresenceType != PresenceType.Npc)
                    {
                        OSDMap evMap = (OSDMap)ev;
                        m_log.WarnFormat(
                            "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} {1} when placing message {2} in region {3}",
                            sp.Name, sp.UUID, evMap["message"], m_scene.Name);
                    }
                }
            }
            catch (NullReferenceException e)
            {
                m_log.Error("[EVENTQUEUE] Caught exception: " + e);
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
 /// <summary>
 /// May return a null queue
 /// </summary>
 /// <param name="agentId"></param>
 /// <returns></returns>
 private ThreadedClasses.BlockingQueue <OSD> GetQueue(UUID agentId)
 {
     ThreadedClasses.BlockingQueue <OSD> queue = null;
     if (queues.TryGetValue(agentId, out queue))
     {
         return(queue);
     }
     return(null);
 }
Esempio n. 3
0
        public bool HasEvents(UUID requestID, UUID agentID)
        {
            ThreadedClasses.BlockingQueue <OSD> queue = GetQueue(agentID);
            if (queue != null)
            {
                //m_log.WarnFormat("POLLED FOR EVENTS BY {0} in {1} -- {2}", agentID, m_scene.RegionInfo.RegionName, queue.Count);
                return(queue.Count > 0);
            }

            return(false);
        }
Esempio n. 4
0
        public Hashtable GetEvents(UUID requestID, UUID pAgentId)
        {
            if (DebugLevel >= 2)
            {
                m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.Name);
            }

            ThreadedClasses.BlockingQueue <OSD> queue = GetQueue(pAgentId);
            if (queue == null)
            {
                return(NoEvents(requestID, pAgentId));
            }

            OSD element;

            try
            {
                element = queue.Dequeue(15000);
            }
            catch
            {
                return(NoEvents(requestID, pAgentId));
            }

            int thisID = m_ids[pAgentId];

            OSDArray array = new OSDArray();

            if (element == null) // didn't have an event in 15s
            {
                // Send it a fake event to keep the client polling!   It doesn't like 502s like the proxys say!
                array.Add(EventQueueHelper.KeepAliveEvent());
                //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName);
            }
            else
            {
                if (DebugLevel > 0)
                {
                    LogOutboundDebugMessage(element, pAgentId);
                }

                array.Add(element);

                lock (queue) /* we use this here to get the inner code race condition safe, NonblockingQueue tolerates this */
                {
                    while (queue.Count > 0)
                    {
                        element = queue.Dequeue();

                        if (DebugLevel > 0)
                        {
                            LogOutboundDebugMessage(element, pAgentId);
                        }

                        array.Add(element);
                        thisID++;
                    }
                }
            }

            OSDMap events = new OSDMap();

            events.Add("events", array);

            events.Add("id", new OSDInteger(thisID));
            m_ids[pAgentId] = thisID + 1;
            Hashtable responsedata = new Hashtable();

            responsedata["int_response_code"]   = 200;
            responsedata["content_type"]        = "application/xml";
            responsedata["keepalive"]           = false;
            responsedata["reusecontext"]        = false;
            responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
            //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
            return(responsedata);
        }