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