Not logged in. · Lost password · Register
Forum: MatriX RSS
humba #1
Member since Feb 2020 · 6 posts
Group memberships: Members
Show profile · Link to this post
Subject: Porting code to vNext
I have a working solution using the old matrix lib that I need to bring into the .NET core world. So I swapped out the matrix libs and now I'm flailing trying to migrate my code.

For instance, I'm using xmppClient.StreamActive to determine if an XmppClient has a connection or now. How does that translate to Matrix vNext?

Similarly, I subscribed to a variety of OnXXXX events. Going by the sample for message subscription I managed to port OnMessage and OnPresence, but there's a bunch of other events I'm still struggling with: OnClose, OnError, OnStreamError, OnXmlError, OnAuthError. How do these translate?

I'm also using the PubSubManager in the old lib and I haven't found a replacement there, either.
Avatar
Alex #2
Member since Feb 2003 · 4375 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello humba,

Quote by humba:
I have a working solution using the old matrix lib that I need to bring into the .NET core world. So I swapped out the matrix libs and now I'm flailing trying to migrate my code.

Similarly, I subscribed to a variety of OnXXXX events. Going by the sample for message subscription I managed to port OnMessage and OnPresence, but there's a bunch of other events I'm still struggling with: OnClose, OnError, OnStreamError, OnXmlError, OnAuthError. How do these translate?

MatriX vNext is very different from MatriX. You cannot just change the libraries with some minor changes and recompile. You have to rewrite and redesign lots of your code.

MatriX vNext is reactive, there are no classical events. You have to filter on the packet stream and subscribe to it with actions instead.
See also:
https://matrix-xmpp.io/docs/receiving-messages

Quote by humba:
For instance, I'm using xmppClient.StreamActive to determine if an XmppClient has a connection or now. How does that translate to Matrix vNext?

In MatriX vNext I guess the closest is the XmppSessionState which you can get from the XmppSessionStateObserver.

  1. xmppClient.XmppSessionStateObserver.Subscribe(v => {
  2.    Debug.WriteLine($"State changed: {v}");
  3. });

Quote by humba:
I'm also using the PubSubManager in the old lib and I haven't found a replacement there, either.

this does not exist yet. If it helps I can send you the codes of the previous MatriX version for that which can be easily ported.
This is on the ToDo list for vNext and will come to the Matrix.Extensions package soon.

You can also look at this sample client on GitHub here which shows you many of the concepts in MatriX vNext.

Best,
Alex
humba #3
Member since Feb 2020 · 6 posts
Group memberships: Members
Show profile · Link to this post
I've already downloaded the source code and I'm going through various classes that appear interesting.

