comparison mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua @ 37:6018c0370d89

merge
author Thilo Cestonaro <thilo@cestona.ro>
date Mon, 12 Oct 2009 23:09:21 +0200
parents 58d326d86a9a
children 9b63fd1196c0
comparison
equal deleted inserted replaced
31:a0dfa3e5883c 37:6018c0370d89
3 -- This file is MIT/X11 licensed. Please see the 3 -- This file is MIT/X11 licensed. Please see the
4 -- COPYING file in the source package for more information. 4 -- COPYING file in the source package for more information.
5 -- 5 --
6 6
7 local st = require "util.stanza"; 7 local st = require "util.stanza";
8 local adhoc_new = module:require "adhoc".new;
8 9
9 function ping_command_handler (item, origin, stanza) 10 function ping_command_handler (item, origin, stanza)
10 local now = os.date("%Y-%m-%dT%X"); 11 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}) 12 origin.send(st.reply(stanza):add_child(item:cmdtag("completed", now):tag("note", {type="info"}):text("Pong\n" .. now)));
12 :tag("note", {type="info"}):text("Pong\n" .. now));
13 return true; 13 return true;
14 end 14 end
15 15
16 local descriptor = { name="Ping", node="ping", handler=ping_command_handler }; 16 local descriptor = adhoc_new("Ping", "ping", ping_command_handler);
17 17
18 function module.unload() 18 function module.unload()
19 module:remove_item("adhoc", descriptor); 19 module:remove_item("adhoc", descriptor);
20 end 20 end
21 21