Ejemplo n.º 1
0
        /// <summary>
        /// Adds an event to the interest list
        /// </summary>
        /// <param name="eventData">Event to add</param>
        /// <param name="handler">Collection of callbacks that will handle this
        /// event</param>
        public void EnqueueEvent(InterestListEvent eventData, InterestListEventHandler handler)
        {
            double?priority = handler.PriorityCallback(eventData, m_presence);

            // If this event has a non-null priority for this presence, enqueue it
            if (priority.HasValue)
            {
                QueuedInterestListEvent qile = new QueuedInterestListEvent(eventData, priority.Value, handler);

                lock (m_syncRoot)
                {
                    C5.PriorityQueueHandle handle;
                    if (m_eventIDs.TryGetValue(eventData.ID, out handle))
                    {
                        // An event with the same ID already exists in the priority queue. Combine this update with the previous one
                        qile = handler.CombineCallback(m_eventHeap[handle], qile);
                        m_eventHeap.Replace(handle, qile);
                    }
                    else
                    {
                        // This event ID is new
                        m_eventHeap.Add(ref handle, qile);
                        m_eventIDs.Add(eventData.ID, handle);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void CreateInterestListEventFor(IScenePresence presence, InterestListEvent eventData)
 {
     if (presence.InterestList != null)
     {
         InterestListEventHandler handler;
         if (TryGetInterestListHandler(eventData.Type, out handler))
         {
             presence.InterestList.EnqueueEvent(eventData, handler);
         }
     }
 }
Ejemplo n.º 3
0
        public void CreateInterestListEvent(InterestListEvent eventData)
        {
            InterestListEventHandler handler;

            if (TryGetInterestListHandler(eventData.Type, out handler))
            {
                ForEachPresence(
                    delegate(IScenePresence presence)
                {
                    // TODO: Once we have semi-complete implementations of multiple protocols,
                    // we'll probably want to filter events here to avoid stuffing a bunch of
                    // cross-protocol events into the wrong queues
                    if (presence.InterestList != null)
                    {
                        presence.InterestList.EnqueueEvent(eventData, handler);
                    }
                }
                    );
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public QueuedInterestListEvent(InterestListEvent eventData, double priority, InterestListEventHandler handler)
 {
     Event    = eventData;
     Priority = priority;
     Handler  = handler;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// The default prioritizer for interest list events. Returns the
 /// squared distance between the event and the target presence
 /// </summary>
 public static double?DefaultPrioritizer(InterestListEvent eventData, IScenePresence presence)
 {
     // A simple distance-based prioritizer
     return(Vector3.DistanceSquared(presence.ScenePosition, eventData.ScenePosition));
 }