annotate mod_adhoc_cmd_ping/mod_adhoc_cmd_ping.lua @ 18:2df11ec081fe

mod_privacy: make finding the right session working
author Thilo Cestonaro <thilo@cestona.ro>
date Mon, 28 Sep 2009 22:36:01 +0200
parents 2be8bcce5b18
children b9d063dd16d5
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";
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
8
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
9 function ping_command_handler (item, origin, stanza)
9
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
10 local now = os.date("%Y-%m-%dT%X");
7
473b14c59797 adds mod_adhoc_cmd_ping which provides 'ping' adhoc command.
Thilo Cestonaro <thilo@cestona.ro>
parents:
diff changeset
11 origin.send(st.reply(stanza):tag("command", {xmlns="http://jabber.org/protocol/commands", status="completed", node=item.node, sessionid=now})
9
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
12 :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
9
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
16 local descriptor = { name="Ping", node="ping", handler=ping_command_handler };
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:log("debug", "Removing ping command");
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
20 module:remove_item("adhoc", descriptor);
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
21 end
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
22
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
23 module:add_item ("adhoc", descriptor);
2be8bcce5b18 thx to Florob:
ephraim@errorm.fritz.box
parents: 7
diff changeset
24