annotate mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua @ 48:7fbaf590dc12

mod_adhoc_cmd_admin: Fix session leak
author Florian Zeitz <florob@babelmonkeys.de>
date Sat, 17 Oct 2009 01:36:25 +0200
parents 58d326d86a9a
children 9b63fd1196c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
1 -- Copyright (C) 2009 Thilo Cestonaro
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
2 --
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
3 -- This file is MIT/X11 licensed. Please see the
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
4 -- COPYING file in the source package for more information.
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
5 --
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
6
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
7 local st = require "util.stanza";
36
58d326d86a9a mod_adhoc: add adhoc.lib.lua to ease implementing new commands (as a consequence mod_adhoc is a directory now)
Florian Zeitz <florob@babelmonkeys.de>
parents: 28
diff changeset
8 local adhoc_new = module:require "adhoc".new;
7
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
9
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
10 function ping_command_handler (item, origin, stanza)
9
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
11 local now = os.date("%Y-%m-%dT%X");
36
58d326d86a9a mod_adhoc: add adhoc.lib.lua to ease implementing new commands (as a consequence mod_adhoc is a directory now)
Florian Zeitz <florob@babelmonkeys.de>
parents: 28
diff changeset
12 origin.send(st.reply(stanza):add_child(item:cmdtag("completed", now):tag("note", {type="info"}):text("Pong\n" .. now)));
7
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
13 return true;
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
14 end
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
15
36
58d326d86a9a mod_adhoc: add adhoc.lib.lua to ease implementing new commands (as a consequence mod_adhoc is a directory now)
Florian Zeitz <florob@babelmonkeys.de>
parents: 28
diff changeset
16 local descriptor = adhoc_new("Ping", "ping", ping_command_handler);
9
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
17
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
18 function module.unload()
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
19 module:remove_item("adhoc", descriptor);
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
20 end
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
21
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
22 module:add_item ("adhoc", descriptor);
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
23