Coder Social home page Coder Social logo

Comments (3)

pasis avatar pasis commented on July 28, 2024

Libstrophe is low-level library and this applies some restrictions. We can't simply resend items, because they may be valid only within current session. Resending is responsibility of user (user of the library, program in most cases).
Second, any change must not break existent programs.

You're right, would be nice to have some "reliable" interface or access to unsent items. You can try to play around connection_handler. User notified with event XMPP_CONN_DISCONNECT from conn_disconnect() on errors. And at this point conn contains unsent items. Just a quick thought: you can make interface xmpp_conn_unsent_nr()/next() and user can go through the messages and save ones need to be resent. But user doesn't work with raw strings, so I think next() should return xmpp_stanza_t. Libstrophe stores complete stanzas in raw strings in the send_queue what makes this approach possible.

Also, as you said, send_queue should be cleared on a connection error. Since connection_handler may want to access the queue and call xmpp_connect_client() we can't clear queue neither before nor after handler's call in conn_disconnect(). But we can clear it at the top of connect-like functions with some static function conn_send_queue_purge().

What about handler for successfully sent items: user can mix xmpp_send() and xmpp_send_raw().

from libstrophe.

stanson-ch avatar stanson-ch commented on July 28, 2024

User notified with event XMPP_CONN_DISCONNECT from conn_disconnect() on errors. And at this point conn contains unsent items. Just a quick thought: you can make interface xmpp_conn_unsent_nr()/next() and user can go through the messages and save ones need to be resent.

Good point, looks like solution. Will try.

Also, as you said, send_queue should be cleared on a connection error. Since connection_handler may want to access the queue and call xmpp_connect_client() we can't clear queue neither before nor after handler's call in conn_disconnect(). But we can clear it at the top of connect-like functions with some static function conn_send_queue_purge()

Purging queue in xmpp_connect_client is a good idea. This will allow to make "short cycle" reconnects possible, without releasing connection, creating new connection and setting same credentials again. Will try to make a patch.

from libstrophe.

pasis avatar pasis commented on July 28, 2024

Fix for the send_queue is already in master and reconnect works. Access to unsent data is not in priority for the next release (0.9), but may be added in some future release.

from libstrophe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.