Subject: Matrix vNext : how to send request for IqType.Set in .Net Core/C#
I'm new to XMPP. I've been trying to use MatriX vNext to call XMPP API. I checked 'ag-software.net' and forum. Only found brief code samples and even the most relevant ones are for 'IqType.Get'. I did manage to create xmppClient and connected to the XMPP Server successfully. However, I couldn't figure out how to send my request. If I understood correctly, below is the way to send Iq type requests and handle the response but I'm not sure how to mount the payload and extract the result from the response.
Could you please show me an example for this. I'm tying to send the XML below:
Example Request:
Example Response:
- xmppClient
- .XmppXElementStream
- .Where(el =>
- el.OfType<Iq>
- && el.Cast<T>().Type == IqType.Get
- && el.Cast<T>().Query.OfType<Ping>())
- .Subscribe(el =>
- {
- // handle and reply to incoming pings
- var iq = xmppXElement.Cast<T>();
- var resIq = Factory.GetElement<T>();
- resIq.Id = iq.Id;
- resIq.To = iq.From;
- resIq.Type = IqType.Result;
- await xmppClient.SendAsync(resIq);
- });
- // connect, secure, authenticate and bind
- await xmppClient.ConnectAsync();
Could you please show me an example for this. I'm tying to send the XML below:
Example Request:
- <iq from="username.apikey@api.coredial.com"
- id="rpc-1"
- to="service.api.coredial.com"
- type="set">
- <query xmlns="jabber:iq:rpc">
- <methodCall>
- <methodName>pbx.originate</methodName>
- <params>
- <param>
- <value>
- <int>77</int>
- </value>
- </param>
- <param>
- <value>
- <string>2101</string>
- </value>
- </param>
- </params>
- </methodCall>
- </query>
- </iq>
Example Response:
- <iq from="service.api.coredial.com"
- id="rpc-1"
- to="admin.apikey@api.coredial.com/resource"
- type="result">
- <query xmlns="jabber:iq:rpc">
- <methodResponse>
- <params>
- <param>
- <value>
- <boolean>1</boolean>
- </value>
- </param>
- </params>
- </methodResponse>
- </query>
- </iq>
This post was edited on 2020-01-17, 15:50 by Alex.