Add() public method

Adds to the end of the list, replacing any item with the same ID, or bumping the oldest item if the list is full.
public Add ( object value ) : int
value object PubSubItem to add to the list.
return int
Example #1
0
        private void GotItems(object sender, IQ iq, object state)
        {
            if (iq.Type != IQType.result)
            {
                FireError(Op.ITEMS, "Error retrieving items", iq);
                return;
            }

            PubSub ps = iq["pubsub", URI.PUBSUB] as PubSub;

            if (ps == null)
            {
                FireError(Op.ITEMS, "Invalid pubsub protocol", iq);
                return;
            }
            PubSubItemCommand items = ps["items", URI.PUBSUB] as PubSubItemCommand;

            if (items == null)
            {
                // That doesn't really hurt us, I guess.  No items.  Keep going.
                this[Op.ITEMS] = STATE.Running;
                return;
            }

            if (items.Node != m_node)
            {
                FireError(Op.ITEMS, "Non-matching node.  Probably a server bug.", iq);
                return;
            }

            foreach (PubSubItem item in items.GetItems())
            {
                m_items.Add(item);
            }

            this[Op.ITEMS] = STATE.Running;
        }
Example #2
0
        internal void FireItems(EventItems items)
        {
            // OK, it's for us.  Might be a new one or a retraction.
            // Shrug, even if we're sent a mix, it shouldn't hurt anything.

            /*
             * <message from='pubsub.shakespeare.lit' to='*****@*****.**' id='bar'>
             * <event xmlns='http://jabber.org/protocol/pubsub#event'>
             *  <items node='princely_musings'>
             *    <retract id='ae890ac52d0df67ed7cfdf51b644e901'/>
             *  </items>
             * </event>
             * </message>
             */
            foreach (string id in items.GetRetractions())
            {
                m_items.RemoveId(id);
            }

            foreach (PubSubItem item in items.GetItems())
            {
                m_items.Add(item);
            }
        }