Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- client
- local modemSide = "right"
- local serverId = 6
- rednet.open(modemSide)
- local function updateFile(name)
- print('sending file request for: '..name)
- rednet.send(serverId, name)
- while true do
- print('waiting for response')
- local event, id, msg, dist = os.pullEvent("rednet_message")
- if id == serverId then
- msg = textutils.unserialize(msg)
- if not msg.success then
- printError(msg.message)
- else
- local handle = fs.open(msg.path, "w")
- if not handle then
- printError("Failed to open file to update")
- elseif not msg.message then
- printError("No contents received")
- else
- handle.write(msg.message)
- handle.close()
- end
- end
- return -- exit out of the function, we are done here
- else
- printError('response from unknown client')
- end
- end
- end
- updateFile("cake")
- updateFile("can")
- updateFile("someFile")
- rednet.close(modemSide)
Advertisement
Add Comment
Please, Sign In to add comment