comparison mod_component_client/mod_component_client.lua @ 1208:defa479a7d53

mod_component_client: Fire connect (logged in) and disconnect events
author Waqas Hussain <waqas20@gmail.com>
date Fri, 11 Oct 2013 16:56:06 -0400
parents 8b14cdfe0213
children fc39f78e2b36
comparison
equal deleted inserted replaced
1207:c6b8ae5a8369 1208:defa479a7d53
89 end 89 end
90 90
91 module:hook("stanza/jabber:component:accept:handshake", function(event) 91 module:hook("stanza/jabber:component:accept:handshake", function(event)
92 session.type = "component"; 92 session.type = "component";
93 module:log("debug", "Handshake complete"); 93 module:log("debug", "Handshake complete");
94 module:fire_event("component_client/connected", {});
94 return true; -- READY! 95 return true; -- READY!
95 end); 96 end);
96 97
97 module:hook("route/remote", function(event) 98 module:hook("route/remote", function(event)
98 return session and session.send(event.stanza); 99 return session and session.send(event.stanza);
208 session.destroyed = true; 209 session.destroyed = true;
209 session = nil; 210 session = nil;
210 end 211 end
211 __conn = nil; 212 __conn = nil;
212 module:log("error", "connection lost"); 213 module:log("error", "connection lost");
214 module:fire_event("component_client/disconnected", { reason = err });
213 end 215 end
214 216
215 function connect() 217 function connect()
216 ------------------------ 218 ------------------------
217 -- Taken from net.http 219 -- Taken from net.http