Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --A simple FileSharing Server
- --For CC In-Game
- --(c) 2021 by Christopher Yarch
- --a.k.a. Dusk the Dragon
- math.randomseed(os.time())
- modem = "top"
- rednet.open("top")
- domain = "fileserver"
- progList = {}
- function rednetHandler()
- id, msg = rednet.receive(domain)
- print("Incoming Message")
- --Check to see if we have a table
- if #msg > 1 then
- --Process the request.
- if msg[1] == "put" then
- print("Sharing File")
- print("Content: "..msg[2])
- local FSID = math.random(11111,99999)
- progList[FSID] = msg[2]
- print(progList[FSID])
- rednet.broadcast(FSID,domain)
- print("File Shared")
- elseif msg[1] == "get" then
- ID = tonumber(msg[2])
- print(ID)
- local prog = progList[ID]
- print(prog)
- if not prog then
- rednet.broadcast("Err404",domain)
- else
- rednet.broadcast(prog,domain)
- end
- else
- rednet.broadcast("Err400")
- end
- end
- end
- while true do
- rednetHandler()
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement