powered by Jive Software

Delay not getting in message object in android

I am using Smack for one of my project for chat module. I succeed in implementation. Also got chat history. using below code:

CoroutineScope(Dispatchers.IO).launch {
            var mamManager = MamManager.getInstanceFor(mConnection)
            var result =  async { mamManager.queryMostRecentPage(jId, 50) }.await()
            withContext(Dispatchers.Main){
              

                chatList.clear()
                for(message in result.messages){
                    chatList.add(message)
                }
                mMsgAdapter?.notifyDataSetChanged()
                
            }
        }

In response, I get list of all messages. Below are xml response of one of the message from list:

<message xmlns='jabber:client' to='raju@testing.com' from='nit@testing.com/562197503342225256402' id='RC0CL-101' xml:lang='en' type='chat'><archived xmlns='urn:xmpp:mam:tmp' by='nit@testing.com' id='1596112104059'></archived><stanza-id xmlns='urn:xmpp:sid:0' id='1596112104054539' by=''nit@testing.com'/><body>Hello there.</body></message>

Here, I am not getting delay tag in that. I tried almost everything but didn’t get anything.

If you look at the specification you can see that the delay tag is not appended to the original message, but can instead be found on the <forwarded/> element, which also carries the message.

So instead of looping over the messages directly, you could loop over result.getForwarded() and retrieve both the message, as well as the respective delay tag from the Forwaded element.

If I use latest smack version 4.3.2 then there is no such method like result.getForwarded(). Where result is MamQuery. From there I cannot get forwarded element.

And if i use smack version 4.2.0 then there is method like result.forwardedMessages in which result is MamQueryResult. From there I can get forwarded element.

Latest version is 4.3.4

MamQuery.getMessages() returns the forwarded messages from the archive.

https://download.igniterealtime.org/smack/docs/4.3.4/javadoc/org/jivesoftware/smackx/mam/MamManager.MamQuery.html

MamQuery.getMessages()

It returns List<Message> in which I am not getting delay because delay is inside forwarded.

Right, you want MamQuery.getMamResultExtensions().

I used result.page.forwarded and now I am getting a delay inside that.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.