Inheritance: jabber.connection.StreamComponent, IEnumerable
Ejemplo n.º 1
0
 public void FireAdd(PubSubNode node, PubSubItem item)
 {
     if (OnAdd != null)
     {
         OnAdd(node, item);
     }
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
0
 public void FireRemove(PubSubNode node, PubSubItem item)
 {
     if (OnRemove != null)
     {
         OnRemove(node, item);
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
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  = (PubSubNode)m_nodes[jn];

            if (n != null)
            {
                return(n);
            }
            n           = new PubSubNode(Stream, service, node, maxItems);
            m_nodes[jn] = n;
            n.OnError  += OnError;
            return(n);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 8
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 = m_nodes[jn] as PubSubNode;

            if (psNode != null)
            {
                m_nodes[jn] = null;
            }
            else
            {
                psNode = new PubSubNode(Stream, service, node, 10);
            }

            psNode.OnError += errorHandler;

            psNode.Delete();
        }
Ejemplo n.º 9
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("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);
        }
Ejemplo n.º 10
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("WARNING: notification received for unknown pubsub 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);
        }
Ejemplo n.º 11
0
 public void FireRemove(PubSubNode node, PubSubItem item)
 {
     if (OnRemove != null)
         OnRemove(node, item);
 }
Ejemplo n.º 12
0
 public void FireAdd(PubSubNode node, PubSubItem item)
 {
     if (OnAdd != null)
         OnAdd(node, item);
 }
Ejemplo n.º 13
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;
 }
Ejemplo n.º 14
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();
        }
Ejemplo n.º 15
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;
 }
Ejemplo n.º 16
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;
 }
Ejemplo n.º 17
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 = m_nodes[jn] as PubSubNode;
            if (psNode != null)
            {
                m_nodes[jn] = null;
            }
            else
            {
                psNode = new PubSubNode(Stream, service, node, 10);
            }

            psNode.OnError += errorHandler;

            psNode.Delete();
        }
Ejemplo n.º 18
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 = (PubSubNode) m_nodes[jn];
     if (n != null)
         return n;
     n = new PubSubNode(Stream, service, node, maxItems);
     m_nodes[jn] = n;
     n.OnError += OnError;
     return n;
 }