removed copper.0.lua because it's unneccesary

This commit is contained in:
Izaya 2017-09-04 02:52:46 +10:00
parent 8b7179edfe
commit 24e5d76527
1 changed files with 0 additions and 45 deletions

View File

@ -1,45 +0,0 @@
net = {}
net.id = computer.address():sub(1,8)
net.np = 4957
net.tm = {}
function net.send(id,po,msg) -- id, port, message
event.push("sendmsg",id,po,msg)
end
if cdlib then
spawn("copper.0 daemon",function() print(pcall(function ()
local pt = {}
for a,t in component.list("modem") do
table.insert(net.tm,component.proxy(a))
component.proxy(a).open(net.np)
end
while true do
local ev = {event.pull()}
if ev[1] == "rsendmsg" then
dst,data = ev[2],ev[3]
for k,v in ipairs(net.tm) do
v.broadcast(net.np,"copper",cdlib.encode(0,net.id,dst,data))
end
elseif ev[1] == "modem_message" and ev[4] == net.np and ev[6] == "copper" then
local hops,src,dst,data = cdlib.decode(ev[7])
if not pt[ev[7]:sub(2)] then
pt[ev[7]:sub(2)] = os.time()
if dst == net.id then
event.push("net_rmsg",src,data)
else
for k,v in ipairs(net.tm) do
v.broadcast(net.np,cdlib.encode(hops+1,src,dst,data))
end
end
end
end
if #pt > 63 then
local cot = os.time()
for k,v in pairs(pt) do
if v < cot-5 then
pt[k] = nil
end
end
end
end
end)) end)
end