Advertisement
DOGGYWOOF

server - active data

Jan 8th, 2024
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. -- Server side (Updated to continuously receive and display incoming files)
  2. -- Make sure the modem is open on the side you're using
  3. rednet.open("top") -- Replace "top" with the side where your modem is placed
  4.  
  5. -- Function to display critical server status on the right monitor
  6. -- (...existing code remains unchanged...)
  7.  
  8. -- Set to store allowed device IDs
  9. local allowedDevices = {}
  10.  
  11. -- Function to request and handle device permissions
  12. -- (...existing code remains unchanged...)
  13.  
  14. -- Display initial server ID on the monitor
  15. -- (...existing code remains unchanged...)
  16.  
  17. while true do
  18. local senderID, message, protocol = rednet.receive()
  19.  
  20. if protocol == "file_transfer" then
  21. if allowedDevices[senderID] then
  22. print("Received file '" .. message.fileName .. "' from ID: " .. senderID)
  23.  
  24. -- Save the file to the DGOS directory
  25. local file = fs.open("DGOS/" .. message.fileName, "w")
  26. file.write(message.fileContent)
  27. file.close()
  28.  
  29. print("File saved as " .. message.fileName)
  30. else
  31. print("File rejected from ID: " .. senderID)
  32. end
  33. else
  34. -- Assuming other protocols indicate critical information
  35. -- (...existing code remains unchanged...)
  36. end
  37. end
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement