tigase / Martin

(M) Martin - XMPP client library for Swift
Other
69 stars 27 forks source link

Question: How I could use stream management? #9

Closed manuel-rubio closed 3 years ago

manuel-rubio commented 3 years ago

Following the specification of stream management, I could use the <r> and <a> ensuring the messages the server sends are received for the server and vice-versa... how could I ensure when I'm sending a message that a message was sent before continue sending other messages?

hantu85 commented 3 years ago

Why would you need that check? Any stanza sent using then API will be delivered before another stanza (they are queued internally), so you can just send stanza one after another and the will be delivered (to the server) in proper order.

Also, TigaseSwift has support for StreamManagement already in the library - it is used if available by default. All you need to do, is to register StreamManagementModule module.

manuel-rubio commented 3 years ago

@hantu85 I want to connect in the background, send a message according to the received push notification, and then disconnect from the server but I want to ensure it was sent the stanza before disconnect.

hantu85 commented 3 years ago

I think that you could just send a message and then call disconnect() and wait in completionHandler for it to complete. This library will send message to the server (flush outgoing stanza queue) before disconnecting. If disconnection would be reported as clean by DisconnectedEvent message should be properly delivered to the server and connection would be properly closed.

If server properly handles all incoming stanzas before closing the stream (as it should according to the protocol specification) then message should be properly delivered to the XMPP server.

manuel-rubio commented 3 years ago

Ok, thanks.