I understand the notification subscription (and I've already ported session state, Message, Iq and Presence handling, as well as unsubscription), yet, as with the OnXXX events I listed, there's a bunch of error events and there's no documentation on error handling. I don't know when I should be expecting which exception (in case something goes wrong which I'm sure it will in the beginning - it was the same when I first started (my server is Cisco Finesse)). Say, I'm connecting with incorrect credentials.. what would be the response to ConnectAsync? And how can my application get informed about a connection closing? (there's no Closing in SessionState - would receiving a SessionState.Disconnected be )

I also found a ReconnectHandliner in the source code which I suspect would do automatic reconnect.. yet, it's unused in the entire repo (reconnect is something I do need.. I was using OnClose event to inform my application that the connection broken, and triggering a reconnect).

PubSubManager code would sure help.. either I stop this thing now and delay the entire port or I have to port it now. PubSub is essential to what I'm going. I found a bunch of classes in the source, but again, no live usage so no change for me to figure out what goes where. I only need to List active subscriptions, and add/remove subscriptions (methods

  1. Iq data = await mgr.RequestSubscriptionsAsync(pubSubAddress, null, pubSubManagerTimeout).ConfigureAwait(false);
  2. Iq data = await mgr.SubscribeAsync(pubSubAddress, node, user, pubSubManagerTimeout).ConfigureAwait(false);
  3. Iq data = await mgr.UnsubscribeAsync(pubSubAddress, node, user, pubSubManagerTimeout).ConfigureAwait(false);
Avatar
Alex #4
Member since Feb 2003 · 4375 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello humba,

those are many questions at the same time. Let me try to answer them. And let me know if some answers are missing ;-)

When you loose you connection the state changes to disconnected.

As you have seen there is reconnect logic build in. This is best used together with stream management.
Here is a sample how to enable it:

  1. var xmppClient = new XmppClient(
  2. conf =>
  3. {
  4.     conf.UseAutoReconnect();
  5.     conf.UseStreamManagement();
  6. },
  7. pipelineInitializerAction)
  8. {
  9.     Username = "user",
  10.     Password = "secret",
  11.     XmppDomain = "server.com",
  12.     HostnameResolver = new SrvNameResolver(),
  13. };

ConnectAsync throws exceptions, they are all defined in the Xml docs. Please see here:

  1. /// <summary>
  2. /// Connect to the XMPP server.
  3. /// This establishes the connection to the server, including TLS, authentication, resource binding and
  4. /// compression.
  5. /// </summary>
  6. /// <param name="cancellationToken"></param>
  7. /// <returns></returns>
  8. /// <exception cref="AuthenticationException">Thrown when the authentication fails.</exception>
  9. /// <exception cref="BindException">Thrown when resource binding fails.</exception>
  10. /// <exception cref="StreamErrorException">Throws a StreamErrorException when the server returns a stream error.</exception>
  11. /// <exception cref="CompressionException">Throws a CompressionException when establishing stream compression fails.</exception>
  12. /// <exception cref="RegisterException">Throws aRegisterException when new account registration fails.</exception>

I have attached the code of the PubSubManager. This should help you to port the PubSubManager functions over to MatriX vnext.
You only need to get the code which is building the packets, and then use SendIqAsync as described here:
https://matrix-xmpp.io/docs/info-query

Alex
The author has attached one file to this post:
PubSubManager.cs 74.5 kBytes
You have no permission to open this file.
Avatar
Alex #5
Member since Feb 2003 · 4375 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
PubSub extensions are in MatriX vNext now.
See:
https://github.com/matrix-xmpp/matrix-vnext/tree/master/sr…

New NuGet packages are available as well.
humba #6
Member since Feb 2020 · 6 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #4
Hehe.. and I was just done porting what I needed from the PubSubManager. It was pretty easy though.

For the ONXXX events.. here's what I came up with

OnPresence:

  1. presenceHandler = xmppClient
  2.                 .XmppXElementStreamObserver
  3.                 .Where(el => el is Presence)
  4.                 .Subscribe(el =>
  5.                 {
  6.                     // handle the message here
  7.                     XmppClient_OnPresence(xmppClient, el as Presence);
  8.                 });

OnIq

  1.             iqHandler = xmppClient
  2.                 .XmppXElementStreamObserver
  3.                 .Where(el => el is Iq)
  4.                 .Subscribe(el =>
  5.                 {
  6.                     // handle the message here
  7.                     XmppClient_OnIq(xmppClient, el as Iq);
  8.                 });

OnMessage

  1. messageHandler = xmppClient
  2.                 .XmppXElementStreamObserver
  3.                 .Where(el => el is Message)
  4.                 .Subscribe(el =>
  5.                 {
  6.                     // handle the message here
  7.                     XmppClient_OnMessage(xmppClient, el as Message);
  8.                 });

OnClose

  1. sessionStateHandler = xmppClient.XmppSessionStateObserver.Subscribe(v =>
  2.             {
  3.                 OnSessionState(v);
  4.             });
  5.  
  6. private void OnSessionState(SessionState state)
  7.         {
  8.             Log($"session state has changed, new state: {state}", 4);
  9.             switch (state)
  10.             {
  11.                 case SessionState.Disconnected:
  12.                     XmppClient_OnClose();
  13.                     break;
  14.             }
  15.         }

OnStreamError: catch StreamErrorException thrown from ConnectAsync

OnAuthError: catch AuthenticationException from ConnectAsync

OnBindError: catch BindException from ConnectAsync

OnBind:

extend the above OnSessionState to handle SessionState.Binding.

OnError: I have no clue at present.. any idea? My code just sets the internal connection state to error, but does otherwise not react to it.
Avatar
Alex #7
Member since Feb 2003 · 4375 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by humba:
OnError: I have no clue at present.. any idea? My code just sets the internal connection state to error, but does otherwise not react to it.

This was required in the previous version of MatriX because its using the older callback based asynchronous pattern with BeginXXX and EndXXX. So some kind of callback is required to raise back errors and exception to the application code for asynchronous operations.

MatriX vNext is all based on tasks/async/await pattern (TAP). So you can catch all you exceptions on the awaitable operations, eg. using try/catch pattern.

The stream errors you can catch over the XmppXElementStreamObserver.

Alex
humba #8
Member since Feb 2020 · 6 posts
Group memberships: Members
Show profile · Link to this post
I'm running my code now. And I'm not getting MESSAGE and PRESENCE events, only Iqs. I sniffed traffic from the old and the new solution. One thing I noted is that the old matrix client would query the roster implicitly.. I added that manually to my vnext code after ConnectAsync.. now as far as I can tell, things are pretty much the same. But I must be missing something still.

This is what I get if I do follow TCP stream in Wireshark using the old matrix lib

  1. <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chdevuccx105.nxodev.intra" version="1.0" >
  2.     <?xml version='1.0' encoding='UTF-8'?>
  3.     <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chdevuccx105.nxodev.intra" id="13bc6ee6" xml:lang="en" version="1.0">
  4.         <stream:features>
  5.             <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  6.                 <mechanism>PLAIN</mechanism>
  7.             </mechanisms>
  8.             <auth xmlns="http://jabber.org/features/iq-auth"/>
  9.             <register xmlns="http://jabber.org/features/iq-register"/>
  10.         </stream:features>
  11.         <auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">my secret goes here</auth>
  12.         <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
  13.         <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chdevuccx105.nxodev.intra" version="1.0" >
  14.             <?xml version='1.0' encoding='UTF-8'?>
  15.             <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chdevuccx105.nxodev.intra" id="13bc6ee6" xml:lang="en" version="1.0">
  16.                 <stream:features>
  17.                     <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
  18.                     <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>
  19.                 </stream:features>
  20.                 <iq id="MX_1" type="set">
  21.                     <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
  22.                         <resource>MatriX</resource>
  23.                     </bind>
  24.                 </iq>
  25.                 <iq type="result" id="MX_1" to="chdevuccx105.nxodev.intra/13bc6ee6">
  26.                     <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
  27.                         <jid>pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX</jid>
  28.                     </bind>
  29.                 </iq>
  30.                 <iq id="MX_2" type="set">
  31.                     <session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
  32.                 </iq>
  33.                 <iq type="result" id="MX_2" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX"/>
  34.                 <iq id="MX_3" type="get">
  35.                     <query xmlns="jabber:iq:roster" />
  36.                 </iq>
  37.                 <iq type="result" id="MX_3" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX">
  38.                     <query xmlns="jabber:iq:roster">
  39.                         <item jid="finesse@chdevuccx105.nxodev.intra" subscription="both"/>
  40.                         <item jid="admin@chdevuccx105.nxodev.intra" subscription="both"/>
  41.                         <item jid="presencelistener@chdevuccx105.nxodev.intra" subscription="both"/>
  42.                     </query>
  43.                 </iq>
  44.                 <presence>
  45.                     <status/>
  46.                     <priority>0</priority>
  47.                 </presence>
  48.                 <presence id="rV85B-7" from="finesse@chdevuccx105.nxodev.intra/web_framework" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX"/>
  49.                 <presence id="JC3X6-3" from="admin@chdevuccx105.nxodev.intra/desktop" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX"/>
  50.                 <iq id="MX_4" type="get" to="pubsub.chdevuccx105.nxodev.intra">
  51.                     <pubsub xmlns="http://jabber.org/protocol/pubsub">
  52.                         <subscriptions />
  53.                     </pubsub>
  54.                 </iq>
  55.                 <iq type="result" id="MX_4" from="pubsub.chdevuccx105.nxodev.intra" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX">
  56.                     <pubsub xmlns="http://jabber.org/protocol/pubsub">
  57.                         <subscriptions>
  58.                             <subscription node="/finesse/api/User/pmgr_agentmonitoring/Dialogs" jid="pmgr_agentmonitoring@chdevuccx105.nxodev.intra" subscription="subscribed"/>
  59.                             <subscription node="/finesse/api/User/pmgr_agentmonitoring" jid="pmgr_agentmonitoring@chdevuccx105.nxodev.intra" subscription="subscribed"/>
  60.                             <subscription node="/finesse/api/SystemInfo" jid="pmgr_agentmonitoring@chdevuccx105.nxodev.intra" subscription="subscribed"/>
  61.                         </subscriptions>
  62.                     </pubsub>
  63.                 </iq>
  64.                 <iq id="MX_5" to="pubsub.chdevuccx105.nxodev.intra" type="set">
  65.                     <pubsub xmlns="http://jabber.org/protocol/pubsub">
  66.                         <subscribe node="/finesse/api/User/mtra" jid="pmgr_agentmonitoring@chdevuccx105.nxodev.intra" />
  67.                     </pubsub>
  68.                 </iq>
  69.                 <iq type="result" id="MX_5" from="pubsub.chdevuccx105.nxodev.intra" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX">
  70.                     <pubsub xmlns="http://jabber.org/protocol/pubsub">
  71.                         <subscription node="/finesse/api/User/mtra" jid="pmgr_agentmonitoring@chdevuccx105.nxodev.intra" subscription="subscribed">
  72.                             <subscribe-options/>
  73.                         </subscription>
  74.                     </pubsub>
  75.                 </iq>
  76.                 <message from="pubsub.chdevuccx105.nxodev.intra" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra" id="/finesse/api/User/mtra__pmgr_agentmonitoring@chdevuccx105.nxodev.intra__qwEqo">
  77.                     <event xmlns="http://jabber.org/protocol/pubsub#event">
  78.                         <items node="/finesse/api/User/mtra">
  79.                             <item id="f5e95957-d6bd-47ea-9e62-ff2bb80be86336">
  80.                                 <notification xmlns="http://jabber.org/protocol/pubsub">&lt;Update&gt;
  81.  &lt;data&gt;
  82.     &lt;user&gt;
  83.       &lt;dialogs&gt;/finesse/api/User/mtra/Dialogs&lt;/dialogs&gt;
  84.       &lt;extension&gt;5006&lt;/extension&gt;
  85.       &lt;firstName&gt;Admin&lt;/firstName&gt;
  86.       &lt;lastName&gt;Minh&lt;/lastName&gt;
  87.       &lt;loginId&gt;mtra&lt;/loginId&gt;
  88.       &lt;loginName&gt;mtra&lt;/loginName&gt;
  89.       &lt;mediaType&gt;1&lt;/mediaType&gt;
  90.       &lt;pendingState&gt;&lt;/pendingState&gt;
  91.       &lt;reasonCodeId&gt;-1&lt;/reasonCodeId&gt;
  92.       &lt;roles&gt;
  93.         &lt;role&gt;Agent&lt;/role&gt;
  94.       &lt;/roles&gt;
  95.       &lt;settings&gt;
  96.         &lt;wrapUpOnIncoming&gt;&lt;/wrapUpOnIncoming&gt;
  97.       &lt;/settings&gt;
  98.       &lt;state&gt;NOT_READY&lt;/state&gt;
  99.       &lt;stateChangeTime&gt;2020-02-05T12:02:57.095Z&lt;/stateChangeTime&gt;
  100.       &lt;teamId&gt;1&lt;/teamId&gt;
  101.       &lt;teamName&gt;Default&lt;/teamName&gt;
  102.       &lt;uri&gt;/finesse/api/User/mtra&lt;/uri&gt;
  103.     &lt;/user&gt;
  104.  &lt;/data&gt;
  105.  &lt;event&gt;PUT&lt;/event&gt;
  106.  &lt;requestId&gt;01746877-93c7-479d-8075-64b5522a83d8&lt;/requestId&gt;
  107.  &lt;source&gt;/finesse/api/User/mtra&lt;/source&gt;
  108. &lt;/Update&gt;</notification>
  109.                             </item>
  110.                         </items>
  111.                     </event>
  112.                 </message>
  113.                 <message from="pubsub.chdevuccx105.nxodev.intra" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra" id="/finesse/api/User/mtra__pmgr_agentmonitoring@chdevuccx105.nxodev.intra__65IQy">
  114.                     <event xmlns="http://jabber.org/protocol/pubsub#event">
  115.                         <items node="/finesse/api/User/mtra">
  116.                             <item id="f5e95957-d6bd-47ea-9e62-ff2bb80be86338">
  117.                                 <notification xmlns="http://jabber.org/protocol/pubsub">&lt;Update&gt;
  118.  &lt;data&gt;
  119.     &lt;user&gt;
  120.       &lt;dialogs&gt;/finesse/api/User/mtra/Dialogs&lt;/dialogs&gt;
  121.       &lt;extension&gt;5006&lt;/extension&gt;
  122.       &lt;firstName&gt;Admin&lt;/firstName&gt;
  123.       &lt;lastName&gt;Minh&lt;/lastName&gt;
  124.       &lt;loginId&gt;mtra&lt;/loginId&gt;
  125.       &lt;loginName&gt;mtra&lt;/loginName&gt;
  126.       &lt;mediaType&gt;1&lt;/mediaType&gt;
  127.       &lt;pendingState&gt;&lt;/pendingState&gt;
  128.       &lt;roles&gt;
  129.         &lt;role&gt;Agent&lt;/role&gt;
  130.       &lt;/roles&gt;
  131.       &lt;settings&gt;
  132.         &lt;wrapUpOnIncoming&gt;&lt;/wrapUpOnIncoming&gt;
  133.       &lt;/settings&gt;
  134.       &lt;state&gt;READY&lt;/state&gt;
  135.       &lt;stateChangeTime&gt;2020-02-05T12:03:00.370Z&lt;/stateChangeTime&gt;
  136.       &lt;teamId&gt;1&lt;/teamId&gt;
  137.       &lt;teamName&gt;Default&lt;/teamName&gt;
  138.       &lt;uri&gt;/finesse/api/User/mtra&lt;/uri&gt;
  139.     &lt;/user&gt;
  140.  &lt;/data&gt;
  141.  &lt;event&gt;PUT&lt;/event&gt;
  142.  &lt;requestId&gt;5f6b2359-4f15-4371-8596-78a0e160b170&lt;/requestId&gt;
  143.  &lt;source&gt;/finesse/api/User/mtra&lt;/source&gt;
  144. &lt;/Update&gt;</notification>
  145.                             </item>
  146.                         </items>
  147.                     </event>
  148.                 </message>

The pubsub stuff can be ignored.. that works on both clients
humba #9
Member since Feb 2020 · 6 posts
Group memberships: Members
Show profile · Link to this post
and from the vnext

  1. <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chdevuccx105.nxodev.intra" version="1.0" >
  2.     <?xml version='1.0' encoding='UTF-8'?>
  3.     <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chdevuccx105.nxodev.intra" id="e2a418e4" xml:lang="en" version="1.0">
  4.         <stream:features>
  5.             <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
  6.                 <mechanism>PLAIN</mechanism>
  7.             </mechanisms>
  8.             <auth xmlns="http://jabber.org/features/iq-auth"/>
  9.             <register xmlns="http://jabber.org/features/iq-register"/>
  10.         </stream:features>
  11.         <auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">secret secret</auth>
  12.         <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
  13.         <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" to="chdevuccx105.nxodev.intra" version="1.0" >
  14.             <?xml version='1.0' encoding='UTF-8'?>
  15.             <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="chdevuccx105.nxodev.intra" id="e2a418e4" xml:lang="en" version="1.0">
  16.                 <stream:features>
  17.                     <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/>
  18.                     <session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>
  19.                 </stream:features>
  20.                 <iq id="Lo1O3xkhCE2O5tvvSvH6hA" type="set" xmlns="jabber:client">
  21.                     <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
  22.                         <resource>MatriX</resource>
  23.                     </bind>
  24.                 </iq>
  25.                 <iq type="result" id="Lo1O3xkhCE2O5tvvSvH6hA" to="chdevuccx105.nxodev.intra/e2a418e4">
  26.                     <bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
  27.                         <jid>pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX</jid>
  28.                     </bind>
  29.                 </iq>
  30.                 <iq id="WMjerjLKG0WYaGRv4uesLw" type="set" xmlns="jabber:client">
  31.                     <session xmlns="urn:ietf:params:xml:ns:xmpp-session" />
  32.                 </iq>
  33.                 <iq type="result" id="WMjerjLKG0WYaGRv4uesLw" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX"/>
  34.                 <iq id="588Sz5dxaESvS3s+tkMNzw" type="get" xmlns="jabber:client">
  35.                     <query xmlns="jabber:iq:roster" />
  36.                 </iq>
  37.                 <iq type="result" id="588Sz5dxaESvS3s+tkMNzw" to="pmgr_agentmonitoring@chdevuccx105.nxodev.intra/MatriX">
  38.                     <query xmlns="jabber:iq:roster">
  39.                         <item jid="finesse@chdevuccx105.nxodev.intra" subscription="both"/>
  40.                         <item jid="admin@chdevuccx105.nxodev.intra" subscription="both"/>
  41.                         <item jid="presencelistener@chdevuccx105.nxodev.intra" subscription="both"/>
  42.                     </query>
  43.                 </iq>
  44.             </stream:stream>
  45.         </stream:stream>

Any idea what could be going wrong?

And do you have an example of getting errors from XmppXElementStreamObserver?
This post was edited on 2020-02-05, 13:46 by Alex.
Avatar
Alex #10
Member since Feb 2003 · 4375 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
The ConnectAsync sets up the connection until resource binding.
It does not set your own presence which is required for getting other presences and messages.
It also does not fetch the roster automatically.

The reason for this is that is that presence and roster are not required in all applications.

When you need roster and presence then just do it like described here in the Console client sample:
https://github.com/matrix-xmpp/matrix-vnext/blob/a99f7d7e2…

  1. // Connect the XMPP connection
  2. await xmppClient.ConnectAsync();
  3.  
  4. // request the roster (aka contact list)
  5. var roster = await xmppClient.RequestRosterAsync();
  6.  
  7. // Send our presence to the server
  8. await xmppClient.SendPresenceAsync(Show.Chat, "free for chat");
humba #11
Member since Feb 2020 · 6 posts
Group memberships: Members
Show profile · Link to this post
Setting the presence after querying the roster did the trick, thanks.

So the only thing remaining is catching errors from XmppXElementStreamObserver. Do you have an example on how to do that?
Avatar
Alex #12
Member since Feb 2003 · 4375 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by humba:
Setting the presence after querying the roster did the trick, thanks.

So the only thing remaining is catching errors from XmppXElementStreamObserver. Do you have an example on how to do that?

for <stream:error/> you just subscribe to the Error element in the Matrix.Xmpp.Stream namespace

  1. xmppClient
  2.     .XmppXElementStreamObserver
  3.     .Where(el => el is Matrix.Xmpp.Stream.Error)
  4.     .Subscribe(el =>
  5.     {
  6.         // handle the stream errors here        
  7.     });
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:
Forum: MatriX RSS