feat(net): stopServer function for net.listenQuery
This commit is contained in:
parent
3f92309ac6
commit
5305afe203
10
libs/net.lua
10
libs/net.lua
@ -15,9 +15,15 @@ net.listenQuery = function(hostname, processQueryMessage)
|
|||||||
|
|
||||||
rednet.host(QUERY_PROTO, hostname)
|
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 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)
|
rednet.send(computerId, textutils.serialize(responseMessage), QUERY_RESPONSE_PROTO)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user