mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-23 10:38:05 +11:00
made listen and flisten care what is sent to them
This commit is contained in:
parent
6240fe7218
commit
e891f0d220
@ -113,7 +113,7 @@ end
|
||||
function net.listen(port)
|
||||
repeat
|
||||
_, from, rport, data = event.pull("net_msg")
|
||||
until rport == port
|
||||
until rport == port and data == "openstream"
|
||||
local nport = math.random(net.minport,net.maxport)
|
||||
local sclose = net.genPacketID()
|
||||
net.rsend(from,rport,tostring(nport))
|
||||
@ -121,4 +121,18 @@ function net.listen(port)
|
||||
return socket(from,nport,sclose)
|
||||
end
|
||||
|
||||
function net.flisten(port,listener)
|
||||
local function helper(_,from,rport,data)
|
||||
if rport == port and data == "openstream" then
|
||||
local nport = math.random(net.minport,net.maxport)
|
||||
local sclose = net.genPacketID()
|
||||
net.rsend(from,rport,tostring(nport))
|
||||
net.rsend(from,nport,sclose)
|
||||
listener(socket(from,nport,sclose))
|
||||
end
|
||||
end
|
||||
event.listen("net_msg",helper)
|
||||
return helper
|
||||
end
|
||||
|
||||
return net
|
||||
|
Loading…
Reference in New Issue
Block a user