/// <summary> /// Builds a request to discover information of an entity /// </summary> /// <param name="to">The xmpp entity to discover</param> /// <returns></returns> /// <param name="node">Optional node information</param> /// <returns></returns> public static Iq DiscoverInformation(Jid to, string node = null) { var discoIq = new DiscoInfoIq { To = to, Type = IqType.Get }; if (!String.IsNullOrEmpty(node)) { discoIq.Info.Node = node; } return(discoIq); }
public void BuildDiscoIqWithFeatures() { var expectedXml = Resource.Get("Xmpp.Disco.iq2.xml"); var dIq = new DiscoInfoIq { Type = IqType.Result, To = "[email protected]/resource", Id = "id_from_request" }; dIq.Info.AddFeature(new Feature("urn:xmpp:jingle:1")); dIq.Info.AddFeature(new Feature("urn:xmpp:jingle:apps:rtp:audio")); dIq.Info.AddFeature(new Feature("urn:xmpp:jingle:apps:rtp:video")); dIq.ShouldBe(expectedXml); }
public void DiscoverInformation(Jid to, Jid from, string node, IqCB cb, object cbArgs) { /* * * Example 9. Querying a specific JID and node combination * * <iq type='get' * from='[email protected]/orchard' * to='mim.shakespeare.lit' * id='info3'> * <query xmlns='http://jabber.org/protocol/disco#info' * node='http://jabber.org/protocol/commands'/> * </iq> * * * Example 10. JID+node result * * <iq type='result' * from='mim.shakespeare.lit' * to='[email protected]/orchard' * id='info3'> * <query xmlns='http://jabber.org/protocol/disco#info' * node='http://jabber.org/protocol/commands'> * <identity * category='automation' * type='command-list'/> * </query> * </iq> */ DiscoInfoIq discoIq = new DiscoInfoIq(IqType.get); discoIq.To = to; if (from != null) { discoIq.From = from; } if (node != null && node.Length > 0) { discoIq.Query.Node = node; } xmppConnection.IqGrabber.SendIq(discoIq, cb, cbArgs); }
public DiscoHandler(ICaps caps, ICaps clientCaps) { Handle( el => el.OfType <Iq>() && el.Cast <Iq>().Type == IqType.Get && el.Cast <Iq>().Query.OfType <Info>(), async(context, xmppXElement) => { var iq = xmppXElement.Cast <Iq>(); var info = xmppXElement.Cast <Iq>().Query.Cast <Info>(); if (info.Node == null || info.Node == caps.Node + "#" + clientCaps.CapsHash) { var resIq = new Iq() { Id = iq.Id, To = iq.From, Type = IqType.Result }; resIq.Add(clientCaps.DiscoInfo); await SendAsync(resIq); } else { var dIq = new DiscoInfoIq { Type = IqType.Error, To = iq.From, Id = iq.Id, Info = { Node = info.Node }, Error = new Error(Matrix.Xmpp.Base.ErrorCondition.ItemNotFound) }; await SendAsync(dIq); } }); }
internal Disco() { /* * <iq from='[email protected]/orchard' * id='disco1' * to='[email protected]/balcony' * type='result'> * <query xmlns='http://jabber.org/protocol/disco#info'/> * <identity category='client' type='pc'/> * <feature var='http://jabber.org/protocol/disco#info'/> * <feature var='http://jabber.org/protocol/disco#items'/> * <feature var='http://jabber.org/protocol/muc'/> * </query> * </iq> */ DiscoInfoIq diiq = new DiscoInfoIq(); diiq.Id = "disco1"; diiq.To = new agsXMPP.Jid("[email protected]/balcony"); diiq.Type = agsXMPP.protocol.client.IqType.result; diiq.Query.AddIdentity(new DiscoIdentity("pc", "client")); diiq.Query.AddFeature(new DiscoFeature(agsXMPP.Uri.DISCO_INFO)); diiq.Query.AddFeature(new DiscoFeature(agsXMPP.Uri.DISCO_ITEMS)); diiq.Query.AddFeature(new DiscoFeature(agsXMPP.Uri.MUC)); Program.Print(diiq); // Build caps from this disco info Capabilities caps = new Capabilities(); caps.Node = "http://www.ag-software.de/miniclient/caps"; caps.SetVersion(diiq.Query); Program.Print(caps); }
public void DiscoverInformation(Jid to, Jid from, string node, IqCB cb, object cbArgs) { /* Example 9. Querying a specific JID and node combination <iq type='get' from='[email protected]/orchard' to='mim.shakespeare.lit' id='info3'> <query xmlns='http://jabber.org/protocol/disco#info' node='http://jabber.org/protocol/commands'/> </iq> Example 10. JID+node result <iq type='result' from='mim.shakespeare.lit' to='[email protected]/orchard' id='info3'> <query xmlns='http://jabber.org/protocol/disco#info' node='http://jabber.org/protocol/commands'> <identity category='automation' type='command-list'/> </query> </iq> */ DiscoInfoIq discoIq = new DiscoInfoIq(IqType.get); discoIq.To = to; if (from != null) discoIq.From = from; if (node != null && node.Length > 0) discoIq.Query.Node = node; xmppConnection.IqGrabber.SendIq(discoIq, cb, cbArgs); }