qxmpp-project / qxmpp

Cross-platform C++ XMPP client and server library
408 stars 197 forks source link

How to check if a QXmppMessage has the delay element attached? #527

Closed timakas closed 1 year ago

timakas commented 1 year ago

I am trying to determine if an incoming message is a delayed offline message.

I've read that QXmpp supports XEP - 0203 Delayed Delivery, and I have gone through the QXmpp documentation, but I can't seem to find a way to check if a QXmppMessage has the delay element attached. Can someone please offer a solution to check for the delay element? Appreciate any help, thanks.

melvo commented 1 year ago

https://doc.qxmpp.org/qxmpp-1/classQXmppMessage.html#a455a05e7adee6a989e1e56f1a1766373 (QXmppMessage::stamp()) is what you are looking for :)

timakas commented 1 year ago

https://doc.qxmpp.org/qxmpp-1/classQXmppMessage.html#a455a05e7adee6a989e1e56f1a1766373 (QXmppMessage::stamp()) is what you are looking for :)

Thanks :) I'm still a bit new to working with QXmpp. So could I ask about the implementation of checking for the delay message? Would it work like this... Upon connecting to the server I set a login time variable, and when delay messages come from the server I compare the message stamp to the login time variable, and if the message stamp is older than the login time, then this confirms it is a delay message?

lnjX commented 1 year ago

@timakas If the message did not contain a delay element, QXmppMessage::stamp().isNull() will return true.