mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-27 04:18:05 +11:00
implemented keepalives
This commit is contained in:
parent
f254ededac
commit
1559364799
@ -84,9 +84,11 @@ spawn(clientLoop)
|
|||||||
function pushLoop()
|
function pushLoop()
|
||||||
while true do
|
while true do
|
||||||
for id,msg in pairs(messages) do
|
for id,msg in pairs(messages) do
|
||||||
for k,client in pairs(clients) do
|
if msg:len() > 3 then
|
||||||
client.conn:send(msg)
|
for k,client in pairs(clients) do
|
||||||
reprint("Message #"..tostring(id).." -> Client #"..tostring(k).." - "..msg)
|
client.conn:send(msg)
|
||||||
|
reprint("Message #"..tostring(id).." -> Client #"..tostring(k).." - "..msg)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
messages[id] = nil
|
messages[id] = nil
|
||||||
end
|
end
|
||||||
|
@ -7,6 +7,7 @@ local internet = component.internet
|
|||||||
local tArgs = {...}
|
local tArgs = {...}
|
||||||
|
|
||||||
local addr, raddr = vcomp.uuid(),vcomp.uuid()
|
local addr, raddr = vcomp.uuid(),vcomp.uuid()
|
||||||
|
local poll, keepalive = tonumber(tArgs[3]) or 5, tonumber(tArgs[4]) or 30
|
||||||
|
|
||||||
local socket = internet.connect(tArgs[1],tonumber(tArgs[2]))
|
local socket = internet.connect(tArgs[1],tonumber(tArgs[2]))
|
||||||
repeat
|
repeat
|
||||||
@ -16,7 +17,7 @@ until socket.finishConnect()
|
|||||||
local proxy = {}
|
local proxy = {}
|
||||||
local rbuffer = ""
|
local rbuffer = ""
|
||||||
|
|
||||||
local timer = event.timer(5,function()
|
local timer = event.timer(poll,function()
|
||||||
rbuffer=rbuffer..(socket.read(4096) or "")
|
rbuffer=rbuffer..(socket.read(4096) or "")
|
||||||
if imt.decodePacket(rbuffer) then
|
if imt.decodePacket(rbuffer) then
|
||||||
computer.pushSignal("modem_message",addr,raddr,0,0,imt.decodePacket(rbuffer))
|
computer.pushSignal("modem_message",addr,raddr,0,0,imt.decodePacket(rbuffer))
|
||||||
@ -24,6 +25,10 @@ local timer = event.timer(5,function()
|
|||||||
end
|
end
|
||||||
end,math.huge)
|
end,math.huge)
|
||||||
|
|
||||||
|
local katimer = event.timer(keepalive,function()
|
||||||
|
socket.write("\0\1\0")
|
||||||
|
end,math.huge)
|
||||||
|
|
||||||
function proxy.send(...)
|
function proxy.send(...)
|
||||||
socket.write(imt.encodePacket(...))
|
socket.write(imt.encodePacket(...))
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user