예제 #1
0
 public void FireAdd(PubSubNode node, PubSubItem item)
 {
     if (OnAdd != null)
     {
         OnAdd(node, item);
     }
 }
예제 #2
0
 public void FireRemove(PubSubNode node, PubSubItem item)
 {
     if (OnRemove != null)
     {
         OnRemove(node, item);
     }
 }
예제 #3
0
 private void m_node_OnItemAdd(PubSubNode node, Jabber.Protocol.IQ.PubSubItem item)
 {
     // OnItemRemove should have fired first, so no reason to remove it here.
     // Hopefully.
     Debug.Assert(lbID.Items.IndexOf(item.ID) == -1);
     lbID.Items.Add(item.ID);
 }
예제 #4
0
 private void m_node_OnItemRemove(PubSubNode node, Jabber.Protocol.IQ.PubSubItem item)
 {
     int index = lbID.Items.IndexOf(item.ID);
     if (lbID.SelectedIndex == index)
         rtItem.Clear();
     if (index >= 0)
         lbID.Items.RemoveAt(index);
 }
예제 #5
0
        /// <summary>
        /// Subscribes to a publish-subscribe node.
        /// </summary>
        /// <param name="service">Component that handles PubSub requests.</param>
        /// <param name="node">The node on the component that the client wants to interact with.</param>
        /// <param name="maxItems">Maximum number of items to retain.  First one to call Subscribe gets their value, for now.</param>
        /// <returns>
        /// The existing node will be returned if there is already a subscription.
        /// If the node does not exist, the PubSubNode object will be returned
        /// in a subscribing state.
        /// </returns>
        public PubSubNode GetNode(JID service, string node, int maxItems)
        {
            JIDNode    jn = new JIDNode(service, node);
            PubSubNode n  = null;

            if (m_nodes.TryGetValue(jn, out n))
            {
                return(n);
            }
            n           = new PubSubNode(Stream, service, node, maxItems);
            m_nodes[jn] = n;
            n.OnError  += OnError;
            return(n);
        }
예제 #6
0
        private void m_stream_OnProtocol(object sender, XmlElement rp)
        {
            Message msg = rp as Message;

            if (msg == null)
            {
                return;
            }
            PubSubEvent evt = msg["event", URI.PUBSUB_EVENT] as PubSubEvent;

            if (evt == null)
            {
                return;
            }

            EventItems items = evt.GetChildElement <EventItems>();

            if (items == null)
            {
                return;
            }

            string     node = items.Node;
            JID        from = msg.From.BareJID;
            JIDNode    jn   = new JIDNode(from, node);
            PubSubNode psn  = null;

            if (!m_nodes.TryGetValue(jn, out psn))
            {
                CBHolder holder = null;
                if (!m_callbacks.TryGetValue(node, out holder))
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                                                    "WARNING: notification received for unknown pubsub node: {0}",
                                                    node));
                    return;
                }
                psn               = new PubSubNode(m_stream, from, node, holder.Max);
                psn.OnItemAdd    += holder.FireAdd;
                psn.OnItemRemove += holder.FireRemove;
                m_nodes[jn]       = psn;
            }
            psn.FireItems(items);
        }
예제 #7
0
        ///<summary>
        /// Removes the publish-subscribe node from the manager and sends a delete
        /// node to the XMPP server.
        ///</summary>
        /// <param name="service">
        /// Component that handles PubSub requests.
        /// </param>
        /// <param name="node">
        /// The node on the component that the client wants to interact with.
        /// </param>
        /// <param name="errorHandler">
        /// Callback for any errors with the publish-subscribe node deletion.
        /// </param>
        public void RemoveNode(JID service, string node, Bedrock.ExceptionHandler errorHandler)
        {
            JIDNode jn = new JIDNode(service, node);

            PubSubNode psNode = null;

            if (m_nodes.TryGetValue(jn, out psNode))
            {
                m_nodes.Remove(jn);
            }
            else
            {
                psNode = new PubSubNode(Stream, service, node, 10);
            }

            psNode.OnError += errorHandler;

            psNode.Delete();
        }
