private void m_stream_OnProtocol(object sender, XmlElement rp) { if (rp.Name != "message") { return; } PubSubEvent evt = rp["event", URI.PUBSUB_EVENT] as PubSubEvent; if (evt == null) { return; } EventItems items = evt.GetChildElement <EventItems>(); if (items == null) { return; } if (items.Node != m_node) { return; } // 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); } }
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); }