Problem:
The connection should be closed when the page unloads. Unfortunately strophe.js (at least up to version 1.0.2) disconnects asynchronously, which does not work when the page is destroyed. After some time the XMPP server will notice, that the page disappeared and will close the connection. But if you do not want to wait, then we have to force strophe to close immediately.
Solution:
There is a strophe patch, which allows for synchronous connection closing. The patch must be applied to the strophe.js file. Just 2 lines of code in strophe,js and one line before calling disconnect().
See A Website Chat made easy with XMPP and BOSH.
_happy_closing()
Keine Kommentare:
Kommentar veröffentlichen