Not logged in. · Lost password · Register
Forum: MatriX RSS
Avatar
wmorrison #1
Member since Dec 2015 · 50 posts · Location: Kingston, Jamaica
Group memberships: Members
Show profile · Link to this post
Subject: The Message Class
Hello,
      I would like to send some other data as part of the message to a recipient.  I am searching around the message class but without success.  Any recommendation on how to achieve this?

Regards,
Will
Avatar
Alex #2
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
you can add any information you with to a Message stanza. Just create your custom XmppXElements in your custom namespace and attach them to a message stanza.

See also:
http://www.ag-software.net/matrix-xmpp-sdk/matrix-develope…

Alex
Avatar
wmorrison #3
Member since Dec 2015 · 50 posts · Location: Kingston, Jamaica
Group memberships: Members
Show profile · Link to this post
Hi Alex,

I created a class of type XmppXElement with 1 property.  I used the add method of the message class and added the class to the message.  The information was delivered in the message (using e.Message.ToString()) as follows:

  1. <message from='15555215554@adminpc/15555215554'
  2.     to='15552175049@adminpc'
  3.     type='chat'
  4.     id='215701883'
  5.     xmlns='jabber:client'>  
  6.     <body>This a test message</body>  
  7.     <active xmlns='http://jabber.org/protocol/chatstates' />  
  8.     <request xmlns='urn:xmpp:receipts' />  
  9.     <query xmlns='user: messagexdata'>   
  10.         <datesent>6/14/2016 9:53:24 PM</datesent>  
  11.     </query>
  12. </message>

The issue I am having is how to get the datesent element from the message.  I tried

  1. e.Message.GetTag("user:messagexdata", "datesent");

but I am getting null.  I am not sure what to do.

Regards,
Will
This post was edited on 2016-06-15, 10:01 by Alex.
Avatar
Alex #4
Member since Feb 2003 · 4322 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
this is also described in the link I posted above.

  1. var yourElement = msg.Element<yourCustomType>();

don't forget to register your type in the Factory.

Alex
Avatar
wmorrison #5
Member since Dec 2015 · 50 posts · Location: Kingston, Jamaica
Group memberships: Members
Show profile · Link to this post
It worked fine.
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