コード例 #1
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);
        }
コード例 #2
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, Kixeye.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();
        }
コード例 #3
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;
 }