comparison mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua @ 9:2be8bcce5b18

thx to Florob: add remove_item support to mod_addhoc and reload support to mod_adhoc_cmd_ping the returned pong shows the time in the note
author ephraim@errorm.fritz.box
date Fri, 25 Sep 2009 20:33:14 +0200
parents 473b14c59797
children b9d063dd16d5
comparison
equal deleted inserted replaced
8:10502594a49b 9:2be8bcce5b18
5 -- 5 --
6 6
7 local st = require "util.stanza"; 7 local st = require "util.stanza";
8 8
9 function ping_command_handler (item, origin, stanza) 9 function ping_command_handler (item, origin, stanza)
10 local now = os.date("%Y-%m-%dT%X") 10 local now = os.date("%Y-%m-%dT%X");
11 origin.send(st.reply(stanza):tag("command", {xmlns="http://jabber.org/protocol/commands", status="completed", node=item.node, sessionid=now}) 11 origin.send(st.reply(stanza):tag("command", {xmlns="http://jabber.org/protocol/commands", status="completed", node=item.node, sessionid=now})
12 :tag("note", {type="info"}):text(item.name)); 12 :tag("note", {type="info"}):text("Pong\n" .. now));
13 return true; 13 return true;
14 end 14 end
15 15
16 module:add_item ("adhoc", { name="Ping", node="ping", handler=ping_command_handler }); 16 local descriptor = { name="Ping", node="ping", handler=ping_command_handler };
17
18 function module.unload()
19 module:log("debug", "Removing ping command");
20 module:remove_item("adhoc", descriptor);
21 end
22
23 module:add_item ("adhoc", descriptor);
24