Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Maybe the class isn't supposed to exist...
Avatar
sldr #1
Member since Feb 2018 · 15 posts
Group memberships: Members
Show profile · Link to this post
Subject: Matrix.vNext Lib is missing Matrix.Xmpp.Client.TimeIq class
This lib is all new to me and have only spent about half a day using it with no knowledge of XMPP so I could be doing something wrong. I have the following code that works for VersionIq and tried to copy it for TimeIq (that doesn't exist).

  1. x.XmppXElementStreamObserver
  2.     .Where(el => el.OfType<Iq>()
  3.             && el.Cast<Iq>().Type == IqType.Get
  4.             && el.Cast<Iq>().Query.OfType<Matrix.Xmpp.Version.Version>())
  5.     .Subscribe(el =>
  6.     {
  7.         Iq iq = el.Cast<Iq>();
  8.         VersionIq resIq = Factory.GetElement<VersionIq>();
  9.         resIq.Id = iq.Id;
  10.         resIq.From = iq.To;
  11.         resIq.To = iq.From;
  12.         resIq.Type = IqType.Result;
  13.         Matrix.Xmpp.Version.Version v = new Matrix.Xmpp.Version.Version();
  14.         v.Name = "SLDR EMailIM";
  15.         v.Os = "Windows";
  16.         v.Ver = "SLDR EMailIM V0.22";
  17.         resIq.Version = v;
  18.         x.SendAsync(resIq).Wait();
  19.         Console.WriteLine(resIq.ToString());
  20.     });

When I tried to do this with for TimeIq but it doesn't work because the TimeIq class doesn't exist anywhere in the Matrix namespace tree.
  1. x.XmppXElementStreamObserver
  2.     .Where(el => el.OfType<Iq>()
  3.             && el.Cast<Iq>().Type == IqType.Get
  4.             && el.Cast<Iq>().Query.OfType<Matrix.Xmpp.Time.Time>())
  5.     .Subscribe(el =>
  6.     {
  7.         Iq iq = el.Cast<Iq>();
  8.         TimeIq resIq = Factory.GetElement<TimeIq>();
  9.         resIq.Id = iq.Id;
  10.         resIq.From = iq.To;
  11.         resIq.To = iq.From;
  12.         resIq.Type = IqType.Result;
  13.         Matrix.Xmpp.Time.Time t = new Matrix.Xmpp.Time.Time();
  14.         t.DateTime = new DateTime();
  15.         resIq.Time = t;
  16.         x.SendAsync(resIq).Wait();
  17.         Console.WriteLine(resIq.ToString());
  18.     });

Please point me in the right direction if I am missing something. I am using Matrix.vNext Version 1.0.6 and did a "Install-Package Matrix.vNext -Version 1.0.6" to get it.

Thanks,
SLDR
(Stephen L. De Rudder)
This post was edited 2 times, last on 2018-02-24, 11:36 by Alex.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
TimeIq class does not exist.
You can build all Iqs like this:

  1. var timeQuery = new IqQuery<Time>() { Type = IqType.Get };

Alex
Avatar
sldr #3
Member since Feb 2018 · 15 posts
Group memberships: Members
Show profile · Link to this post
Subject: WOW Thanks for quick reply!!!
I have it working now with your solution.

  1.       x.XmppXElementStreamObserver.Where(el => el.OfType<Iq>() && el.Cast<Iq>().Type == IqType.Get && el.Cast<Iq>().Query.OfType<Matrix.Xmpp.Time.Time>()).Subscribe(el =>
  2.       {
  3.         Iq iq = el.Cast<Iq>();
  4.         IqQuery<Matrix.Xmpp.Time.Time> resIq = new IqQuery<Matrix.Xmpp.Time.Time>();
  5.         resIq.Id = iq.Id;
  6.         resIq.From = iq.To;
  7.         resIq.To = iq.From;
  8.         resIq.Type = IqType.Result;
  9.         resIq.Query.DateTime = DateTime.Now;
  10.         x.SendAsync(resIq).Wait();
  11.         Console.WriteLine(resIq.ToString());
  12.       });

Thanks,
SLDR
(Stephen L. De Rudder)

PS: It would be nice to have all the *Iq classes to be consistent but I am happy with your solution.
This post was edited on 2018-02-24, 09:53 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
the TimeIq class was added. You can use the latest CI builds from here:
https://www.myget.org/F/matrix-xmpp/api/v3/index.json

be aware that the CI builds are already version 2 which is coming soon.
We moved some functions from XmppClient to the Extension package.
So you just need to add Matrix.vNext.Extensions nuGet package and include the Roster and Presence extension namespaces when you are using the RequestRosterAsync and SendPresenceAsync function which were directly on the XmppClient before.

Alex
This post was edited 2 times, last on 2018-02-27, 23:29 by Alex.
Avatar
Alex #5
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
There is a sample in the docs now which described on how to implement software version as a handler:
https://matrix-xmpp.io/docs/handlers
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: