Mercurial > prosody-hg
comparison core/sessionmanager.lua @ 126:63863534b1f1
Final fix for marking user offline when all resources are gone :)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 23 Oct 2008 18:05:06 +0100 |
| parents | 6b6b8f4ab7e3 |
| children | fbb3a4ff9cf1 40e443eacbbd |
comparison
equal
deleted
inserted
replaced
| 125:6b6b8f4ab7e3 | 126:63863534b1f1 |
|---|---|
| 1 | 1 |
| 2 local tonumber, tostring = tonumber, tostring; | 2 local tonumber, tostring = tonumber, tostring; |
| 3 local ipairs, pairs, print= ipairs, pairs, print; | 3 local ipairs, pairs, print, next= ipairs, pairs, print, next; |
| 4 local collectgarbage = collectgarbage; | 4 local collectgarbage = collectgarbage; |
| 5 local m_random = import("math", "random"); | 5 local m_random = import("math", "random"); |
| 6 local format = import("string", "format"); | 6 local format = import("string", "format"); |
| 7 | 7 |
| 8 local hosts = hosts; | 8 local hosts = hosts; |
| 37 session.log("info", "Destroying session"); | 37 session.log("info", "Destroying session"); |
| 38 if session.username then | 38 if session.username then |
| 39 if session.resource then | 39 if session.resource then |
| 40 hosts[session.host].sessions[session.username].sessions[session.resource] = nil; | 40 hosts[session.host].sessions[session.username].sessions[session.resource] = nil; |
| 41 end | 41 end |
| 42 if not next(hosts[session.host].sessions[session.username], nil) then | 42 |
| 43 if not next(hosts[session.host].sessions[session.username].sessions) then | |
| 44 log("debug", "All resources of %s are now offline", session.username); | |
| 43 hosts[session.host].sessions[session.username] = nil; | 45 hosts[session.host].sessions[session.username] = nil; |
| 44 end | 46 end |
| 45 end | 47 end |
| 46 session.conn = nil; | 48 session.conn = nil; |
| 47 session.disconnect = nil; | 49 session.disconnect = nil; |
