Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
morgana #1
Member since Feb 2013 · 1 post
Group memberships: Members
Show profile · Link to this post
Subject: Get Items from PubSub Subscription
I'm looking the best way to get the items after I've subscribed to a pub sub node.  I'm receiving the message in the pubSubManager OnEvent, but there is no data in the MessageEventArgs e, Message, Body Property.

Do I have to walk through the nodes, or should I use some object that is already in the SDK to get the data?

Any quick code examples would be helpful in C#.

Thanks,

Morgan
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
A pubsub notification message with payload look like the following:


  1. <message from='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'>
  2.  <event xmlns='http://jabber.org/protocol/pubsub#event'>
  3.     <items node='princely_musings'>
  4.       <item id='ae890ac52d0df67ed7cfdf51b644e901'>
  5.         <entry xmlns='http://www.w3.org/2005/Atom'>
  6.           <title>Soliloquy</title>
  7.           <summary>
  8. To be, or not to be: that is the question:
  9. Whether 'tis nobler in the mind to suffer
  10. The slings and arrows of outrageous fortune,
  11. Or to take arms against a sea of troubles,
  12. And by opposing end them?
  13.           </summary>
  14.           <link rel='alternate' type='text/html'
  15.                href='http://denmark.lit/2003/12/13/atom03'/>
  16.           <id>tag:denmark.lit,2003:entry-32397</id>
  17.           <published>2003-12-13T18:30:02Z</published>
  18.           <updated>2003-12-13T18:30:02Z</updated>
  19.         </entry>
  20.       </item>
  21.     </items>
  22.  </event>
  23. </message>

You should be able to loop over the items with the following code:

  1. foreach (var item in e.Message.Element<Event>().Items.GetItems())
  2. {
  3.                
  4. }
This post was edited on 2013-03-12, 20:19 by Alex.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: