Info query (iq)

Sending XMPP iq stanzas to an entity is pretty simple with XmppDotNet using the async await pattern. The following example is sending a request to get a vcard from the user bob@example.com. Usually Iq queries must be always sent do a full Jid (including a resource). The vCard request is one of the exceptions, because the vCard is hosted directly on the users server. And the server is processing the iq request on our behalf.

Example

// construct the iq query
var vcardRequest = new VcardIq { Type = IqType.Get, To = "bob@example.com" };

// send the request and await the response
var resultIq = await xmppClient.SendIqAsync(vcardRequest);

// check for success or failure
if (resultIq.Type == IqType.Result)
{
    // server returned a result (sucsess)
    // => process the vCard here
}
else if (resultIq.Type == IqType.Error)
{
    // server returned an error
    // => handle error
}