Comparison

plugins/mod_console.lua @ 1491:694a0a00e1a5

mod_console: Add c2s:close() command
author Matthew Wild <mwild1@gmail.com>
date Wed, 08 Jul 2009 02:29:13 +0100
parent 1483:efd19cdda6ca
child 1496:4fa337035f46
comparison
equal deleted inserted replaced
1490:b5c59667a04c 1491:694a0a00e1a5
15 local connlisteners_register = require "net.connlisteners".register; 15 local connlisteners_register = require "net.connlisteners".register;
16 16
17 local console_listener = { default_port = 5582; default_mode = "*l"; }; 17 local console_listener = { default_port = 5582; default_mode = "*l"; };
18 18
19 require "util.iterators"; 19 require "util.iterators";
20 local jid_bare = require "util.jid".bare;
20 local set, array = require "util.set", require "util.array"; 21 local set, array = require "util.set", require "util.array";
21 22
22 local commands = {}; 23 local commands = {};
23 local def_env = {}; 24 local def_env = {};
24 local default_env_mt = { __index = def_env }; 25 local default_env_mt = { __index = def_env };
318 end 319 end
319 end); 320 end);
320 return true, "Total: "..count.." secure client connections"; 321 return true, "Total: "..count.." secure client connections";
321 end 322 end
322 323
324 function def_env.c2s:close(match_jid)
325 local print, count = self.session.print, 0;
326 show_c2s(function (jid, session)
327 if jid == match_jid or jid_bare(jid) == match_jid then
328 count = count + 1;
329 session:close();
330 end
331 end);
332 return true, "Total: "..count.." sessions closed";
333 end
323 334
324 def_env.s2s = {}; 335 def_env.s2s = {};
325 function def_env.s2s:show(match_jid) 336 function def_env.s2s:show(match_jid)
326 local _print = self.session.print; 337 local _print = self.session.print;
327 local print = self.session.print; 338 local print = self.session.print;