예제 #8
0
        private void m_stream_OnProtocol(object sender, XmlElement rp)
        {
            Message msg = rp as Message;
            if (msg == null)
                return;
            PubSubEvent evt = msg["event", URI.PUBSUB_EVENT] as PubSubEvent;
            if (evt == null)
                return;

            EventItems items = evt.GetChildElement<EventItems>();
            if (items == null)
                return;

            string node = items.Node;
            JID from = msg.From.BareJID;
            JIDNode jn = new JIDNode(from, node);
            PubSubNode psn = null;
            if (!m_nodes.TryGetValue(jn, out psn))
            {
                CBHolder holder = null;
                if (!m_callbacks.TryGetValue(node, out holder))
                {
                    Console.WriteLine(String.Format(CultureInfo.CurrentCulture,
                                                    "WARNING: notification received for unknown pubsub node: {0}",
                                                    node));
                    return;
                }
                psn = new PubSubNode(m_stream, from, node, holder.Max);
                psn.OnItemAdd += holder.FireAdd;
                psn.OnItemRemove += holder.FireRemove;
                m_nodes[jn] = psn;
            }
            psn.FireItems(items);
        }
예제 #9
0
 public void FireRemove(PubSubNode node, PubSubItem item)
 {
     if (OnRemove != null)
         OnRemove(node, item);
 }
예제 #10
0
 public void FireAdd(PubSubNode node, PubSubItem item)
 {
     if (OnAdd != null)
         OnAdd(node, item);
 }
예제 #11
0
 /// <summary>
 /// Creates an item list, which will have at most some number of items.
 /// </summary>
 /// <param name="node">The node to which this item list applies.</param>
 /// <param name="maxItems">Maximum size of the list.  Delete notifications will be sent if this size is exceeded.</param>
 public ItemList(PubSubNode node, int maxItems) : base(maxItems)
 {
     m_node = node;
 }
예제 #12
0
        ///<summary>
        /// Removes the publish-subscribe node from the manager and sends a delete
        /// node to the XMPP server.
        ///</summary>
        /// <param name="service">
        /// Component that handles PubSub requests.
        /// </param>
        /// <param name="node">
        /// The node on the component that the client wants to interact with.
        /// </param>
        /// <param name="errorHandler">
        /// Callback for any errors with the publish-subscribe node deletion.
        /// </param>
        public void RemoveNode(JID service, string node, Bedrock.ExceptionHandler errorHandler)
        {
            JIDNode jn = new JIDNode(service, node);

            PubSubNode psNode = null;
            if (m_nodes.TryGetValue(jn, out psNode))
            {
                m_nodes.Remove(jn);
            }
            else
            {
                psNode = new PubSubNode(Stream, service, node, 10);
            }

            psNode.OnError += errorHandler;

            psNode.Delete();
        }
예제 #13
0
 /// <summary>
 /// Subscribes to a publish-subscribe node.
 /// </summary>
 /// <param name="service">Component that handles PubSub requests.</param>
 /// <param name="node">The node on the component that the client wants to interact with.</param>
 /// <param name="maxItems">Maximum number of items to retain.  First one to call Subscribe gets their value, for now.</param>
 /// <returns>
 /// The existing node will be returned if there is already a subscription.
 /// If the node does not exist, the PubSubNode object will be returned
 /// in a subscribing state.
 /// </returns>
 public PubSubNode GetNode(JID service, string node, int maxItems)
 {
     JIDNode jn = new JIDNode(service, node);
     PubSubNode n = null;
     if (m_nodes.TryGetValue(jn, out n))
         return n;
     n = new PubSubNode(Stream, service, node, maxItems);
     m_nodes[jn] = n;
     n.OnError += OnError;
     return n;
 }
예제 #14
0
 /// <summary>
 /// Creates an item list, which will have at most some number of items.
 /// </summary>
 /// <param name="node">The node to which this item list applies.</param>
 /// <param name="maxItems">Maximum size of the list.  Delete notifications will be sent if this size is exceeded.</param>
 public ItemList(PubSubNode node, int maxItems) : base(maxItems)
 {
     m_node = node;
 }