fix bugs in fileshare

This commit is contained in:
Kirigaya Kazuto 2019-01-11 14:22:52 +08:00
parent 7df4924b16
commit 8f22b594d4
2 changed files with 9 additions and 4 deletions

View File

@ -40,9 +40,14 @@ if(not modem.open(22)) then
return
end
if(opts["b"]) then
print("Broadcasting at port " .. port)
modem.broadcast(port,"fs_req",filename)
else
print("Connecting to " .. server .. " at port " .. port)
print("Press Ctrl+C will stop this process")
modem.send(server,port,"fs_req",filename)
end
print("Press Ctrl+C will stop this process")
while true do
local e=WaitMultipleEvent("modem_message","interrupted")
if(e.event=="modem_message" and e.port==22) then
@ -58,7 +63,7 @@ while true do
if(not ret) then
print("[Error] Failed while writing file: " .. err)
else
print("[Done] Data written to file: " .. err)
print("[Done] Data written to file: " .. localfile)
end
f:close()
end

View File

@ -100,6 +100,6 @@ if(opts["d"]) then
PushEvent(thisid)
print("[Done] FileShare Server started.")
else -- Run in foreground
fss_server_main()
fss_server_main(print,table.pack("modem_message","fss_stop","interrupted"))
print("[Stopped] File Share Server stopped.")
end