24 lines
551 B
Lua
24 lines
551 B
Lua
local createNet = require("/apis/net")
|
|
local createVersion = require("/apis/libversion")
|
|
|
|
local MODEM_DETECTION_TIME = 3
|
|
|
|
if not peripheral.find("modem") then
|
|
print("Warning: modem not found!")
|
|
end
|
|
|
|
-- TOFIX: os.sleep should not be used anymore since we are in the main eventloop here.
|
|
while not peripheral.find("modem") do
|
|
os.sleep(MODEM_DETECTION_TIME)
|
|
end
|
|
|
|
local net = createNet()
|
|
|
|
net.serve("ping", function(message, reply)
|
|
if message == "ping" then
|
|
reply("pong")
|
|
end
|
|
end)
|
|
|
|
print("ping-server v" .. createVersion().forSelf() .. " started.")
|