Subject: Parsing custom message
Hi,
I have been using your sdk for a couple of days now for a personal project and sofar all is going well. I am using XEP-0313 to archive the messages on my server. I am capable of retrieving all messages sent from one user to an other.
This is the result i get per message in the xmppClient_OnMessage :
I cannot seem to parse this to a class to be able to retrieve the body data and the delay data.
This is a quick example of the code i use to parse it.
I hope somebody sees what i am doing wrong.
Thank you in advance!
I have been using your sdk for a couple of days now for a personal project and sofar all is going well. I am using XEP-0313 to archive the messages on my server. I am capable of retrieving all messages sent from one user to an other.
This is the result i get per message in the xmppClient_OnMessage :
- <message from="fakeId" to="fakeId/MatriX" xmlns="jabber:client">
- <result xmlns="urn:xmpp:mam:1" id="1511360750337715">
- <forwarded xmlns="urn:xmpp:forward:0">
- <delay xmlns="urn:xmpp:delay" stamp="2017-11-22T14:25:50.337715Z" />
- <message xmlns="jabber:client" from="user1/MatriX" to="user2" type="chat">
- <body>,kkkk</body>
- </message>
- </forwarded>
- </result>
- </message>
I cannot seem to parse this to a class to be able to retrieve the body data and the delay data.
This is a quick example of the code i use to parse it.
- /// <summary>
- /// Chat log response.
- /// </summary>
- public class ChatLogResponse : XmppXElement
- {
- #region Constructors
- /// <summary>
- /// Constructor.
- /// </summary>
- public ChatLogResponse() :base("jabber:client","message")
- {}
- #endregion
- public string From
- {
- get { return GetTag("from"); }
- set { SetTag("from", value); }
- }
- public string To
- {
- get { return GetTag("to"); }
- set { SetTag("to", value); }
- }
- public ChatLogResponseResult Result
- {
- get { return Element<ChatLogResponseResult>(); }
- set { Replace(value); }
- }
- }
- public class ChatLogResponseResult : XmppXElement
- {
- public ChatLogResponseResult() : base(Variables.MamProtocol, "result")
- {}
- public int Id
- {
- get { return GetAttributeInt("id"); }
- set { SetAttribute("id", value); }
- }
- public ChatLogResponseForwarded Forwarded
- {
- get { return Element<ChatLogResponseForwarded>(); }
- set { Replace(value); }
- }
- }
- public class ChatLogResponseForwarded : XmppXElement
- {
- public ChatLogResponseForwarded() : base("urn:xmpp:forward:0", "forwarded")
- {
- }
- public ChatLogResponseDelay Delay
- {
- get { return Element<ChatLogResponseDelay>(); }
- set { Replace(value); }
- }
- public ChatLogResponseMessage Message
- {
- get { return Element<ChatLogResponseMessage>(); }
- set { Replace(value); }
- }
- }
- public class ChatLogResponseDelay : XmppXElement
- {
- public ChatLogResponseDelay() : base("urn:xmpp:delay", "delay")
- {}
- public string Stamp
- {
- get { return GetAttribute("stamp"); }
- set { SetAttribute("stamp", value); }
- }
- }
- public class ChatLogResponseMessage : XmppXElement
- {
- public ChatLogResponseMessage() : base("jabber:client","message")
- {}
- public string From
- {
- get { return GetAttribute("from"); }
- set { SetAttribute("from", value); }
- }
- public string To
- {
- get { return GetAttribute("to"); }
- set { SetAttribute("to", value); }
- }
- public string Type
- {
- get { return GetAttribute("type"); }
- set { SetAttribute("type", value); }
- }
- /// <summary>
- /// Value child.
- /// </summary>
- public string Body
- {
- get { return GetTag("body"); }
- set { SetTag("body",value); }
- }
- }
I hope somebody sees what i am doing wrong.
Thank you in advance!
This post was edited on 2017-11-23, 23:36 by Alex.