Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use XEP 198 (Stream Management) from smack 4.1?

I am new to XMPP. I'm using smack on android for providing chat in my application.

In smack 4.1, support for stream management is added so I used

  XMPPTCPConnection.setUseStreamManagementDefault(true);

to enable this and I'm getting :

03-27 00:50:54.945: D/SMACK(16991): SENT (5): <enable xmlns='urn:xmpp:sm:3' resume='true'/>
03-27 00:50:55.740: D/SMACK(16991): RECV (5): <enabled xmlns='urn:xmpp:sm:3' id='g2gCbQAAAAVTbWFja2gDYgAABZNiAAYRuGIAAW06' resume='true' max='300'/>

So, XEP 198 is working fine both on my client and the server(ejabberd 15).

But my question is -> do I have to write my own code for storing the messages(which are not acknowledged by the server) into my android sqlite database and manually resend them using chat.sendMessage(); when the connection is reconnected? OR is this resending part is done by Smack itself?

I didnt get any documentation for using XEP 198 on smack 4.1 other than XMPPTCPConnection.setUseStreamManagementDefault(true);

Is there any method available from smack for listening to the <a/> received from the server?

I have seen source code of yaxim, but it seems they have written their own code(by sending packets) for supporting XEP 198 which is now done in Smack 4.1.

Please help me with what should I do after enabling this support?

like image 514
Laxman Marothiya Avatar asked Mar 26 '15 20:03

Laxman Marothiya


1 Answers

  1. Of course you need to store your pending messages and resend them when connection is back.
  2. We have one way to listen message ack. Check out this, https://stackoverflow.com/a/37289804/4085494
like image 140
Haven Avatar answered Sep 28 '22 20:09

Haven