Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
choquito #1
Member since Mar 2013 · 21 posts · Location: Spain
Group memberships: Members
Show profile · Link to this post
Subject: Class design. Iq result object null
Hi Alex,

I'm trying implement  a class based in your weather example.

All works fine but after get the iq.element the object (my class) is always null.

Stanza with result:

  1. <iq id="MX_4" type="result" to="10000004@im.xxxxx.com/MatriX" xmlns="jabber:client" from="boot_test@im.xxxxx.com/MatriX">
  2.  <meep xmlns="A21:meep">
  3.     <nombre>test</nombre>
  4.     <respuesta>1</respuesta>
  5.  </meep>
  6. </iq>


Function Callback:

  1. private void SampleResponse(object sender, IqEventArgs e)
  2. {
  3.             var iq = e.Iq;
  4.  
  5.             if (iq.Type == IqType.result)
  6.             {
  7.                 var meep = iq.Element<Meep>();
  8.              if (meep != null) <--------- meep is always null
  9.                 {
  10.                     var nombre = e.State as string;
  11.                     ....
  12.                 }
  13.             }
  14.             else if (iq.Type == IqType.error)
  15.             {
  16.                 // process errors here
  17.             }
  18. }

What is wrong in my code?...


Thanks.
Avatar
Alex #2
Member since Feb 2003 · 4296 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The parser does not build your Meep class on incoming xml.
This happens when your class is not registered correct in the Factory.

Alex
Avatar
choquito #3
Member since Mar 2013 · 21 posts · Location: Spain
Group memberships: Members
Show profile · Link to this post
The domain was incorrect in
  1. Factory.RegisterElement

Now works fine

Thanks 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:
Forum: MatriX RSS