Comparison

plugins/mod_component.lua @ 7665:2e553f80aedd

mod_component: Fire 'component-disconnected' event on host, to maintain consistency - sessions with no host never authenticated. Fixes #737
author Matthew Wild <mwild1@gmail.com>
date Mon, 12 Sep 2016 22:30:37 +0100
parent 7301:995777582044
child 7666:03aa330562ed
child 7873:8d1ebb9a9b44
comparison
equal deleted inserted replaced
7664:4f145a9f1477 7665:2e553f80aedd
312 end 312 end
313 function listener.ondisconnect(conn, err) 313 function listener.ondisconnect(conn, err)
314 local session = sessions[conn]; 314 local session = sessions[conn];
315 if session then 315 if session then
316 (session.log or log)("info", "component disconnected: %s (%s)", tostring(session.host), tostring(err)); 316 (session.log or log)("info", "component disconnected: %s (%s)", tostring(session.host), tostring(err));
317 module:fire_event("component-disconnected", { session = session, reason = err }); 317 if session.host then
318 module:context(session.host):fire_event("component-disconnected", { session = session, reason = err });
319 end
318 if session.on_destroy then session:on_destroy(err); end 320 if session.on_destroy then session:on_destroy(err); end
319 sessions[conn] = nil; 321 sessions[conn] = nil;
320 for k in pairs(session) do 322 for k in pairs(session) do
321 if k ~= "log" and k ~= "close" then 323 if k ~= "log" and k ~= "close" then
322 session[k] = nil; 324 session[k] = nil;