mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#51 network file cleanup
This commit is contained in:
parent
336662de62
commit
f469754bb7
@ -73,7 +73,7 @@ end
|
||||
---@param modem table modem to use
|
||||
function network.nic(modem)
|
||||
local self = {
|
||||
connected = true,
|
||||
connected = true, -- used to avoid costly MAC calculations if modem isn't even present
|
||||
channels = {}
|
||||
}
|
||||
|
||||
@ -128,7 +128,6 @@ function network.nic(modem)
|
||||
-- if disconnected *after* opening, previousy opened channels will be re-opened on reconnection
|
||||
---@param channel integer
|
||||
function public.open(channel)
|
||||
if self.connected then
|
||||
modem.open(channel)
|
||||
|
||||
local already_open = false
|
||||
@ -143,13 +142,12 @@ function network.nic(modem)
|
||||
table.insert(self.channels, channel)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- close a channel on the modem
|
||||
---@param channel integer
|
||||
function public.close(channel)
|
||||
if self.connected then
|
||||
modem.close(channel)
|
||||
|
||||
for i = 1, #self.channels do
|
||||
if self.channels[i] == channel then
|
||||
table.remove(self.channels, i)
|
||||
@ -157,15 +155,13 @@ function network.nic(modem)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- close all channels on the modem
|
||||
function public.closeAll()
|
||||
if self.connected then
|
||||
modem.closeAll()
|
||||
|
||||
self.channels = {}
|
||||
end
|
||||
end
|
||||
|
||||
-- send a packet, with message authentication if configured
|
||||
---@param dest_channel integer destination channel
|
||||
|
Loading…
Reference in New Issue
Block a user