Comparison

plugins/mod_admin_telnet.lua @ 10292:8fb546e40756

mod_admin_telnet: Use new compact function for waiting on promises
author Kim Alvefur <zash@zash.se>
date Sun, 29 Sep 2019 18:44:58 +0200
parent 10252:aa3f98853816
child 10310:b03065cd033a
comparison
equal deleted inserted replaced
10291:7b48b620164c 10292:8fb546e40756
1146 elseif prosody.hosts[remotehost] then 1146 elseif prosody.hosts[remotehost] then
1147 return nil, "Both hosts are local"; 1147 return nil, "Both hosts are local";
1148 end 1148 end
1149 local iq = st.iq{ from=localhost, to=remotehost, type="get", id=new_id()} 1149 local iq = st.iq{ from=localhost, to=remotehost, type="get", id=new_id()}
1150 :tag("ping", {xmlns="urn:xmpp:ping"}); 1150 :tag("ping", {xmlns="urn:xmpp:ping"});
1151 local ret, err; 1151 local ret, err = async.wait(module:context(localhost):send_iq(iq, nil, timeout));
1152 local wait, done = async.waiter();
1153 module:context(localhost):send_iq(iq, nil, timeout)
1154 :next(function (ret_) ret = ret_; end,
1155 function (err_) err = err_; end)
1156 :finally(done);
1157 wait();
1158 if ret then 1152 if ret then
1159 return true, "pong from " .. ret.stanza.attr.from; 1153 return true, "pong from " .. ret.stanza.attr.from;
1160 else 1154 else
1161 return false, tostring(err); 1155 return false, tostring(err);
1162 end 1156 end