AnsweredAssumed Answered

XMPPTCPConnection.PacketWriter

Question asked by Luis Ángel on Nov 8, 2016
Latest reply on Nov 16, 2016 by Luis Ángel

Hi there,

 

I recently started to use Smack library to work on a chat app, and so far is been really good, the documentation is clear.

So now I have a question and I cannot find anything in the docs to fix this issue that I have;

I am trying to handle the errors for send messages in my own way, so the current behavior is: I try to send a message with no internet connection, and it will be queued until the connection is back, and it will retry that by itself, which is fine, but for some messages, they are just simply lost, so what I want to do, is to find a way to clear the queue once the connection is lost, so I will have my messages in the database, and I will retry them manually, so that way I will avoid to lose some of the messages with the current behavior.

Looking into the code, I found that inside XMPPTCPConnection, there is this class PacketWriter, where there's a queue, where we have all the elements, so I wonder if there is a way to clear the queue once the connection is gone, or if there is a better and easy way to perform that action, which is basically just avoid to retry to send the messages with a reconnection, I want to do it manually.

 

I hope you can help me.

Outcomes