made the network driver use _G.net for configuration.
This commit is contained in:
parent
308c0acad5
commit
581edc74a1
@ -1,21 +1,25 @@
|
|||||||
function _G.net_send(id,po,msg) -- id, port, message
|
net = {}
|
||||||
|
net.id = computer.address():sub(1,8)
|
||||||
|
net.vlan = 1
|
||||||
|
net.np = 4096
|
||||||
|
net.tm = {}
|
||||||
|
function net.send(id,po,msg) -- id, port, message
|
||||||
event.push("sendmsg",id,po,msg)
|
event.push("sendmsg",id,po,msg)
|
||||||
end
|
end
|
||||||
spawn("network daemon",function ()
|
spawn("network daemon",function ()
|
||||||
tM,nP,_G.nID,nVL = {}, 4096, computer.address():sub(1,8), 1
|
for a,t in component.list("modem") do
|
||||||
for a,t in component.list("modem") do -- open the port of the vlan on all network interfaces
|
table.insert(net.tm,component.proxy(a))
|
||||||
table.insert(tM,component.proxy(a))
|
component.proxy(a).open(net.vlan)
|
||||||
component.proxy(a).open(nVL)
|
|
||||||
end
|
end
|
||||||
while true do
|
while true do
|
||||||
local ev = {event.pull()} -- this totally isn't just MultICE code with a fancy wrapper
|
local ev = {event.pull()}
|
||||||
if ev[1] == "sendmsg" then
|
if ev[1] == "sendmsg" then
|
||||||
local eT = ev
|
local eT = ev
|
||||||
for k,v in ipairs(tM) do
|
for k,v in ipairs(net.tm) do
|
||||||
v.broadcast(nVL,nP,eT[2],nID,eT[3],eT[4])
|
v.broadcast(net.vlan,net.np,eT[2],net.id,eT[3],eT[4])
|
||||||
end
|
end
|
||||||
elseif ev[1] == "modem_message" then
|
elseif ev[1] == "modem_message" then
|
||||||
if ev[7] == nID then
|
if ev[7] == net.id then
|
||||||
event.push("net_msg",ev[8],ev[9],ev[10])
|
event.push("net_msg",ev[8],ev[9],ev[10])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user