xmppjs / xmpp.js

XMPP for JavaScript
ISC License
2.19k stars 375 forks source link

fix: restore JID sooner #996

Open otech47 opened 1 year ago

otech47 commented 1 year ago

This fixes an edge case I ran into involving logic where the client automatically handles reconnecting and resuming the stream.

I needed a way to listen for a stanza or event that indicates the stream is fully restored and can be used to send messages again (for example to try resending messages that were sent while offline)

the <resumed> stanza received from the server after a <resume> stanza is sent from the client seemed like a good candidate for this, however listening for that event and assuming the JID was available right away was where I was getting buggy behavior.

This change makes sure the JID is restored before sending the <resume> stanza but also nulls it out if that fails for whatever reason