feat: optimize net.sendMultipleRequests function

This commit is contained in:
Guillaume ARM 2022-07-18 02:07:42 +02:00
parent e94616313e
commit f6dc7bdef9
2 changed files with 16 additions and 2 deletions

View File

@ -1,4 +1,4 @@
local _VERSION = '2.1.1'; local _VERSION = '2.1.2';
local createEventLoop = require('/apis/eventloop'); local createEventLoop = require('/apis/eventloop');
@ -162,6 +162,16 @@ local function createNetwork(el, modem, routingChannel, timeoutInSec)
end end
local function sendMultipleRequests(channel, eventType, payload, destId) local function sendMultipleRequests(channel, eventType, payload, destId)
if destId ~= nil and tonumber(destId) ~= nil then
local ok, res, packet = sendRequest(channel, eventType, payload, destId);
if not ok then
return ok, res, packet
end
return ok, { res }, { packet };
end
local ok = false; local ok = false;
local results = {}; local results = {};
local packetResults = {}; local packetResults = {};

View File

@ -6,7 +6,7 @@ local SERVERS = {
"servers/cube-startup.lua", "servers/cube-startup.lua",
}; };
if periphemu then local periphEmulation = function()
-- attach modem -- attach modem
periphemu.create('top', 'modem'); periphemu.create('top', 'modem');
@ -25,6 +25,10 @@ if periphemu then
end end
end end
if periphemu then
periphEmulation();
end
local function shellFn() local function shellFn()
os.sleep(0.1); os.sleep(0.1);
shell.run("shell"); shell.run("shell");