Software /
code /
prosody
Comparison
core/sessionmanager.lua @ 339:c6446bbfe40c
Fix sending of unavailable presence on disconnect
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 19 Nov 2008 05:07:52 +0000 |
parent | 333:8d15b073fdbe |
child | 356:8ff322b550a3 |
comparison
equal
deleted
inserted
replaced
338:804f5e62a41f | 339:c6446bbfe40c |
---|---|
11 local modulemanager = require "core.modulemanager"; | 11 local modulemanager = require "core.modulemanager"; |
12 local log = require "util.logger".init("sessionmanager"); | 12 local log = require "util.logger".init("sessionmanager"); |
13 local error = error; | 13 local error = error; |
14 local uuid_generate = require "util.uuid".generate; | 14 local uuid_generate = require "util.uuid".generate; |
15 local rm_load_roster = require "core.rostermanager".load_roster; | 15 local rm_load_roster = require "core.rostermanager".load_roster; |
16 | |
17 local st = require "util.stanza"; | |
16 | 18 |
17 local newproxy = newproxy; | 19 local newproxy = newproxy; |
18 local getmetatable = getmetatable; | 20 local getmetatable = getmetatable; |
19 | 21 |
20 module "sessionmanager" | 22 module "sessionmanager" |
31 local w = conn.write; | 33 local w = conn.write; |
32 session.send = function (t) w(tostring(t)); end | 34 session.send = function (t) w(tostring(t)); end |
33 return session; | 35 return session; |
34 end | 36 end |
35 | 37 |
36 function destroy_session(session) | 38 function destroy_session(session, err) |
37 (session.log or log)("info", "Destroying session"); | 39 (session.log or log)("info", "Destroying session"); |
38 | 40 |
39 -- Send unavailable presence | 41 -- Send unavailable presence |
40 if session.presence then | 42 if session.presence then |
41 local pres = st.presence{ type = "unavailable" }; | 43 local pres = st.presence{ type = "unavailable" }; |
42 if err == "closed" then err = "connection closed"; end | 44 if (not err) or err == "closed" then err = "connection closed"; end |
43 pres:tag("status"):text("Disconnected: "..err); | 45 pres:tag("status"):text("Disconnected: "..err); |
44 session.stanza_dispatch(pres); | 46 session.stanza_dispatch(pres); |
45 end | 47 end |
46 | 48 |
47 -- Remove session/resource from user's session list | 49 -- Remove session/resource from user's session list |