Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server side (Updated to continuously receive and display incoming files)
- -- Make sure the modem is open on the side you're using
- rednet.open("top") -- Replace "top" with the side where your modem is placed
- -- Function to display critical server status on the right monitor
- -- (...existing code remains unchanged...)
- -- Set to store allowed device IDs
- local allowedDevices = {}
- -- Function to request and handle device permissions
- -- (...existing code remains unchanged...)
- -- Display initial server ID on the monitor
- -- (...existing code remains unchanged...)
- while true do
- local senderID, message, protocol = rednet.receive()
- if protocol == "file_transfer" then
- if allowedDevices[senderID] then
- print("Received file '" .. message.fileName .. "' from ID: " .. senderID)
- -- Save the file to the DGOS directory
- local file = fs.open("DGOS/" .. message.fileName, "w")
- file.write(message.fileContent)
- file.close()
- print("File saved as " .. message.fileName)
- else
- print("File rejected from ID: " .. senderID)
- end
- else
- -- Assuming other protocols indicate critical information
- -- (...existing code remains unchanged...)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement