diff --git a/libs/net.lua b/libs/net.lua index 7ca8c62..b05bc2b 100644 --- a/libs/net.lua +++ b/libs/net.lua @@ -15,9 +15,15 @@ net.listenQuery = function(hostname, processQueryMessage) rednet.host(QUERY_PROTO, hostname) - while true do + local serverRunning = true + + local function stopServer() + serverRunning = false + end + + while serverRunning do local computerId, message = rednet.receive(QUERY_PROTO) - local responseMessage = processQueryMessage(textutils.unserialize(message), computerId) + local responseMessage = processQueryMessage(textutils.unserialize(message), computerId, stopServer) rednet.send(computerId, textutils.serialize(responseMessage), QUERY_RESPONSE_PROTO) end