From 8b041f3cdbc219dc78f884e6418c83d03b867a5a Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Wed, 19 Nov 2008 05:07:52 +0000 Subject: Fix sending of unavailable presence on disconnect --- core/sessionmanager.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core') diff --git a/core/sessionmanager.lua b/core/sessionmanager.lua index 74edb86c..7a0d6a49 100644 --- a/core/sessionmanager.lua +++ b/core/sessionmanager.lua @@ -14,6 +14,8 @@ local error = error; local uuid_generate = require "util.uuid".generate; local rm_load_roster = require "core.rostermanager".load_roster; +local st = require "util.stanza"; + local newproxy = newproxy; local getmetatable = getmetatable; @@ -33,13 +35,13 @@ function new_session(conn) return session; end -function destroy_session(session) +function destroy_session(session, err) (session.log or log)("info", "Destroying session"); -- Send unavailable presence if session.presence then local pres = st.presence{ type = "unavailable" }; - if err == "closed" then err = "connection closed"; end + if (not err) or err == "closed" then err = "connection closed"; end pres:tag("status"):text("Disconnected: "..err); session.stanza_dispatch(pres); end -- cgit v1.2.3