Comparison

plugins/mod_admin_shell.lua @ 12397:ddf02f2a3354

mod_admin_shell: Add session.write() method to write data to client with no \n
author Matthew Wild <mwild1@gmail.com>
date Thu, 17 Mar 2022 10:22:47 +0000
parent 12304:8210c2a52e9c
child 12398:478fff93ac37
comparison
equal deleted inserted replaced
12396:bdb9577a4830 12397:ddf02f2a3354
81 81
82 self.data.print("Fatal error while running command, it did not complete"); 82 self.data.print("Fatal error while running command, it did not complete");
83 self.data.print("Error: "..tostring(err)); 83 self.data.print("Error: "..tostring(err));
84 end 84 end
85 85
86 local function send_repl_output(session, line) 86 local function send_repl_output(session, line, attr)
87 return session.send(st.stanza("repl-output"):text(tostring(line))); 87 return session.send(st.stanza("repl-output", attr):text(tostring(line)));
88 end 88 end
89 89
90 function console:new_session(admin_session) 90 function console:new_session(admin_session)
91 local session = { 91 local session = {
92 send = function (t) 92 send = function (t)
96 local t = {}; 96 local t = {};
97 for i=1,select("#", ...) do 97 for i=1,select("#", ...) do
98 t[i] = tostring(select(i, ...)); 98 t[i] = tostring(select(i, ...));
99 end 99 end
100 return send_repl_output(admin_session, table.concat(t, "\t")); 100 return send_repl_output(admin_session, table.concat(t, "\t"));
101 end;
102 write = function (t)
103 return send_repl_output(admin_session, t, { eol = "0" });
101 end; 104 end;
102 serialize = tostring; 105 serialize = tostring;
103 disconnect = function () admin_session:close(); end; 106 disconnect = function () admin_session:close(); end;
104 }; 107 };
105 session.env = setmetatable({}, default_env_mt); 108 session.env = setmetatable({}, default_env_mt);