Software /
code /
prosody
Comparison
plugins/mod_component.lua @ 7300:66e7517bd8f3
mod_component: Fire event when component disconnects
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 18 Mar 2016 13:58:55 +0000 |
parent | 6913:c7a0d5299933 |
child | 7301:995777582044 |
comparison
equal
deleted
inserted
replaced
7299:b7dea8fd09c7 | 7300:66e7517bd8f3 |
---|---|
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.on_destroy then session:on_destroy(err); end | 318 if session.on_destroy then session:on_destroy(err); end |
318 sessions[conn] = nil; | 319 sessions[conn] = nil; |
319 for k in pairs(session) do | 320 for k in pairs(session) do |
320 if k ~= "log" and k ~= "close" then | 321 if k ~= "log" and k ~= "close" then |
321 session[k] = nil; | 322 session[k] = nil; |