Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
Govardhan N #1
Member since Mar 2018 · 10 posts
Group memberships: Members
Show profile · Link to this post
Subject: MatriX vNext isComposing functions
Hi Alex,

I am trying to use Event.IsComposing, Event.IsDelivered event to show that the user is typing(similar to whatsapp) like this

  1. xmppClient.XmppXElementStreamObserver.Where(el => el.OfType<Matrix.Xmpp.MessageEvents.Event>()).Subscribe(el =>
  2. {                     
  3.        Matrix.Xmpp.MessageEvents.Event incomingMessage = el.Cast<Matrix.Xmpp.MessageEvents.Event>();
  4.  });

This event is initialized, but not triggered for incoming messages.

Can you help me how to trigger these events to show that the user is typing(similar to whatsapp) in my app ?
Avatar
Alex #2
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
A composing stanza looks like this:

  1. <message to='romeo@montague.net' id='message22'>
  2.  <body>Art thou not Romeo, and a Montague?</body>
  3.  <x xmlns='jabber:x:event'>
  4.     <composing/>
  5.  </x>
  6. </message>

The composing event tag <x xmlns='jabber:x:event'/> is a children of the <message/> tag.

So your code has to look like this:

  1. xmppClient
  2.     .XmppXElementStreamObserver
  3.     .Where(el =>
  4.         el.OfType<Message>()
  5.         && el.Element<Matrix.Xmpp.MessageEvents.Event>() != null                 
  6.  
  7.         )
  8.     .Subscribe(el =>
  9.     {
  10.         var msg = el.Cast<Message>();
  11.         var evt = el.Element<Matrix.Xmpp.MessageEvents.Event>();
  12.     });
Avatar
Govardhan N #3
Member since Mar 2018 · 10 posts
Group memberships: Members
Show profile · Link to this post
Thanks for the solution Alex. It works.

To get the message delivered status, do we need to manually send the delivery status for each received messages or can we get automatically when event is initialized?
Avatar
Alex #4
Member since Feb 2003 · 4327 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You have to send those events on your own.
You can also write your own handler an add it to the channel pipeline as described here:
https://matrix-xmpp.io/docs/handlers
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