1
0
mirror of https://github.com/kepler155c/opus synced 2025-10-24 12:17:40 +00:00

convert to event api

This commit is contained in:
kepler155c@gmail.com
2017-08-03 01:46:39 -04:00
parent 252fb16853
commit a1660fd073
6 changed files with 80 additions and 108 deletions

View File

@@ -6,7 +6,8 @@ multishell.setTitle(multishell.getCurrent(), 'Net Daemon')
_G.network = { }
local function netUp()
local process = require('process')
require = requireInjector(getfenv(1))
local Event = require('event')
local files = fs.list('/sys/network')
@@ -19,19 +20,20 @@ local function netUp()
end
end
while true do
local e = process:pullEvent('device_detach')
if not device.wireless_modem or e == 'terminate' then
for _,c in pairs(network) do
c.active = false
os.queueEvent('network_detach', c)
end
os.queueEvent('network_down')
process:pullEvent('network_down')
process:threadEvent('terminate')
break
Event.on('device_detach', function()
if not device.wireless_modem then
Event.exitPullEvents()
end
end)
Event.pullEvents()
for _,c in pairs(network) do
c.active = false
os.queueEvent('network_detach', c)
end
os.queueEvent('network_down')
Event.pullEvent('network_down')
Util.clear(_G.network)
end