function run_read_qr()
local sIP = ui:getSetting_l('qr_code_from_ip');
if #sIP <= 0 then
ui:setSetting_l('qr_code_from_ip', '');
return;
end
local sPort = ui:getSetting_l('qr_code_from_port');
if #sPort <= 0 then
ui:setSetting_l('qr_code_from_port', '');
return;
elseif tonumber(sPort) == nil then
return;
end
local tcp = CTNLuaTcpClient();
tcp:setServer(tonumber(sPort), sIP);
local sv = CTNString();
local sDlgUI = CTNString();
local sDlgName = CTNString();
local sTmp = '';
while true do
while true do
if ui:allThreadStop() then return end
sv:set('');
if tcp:isLogin() == false then
if tcp:login() == false then
break;
end
end
tcp:recvMsg(sv, '\r', 1000);
if string.len(sv:get()) > 0 then
sTmp = sv:get();
print('读取到:'..sTmp);
sTmp = string.gsub(sTmp, '\r', '');
sTmp = string.gsub(sTmp, '\n', '');
ui:threadChangeValue('调用主线程函数()');
end
cutil:sleep(200);
break;
end
end
end
ui:run('run_read_qr()', '');