feat: optimize net.sendMultipleRequests function
This commit is contained in:
parent
e94616313e
commit
f6dc7bdef9
12
apis/net.lua
12
apis/net.lua
@ -1,4 +1,4 @@
|
||||
local _VERSION = '2.1.1';
|
||||
local _VERSION = '2.1.2';
|
||||
|
||||
local createEventLoop = require('/apis/eventloop');
|
||||
|
||||
@ -162,6 +162,16 @@ local function createNetwork(el, modem, routingChannel, timeoutInSec)
|
||||
end
|
||||
|
||||
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 results = {};
|
||||
local packetResults = {};
|
||||
|
||||
@ -6,7 +6,7 @@ local SERVERS = {
|
||||
"servers/cube-startup.lua",
|
||||
};
|
||||
|
||||
if periphemu then
|
||||
local periphEmulation = function()
|
||||
-- attach modem
|
||||
periphemu.create('top', 'modem');
|
||||
|
||||
@ -25,6 +25,10 @@ if periphemu then
|
||||
end
|
||||
end
|
||||
|
||||
if periphemu then
|
||||
periphEmulation();
|
||||
end
|
||||
|
||||
local function shellFn()
|
||||
os.sleep(0.1);
|
||||
shell.run("shell");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user