Add server.lua
This commit is contained in:
parent
4d5f826e63
commit
da2accfc67
25
dominic/server.lua
Normal file
25
dominic/server.lua
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
rednet.open("back")
|
||||||
|
|
||||||
|
curjob = 20
|
||||||
|
|
||||||
|
function getNextJob()
|
||||||
|
curjob = curjob + 1
|
||||||
|
return curjob
|
||||||
|
end
|
||||||
|
|
||||||
|
while true do
|
||||||
|
sender, message, proto = rednet.receive("jobs")
|
||||||
|
if not message then
|
||||||
|
sleep(0.6)
|
||||||
|
else
|
||||||
|
if message == "gibjob" then
|
||||||
|
job = getNextJob()
|
||||||
|
rednet.broadcast(tostring(job), "newjob")
|
||||||
|
print("Found request for job. Offering "..tostring(job))
|
||||||
|
else
|
||||||
|
-- numberic job is complete
|
||||||
|
completejob = tonumber(message)
|
||||||
|
print("Job "..tostring(completejob).." was completed")
|
||||||
|
rednet.broadcast("thanks", "jobcomplete")
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user