2017-05-24 01:14:23 +10:00
|
|
|
tM,nP,nID,nVL = {}, 4096, computer.address():sub(1,8), 1
|
2017-04-19 02:40:25 +10:00
|
|
|
for a,t in component.list("modem") do
|
|
|
|
table.insert(tM,component.proxy(a))
|
2017-05-08 10:10:45 +10:00
|
|
|
component.proxy(a).open(nVL)
|
2017-04-19 02:40:25 +10:00
|
|
|
end
|
|
|
|
function ns(id,po,msg)
|
|
|
|
h("sendmsg",id,po,msg)
|
|
|
|
end
|
|
|
|
s("network daemon",function ()
|
|
|
|
while true do
|
|
|
|
if ev[1] == "sendmsg" then
|
|
|
|
local eT = ev
|
|
|
|
for k,v in ipairs(tM) do
|
2017-05-08 10:10:45 +10:00
|
|
|
v.broadcast(nVL,nP,eT[2],nID,eT[3],eT[4])
|
2017-04-19 02:40:25 +10:00
|
|
|
end
|
|
|
|
elseif ev[1] == "modem_message" then
|
2017-05-08 10:10:45 +10:00
|
|
|
if ev[7] == nID then
|
|
|
|
h("net_msg",ev[8],ev[9],ev[10])
|
2017-04-19 02:40:25 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
C.yield()
|
|
|
|
end
|
|
|
|
end)
|