Coder Social home page Coder Social logo

sessionClosedHandler about pontarius-xmpp HOT 8 CLOSED

singpolyma avatar singpolyma commented on August 15, 2024
sessionClosedHandler

from pontarius-xmpp.

Comments (8)

Philonous avatar Philonous commented on August 15, 2024

sessionClosedHandler doesn't exist anymore in the git version.
But when the session is closed, nothing special happens. There won't be any more incoming stanzas, so pullMessage etc. block indefinitely and outbound stanzas will remain in the outgoing stanza channel
(That will probably change in the future. I'm not too happy with the outgoing stanza channel since there's no way to tell whether a stanza has actually been sent. The reason for it's existence is to buffer stanzas in case the connection is closed. I'm not even sure this behaviour is desirable )

from pontarius-xmpp.

singpolyma avatar singpolyma commented on August 15, 2024

Having some way to attempt reconnect and/or notify the user when the connection goes away is important, otherwise everything just blocks and we lose data.

from pontarius-xmpp.

Philonous avatar Philonous commented on August 15, 2024

There's the connectionClosedHandler that is called when the connection goes down. The code to handle reconnecting is basically there but I needs some work because we changed the API around a lot. It's on the top of my laundry list.

from pontarius-xmpp.

Philonous avatar Philonous commented on August 15, 2024

We have implemented the reconnect functionality (see reconnect, reconnect' and reconnectNow). It can be used like this:

session (...) config {onConnectionClosed = \s e -> do
                             liftIO $ reconnect' s
                             liftIO $ sendPresence presenceOnline s
                             return ()
                       }

Note that reconnect* doesn't set your presence to online, so you have to do it yourself.

You can end the sesseion with endSession. This will kill the associated threads and close the connection. (note that the connectionClosedHandler will not be called in this case. This is intentional as to avoid possibly calling reconnect). Since the only way this can happen is if you call endSession yourself, you can set up your own machinery to avoid blocking on getMessage or similar when you are ending the session.

from pontarius-xmpp.

singpolyma avatar singpolyma commented on August 15, 2024

Thanks! I will try this stuff out soon :)

from pontarius-xmpp.

singpolyma avatar singpolyma commented on August 15, 2024

Is the intent, then, that when a message send fails my application code will wait for some time and then resend, or similar?

from pontarius-xmpp.

Philonous avatar Philonous commented on August 15, 2024

Yes. Inform the user that the message couldn't be sent at this moment and/or wait for some time and try to resend.

from pontarius-xmpp.

jonkri avatar jonkri commented on August 15, 2024

I might be stating the obvious here, but please note that if you want confirmation that the stanza has actually been received, a True value will not suffice, and you should send an IQ request instead.

from pontarius-xmpp.

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.