mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua
changeset 9 2be8bcce5b18
parent 7 473b14c59797
child 28 b9d063dd16d5
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