Comparison

plugins/mod_component.lua @ 9870:8f4880576835

mod_component: Set module status to indicate whether component is connected
author Matthew Wild <mwild1@gmail.com>
date Tue, 19 Mar 2019 09:08:06 +0000
parent 9784:7fa273f8869e
child 10111:0f335815244f
comparison
equal deleted inserted replaced
9869:7be5477c399e 9870:8f4880576835
47 env.session = false; 47 env.session = false;
48 48
49 local send; 49 local send;
50 50
51 local function on_destroy(session, err) --luacheck: ignore 212/err 51 local function on_destroy(session, err) --luacheck: ignore 212/err
52 module:set_status("warn", err and ("Disconnected: "..err) or "Disconnected");
52 env.connected = false; 53 env.connected = false;
53 env.session = false; 54 env.session = false;
54 send = nil; 55 send = nil;
55 session.on_destroy = nil; 56 session.on_destroy = nil;
56 end 57 end
100 session.component_validate_from = module:get_option_boolean("validate_from_addresses", true); 101 session.component_validate_from = module:get_option_boolean("validate_from_addresses", true);
101 session.type = "component"; 102 session.type = "component";
102 module:log("info", "External component successfully authenticated"); 103 module:log("info", "External component successfully authenticated");
103 session.send(st.stanza("handshake")); 104 session.send(st.stanza("handshake"));
104 module:fire_event("component-authenticated", { session = session }); 105 module:fire_event("component-authenticated", { session = session });
106 module:set_status("info", "Connected");
105 107
106 return true; 108 return true;
107 end 109 end
108 module:hook("stanza/jabber:component:accept:handshake", handle_component_auth, -1); 110 module:hook("stanza/jabber:component:accept:handshake", handle_component_auth, -1);
109 111