Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
tambunanw #1
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members, Premium
Show profile · Link to this post
Subject: Convert Iq to Custom Iq
Hi,

Previously i follow the tutorial and implement this code.

void xmppCon_OnIq(object sender, IqEventArgs e)
        {
            if (e.Iq.Query is Weather)
            {
                var weather = e.Iq.Query as Weather;
            }
        }

but when i try to convert the Iq to WeatherIq it won't works.

 
       void xmppCon_OnIq(object sender, IqEventArgs e)
        {
            if (e.Iq is WeatherIq)
            {
                var weatherIq = e.Iq as WeatherIq;
            }
        }

is theres something missing? how do i convert from Iq to WeatherIq?
Avatar
Alex #2
Member since Feb 2003 · 4328 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
its impossible to convert Iq to WeatherIq. This is by design, because the Iq Tag is always a container only.
You can cast the IQ's first children to Weather.

  1. if (e.Iq.Query is Weather)
  2. {
  3.    var weather = e.Iq.Query as Weather;
  4. }

Alex
Avatar
tambunanw #3
User title: Welly
Member since Jul 2011 · 57 posts · Location: Jakarta
Group memberships: Members, Premium
Show profile · Link to this post
ow. Ok. That's all i need to know.

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