xmppo / Jabber-Net

A modern fork of Jabber-Net
https://github.com/xmppo/Jabber-Net
37 stars 13 forks source link

how to get message history (message archiving) using jabber-net #106

Closed Dases95 closed 5 years ago

Dases95 commented 5 years ago

I'm making simple XMPP client using Jabber-Net. To send simple message, i need a simple example on how to retrieve message history?

ForNeVeR commented 5 years ago

Hello. As Jabber-Net currently has no direct support of that feature, you'll have to use the low-level features to make it work. Quick look at XEP-0313 makes me think you'll need to prepare special IQ queries and send them to the server. Jabber-Net has the low-lever infrastructure to do that.

You could also take a look at the How do I add my own packet types? FAQ entry.

Dases95 commented 5 years ago

i have to create an "YourQuery" object and put the special IQ queries as a parameter ?

ForNeVeR commented 5 years ago

YourQuery itself is a special IQ query.

Dases95 commented 5 years ago

how to set the type of the IQ using yourQuery and how to send this query to the server

ForNeVeR commented 5 years ago

What do you mean by the "type of the IQ"? IQ is one of the packet types in the XMPP protocol. And you, the user, should fill it with the data you need.

To send it (or any packet actually) to the server, you should call XmppStream.Write. One example of XmppStream you're probably familiar with is a JabberClient.

Dases95 commented 5 years ago

i tried this but no result appear

private void j_OnStreamInit(object sender, ElementStream stream)
        {
            XmlDocument doc = new XmlDocument();
            doc.InnerXml = "<query xmlns = 'urn:xmpp:mam:2'><x xmlns = 'jabber:x:data' type = 'submit'><field var = 'FORM_TYPE' type = 'hidden'><value> urn:xmpp:mam:2 </value></field><field var ='with' ><value>admin@DESKTOP-MUBI565</value></field></x></query>";
            YourQuery myQuery = new YourQuery(doc);
            XmppStream x = (XmppStream)sender;
            x.Write(myQuery);
            stream.AddFactory(new MyFactory());
        }
ForNeVeR commented 5 years ago

Which result do you expect?

Dases95 commented 5 years ago

The response from the server

ForNeVeR commented 5 years ago

And how do you observe the response from the server?