mod_component: Fire 'component-disconnected' event on host, to maintain consistency - sessions with no host never authenticated. Fixes #737

This commit is contained in:
Matthew Wild 2016-09-12 22:30:37 +01:00
parent 503a9c65cd
commit cd10e4439e

View file

@ -314,7 +314,9 @@ function listener.ondisconnect(conn, err)
local session = sessions[conn];
if session then
(session.log or log)("info", "component disconnected: %s (%s)", tostring(session.host), tostring(err));
module:fire_event("component-disconnected", { session = session, reason = err });
if session.host then
module:context(session.host):fire_event("component-disconnected", { session = session, reason = err });
end
if session.on_destroy then session:on_destroy(err); end
sessions[conn] = nil;
for k in pairs(session) do