mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-27 04:18:05 +11:00
added hook support to microtel-3 for use with microtel-5
This commit is contained in:
parent
cad7de5c38
commit
10ad65a7ec
@ -1,7 +1,7 @@
|
|||||||
_G.net={}
|
_G.net={}
|
||||||
do
|
do
|
||||||
local M,pQ,pC,rC,C,Y={},{},{},{},computer,table.unpack
|
local M,pQ,pC,rC,C,Y={},{},{},{},computer,table.unpack
|
||||||
net.port,net.hostname,net.route,U=4096,C.address():sub(1,8),true,C.uptime
|
net.port,net.hostname,net.route,net.hook,U=4096,C.address():sub(1,8),true,{},C.uptime
|
||||||
for a in component.list("modem") do
|
for a in component.list("modem") do
|
||||||
M[a]=component.proxy(a)
|
M[a]=component.proxy(a)
|
||||||
M[a].open(net.port)
|
M[a].open(net.port)
|
||||||
@ -39,6 +39,9 @@ end
|
|||||||
local rCPE=C.pullSignal
|
local rCPE=C.pullSignal
|
||||||
function C.pullSignal(t)
|
function C.pullSignal(t)
|
||||||
local Z={rCPE(t)}
|
local Z={rCPE(t)}
|
||||||
|
for k,v in pairs(net.hook) do
|
||||||
|
pcall(v,Y(Z))
|
||||||
|
end
|
||||||
for k,v in pairs(pC) do
|
for k,v in pairs(pC) do
|
||||||
if U()>v+30 then
|
if U()>v+30 then
|
||||||
pC[k]=nil
|
pC[k]=nil
|
||||||
|
@ -2,7 +2,7 @@ _G.net={}
|
|||||||
|
|
||||||
do
|
do
|
||||||
local modems,packetQueue,packetCache,routeCache,C,Y = {},{},{},{},COMPUTER,UNPACK
|
local modems,packetQueue,packetCache,routeCache,C,Y = {},{},{},{},COMPUTER,UNPACK
|
||||||
net.port,net.hostname,net.route,U=4096,computer.address():sub(1,8),true,UPTIME
|
net.port,net.hostname,net.route,net.hook,U=4096,computer.address():sub(1,8),true,{},UPTIME
|
||||||
|
|
||||||
for a in component.list("modem") do
|
for a in component.list("modem") do
|
||||||
modems[a] = component.proxy(a)
|
modems[a] = component.proxy(a)
|
||||||
@ -46,6 +46,9 @@ end
|
|||||||
local realComputerPullSignal = computer.pullSignal
|
local realComputerPullSignal = computer.pullSignal
|
||||||
function computer.pullSignal(t)
|
function computer.pullSignal(t)
|
||||||
local eventTab = {realComputerPullSignal(t)}
|
local eventTab = {realComputerPullSignal(t)}
|
||||||
|
for k,v in pairs(net.hook) do
|
||||||
|
pcall(v,table.unpack(eventTab))
|
||||||
|
end
|
||||||
for k,v in pairs(packetCache) do
|
for k,v in pairs(packetCache) do
|
||||||
if computer.uptime() > v+30 then
|
if computer.uptime() > v+30 then
|
||||||
packetCache[k] = nil
|
packetCache[k] = nil
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
net.mtu=4096
|
net.mtu=4096
|
||||||
function net.send(T,P,L)
|
function net.lsend(T,P,L)
|
||||||
local D={}
|
local D={}
|
||||||
for i=1,L:len(),net.mtu do
|
for i=1,L:len(),net.mtu do
|
||||||
D[#D+1]=L:sub(1,net.mtu)
|
D[#D+1]=L:sub(1,net.mtu)
|
||||||
L=L:sub(net.mtu+1)
|
L=L:sub(net.mtu+1)
|
||||||
end
|
end
|
||||||
for k,v in ipairs(D) do
|
for k,v in ipairs(D) do
|
||||||
net.rsend(T,P,v)
|
net.send(T,P,v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user