Software /
code /
prosody
Changeset
1479:eef17ebe3ca1
Moved automatic unavailable presence generation on disconnect from sessionmanager to mod_presence
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 05 Jul 2009 17:45:44 +0500 |
parents | 1478:da11f2652ae9 |
children | 1480:93d3295fb064 |
files | core/sessionmanager.lua plugins/mod_presence.lua |
diffstat | 2 files changed, 11 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/core/sessionmanager.lua Sun Jul 05 16:21:58 2009 +0500 +++ b/core/sessionmanager.lua Sun Jul 05 17:45:44 2009 +0500 @@ -56,14 +56,6 @@ function destroy_session(session, err) (session.log or log)("info", "Destroying session for %s (%s@%s)", session.full_jid or "(unknown)", session.username or "(unknown)", session.host or "(unknown)"); - -- Send unavailable presence - if session.presence then - local pres = st.presence{ type = "unavailable" }; - if (not err) or err == "closed" then err = "connection closed"; end - pres:tag("status"):text("Disconnected: "..err):up(); - session:dispatch_stanza(pres); - end - -- Remove session/resource from user's session list if session.full_jid then hosts[session.host].events.fire_event("resource-unbind", {session=session, error=err});
--- a/plugins/mod_presence.lua Sun Jul 05 16:21:58 2009 +0500 +++ b/plugins/mod_presence.lua Sun Jul 05 17:45:44 2009 +0500 @@ -315,3 +315,14 @@ end -- resource not online, discard return true; end); + +module:hook("resource-unbind", function(event) + local session, err = event.session, event.error; + -- Send unavailable presence + if session.presence then + local pres = st.presence{ type = "unavailable" }; + if not(err) or err == "closed" then err = "connection closed"; end + pres:tag("status"):text("Disconnected: "..err):up(); + session:dispatch_stanza(pres); + end +end);