24 lines
716 B
Lua
24 lines
716 B
Lua
function _G.net_send(id,po,msg) -- id, port, message
|
|
event.push("sendmsg",id,po,msg)
|
|
end
|
|
spawn("network daemon",function ()
|
|
tM,nP,_G.nID,nVL = {}, 4096, computer.address():sub(1,8), 1
|
|
for a,t in component.list("modem") do -- open the port of the vlan on all network interfaces
|
|
table.insert(tM,component.proxy(a))
|
|
component.proxy(a).open(nVL)
|
|
end
|
|
while true do
|
|
local ev = {event.pull()} -- this totally isn't just MultICE code with a fancy wrapper
|
|
if ev[1] == "sendmsg" then
|
|
local eT = ev
|
|
for k,v in ipairs(tM) do
|
|
v.broadcast(nVL,nP,eT[2],nID,eT[3],eT[4])
|
|
end
|
|
elseif ev[1] == "modem_message" then
|
|
if ev[7] == nID then
|
|
event.push("net_msg",ev[8],ev[9],ev[10])
|
|
end
|
|
end
|
|
end
|
|
end)
|