cluster.open添加maxclient参数 (#1705)

This commit is contained in:
丁大龙
2023-02-18 00:57:39 +08:00
committed by GitHub
parent f344a49755
commit 6fe520a7cb
2 changed files with 6 additions and 6 deletions

View File

@@ -75,11 +75,11 @@ function cluster.send(node, address, ...)
end end
end end
function cluster.open(port) function cluster.open(port, maxclient)
if type(port) == "string" then if type(port) == "string" then
return skynet.call(clusterd, "lua", "listen", port) return skynet.call(clusterd, "lua", "listen", port, nil, maxclient)
else else
return skynet.call(clusterd, "lua", "listen", "0.0.0.0", port) return skynet.call(clusterd, "lua", "listen", "0.0.0.0", port, maxclient)
end end
end end

View File

@@ -142,17 +142,17 @@ function command.reload(source, config)
skynet.ret(skynet.pack(nil)) skynet.ret(skynet.pack(nil))
end end
function command.listen(source, addr, port) function command.listen(source, addr, port, maxclient)
local gate = skynet.newservice("gate") local gate = skynet.newservice("gate")
if port == nil then if port == nil then
local address = assert(node_address[addr], addr .. " is down") local address = assert(node_address[addr], addr .. " is down")
addr, port = string.match(address, "(.+):([^:]+)$") addr, port = string.match(address, "(.+):([^:]+)$")
port = tonumber(port) port = tonumber(port)
assert(port ~= 0) assert(port ~= 0)
skynet.call(gate, "lua", "open", { address = addr, port = port }) skynet.call(gate, "lua", "open", { address = addr, port = port, maxclient = maxclient })
skynet.ret(skynet.pack(addr, port)) skynet.ret(skynet.pack(addr, port))
else else
local realaddr, realport = skynet.call(gate, "lua", "open", { address = addr, port = port }) local realaddr, realport = skynet.call(gate, "lua", "open", { address = addr, port = port, maxclient = maxclient })
skynet.ret(skynet.pack(realaddr, realport)) skynet.ret(skynet.pack(realaddr, realport))
end end
end end