async nightmares part 1 by H.P. OVHCraft

This commit is contained in:
Yessiest 2022-05-28 00:30:50 +04:00
parent 90ee8d4913
commit 2e23f128f0
2 changed files with 9 additions and 5 deletions

@ -1 +1 @@
Subproject commit e68aa525e06d8025a2976d2f93d03ad7a4f81807 Subproject commit 8a1906df7a402349ff7b083e59cf17223363f59b

View File

@ -206,12 +206,14 @@ sync_emitter:on("createEventEntry",function(k,v,timer,evname)
log("ERROR","Event id: "..k..".\nEvent description: ") log("ERROR","Event id: "..k..".\nEvent description: ")
print(v.comm) print(v.comm)
sync_emitter:emit("eventEntryCreated",false,k) sync_emitter:emit("eventEntryCreated",false,k)
return
end end
else else
log("ERROR","No channel with id "..v.channel) log("ERROR","No channel with id "..v.channel)
log("ERROR","Event id: "..k..".\nEvent description: ") log("ERROR","Event id: "..k..".\nEvent description: ")
print(v.comm) print(v.comm)
sync_emitter:emit("eventEntryCreated",false,k) sync_emitter:emit("eventEntryCreated",false,k)
return
end end
sync_emitter:emit("eventEntryCreated",true,k) sync_emitter:emit("eventEntryCreated",true,k)
end) end)
@ -219,9 +221,10 @@ end)
-- load timer events -- load timer events
for k,v in pairs(config.events.timer) do for k,v in pairs(config.events.timer) do
sync_emitter:emit("createEventEntry",k,v,true) sync_emitter:emit("createEventEntry",k,v,true)
local cor, ev, hash = sync_emitter:waitFor("eventEntryCreated",4000) local cor, ev, hash = sync_emitter:waitFor("eventEntryCreated",2000,
function(ev,hash) return hash == k end)
if (not cor) or (not ev) then if (not cor) or (not ev) then
log("INFO","Retrying in 2 seconds") log("INFO","Retrying event "..k.." in 2 seconds")
timer.setTimeout(2000,function() timer.setTimeout(2000,function()
sync_emitter:emit("createEventEntry",k,v,true) sync_emitter:emit("createEventEntry",k,v,true)
end) end)
@ -233,9 +236,10 @@ for _,evtype in pairs(config.events.event) do
events.event[_] = {} events.event[_] = {}
for k,v in pairs(evtype) do for k,v in pairs(evtype) do
sync_emitter:emit("createEventEntry",k,v,false,_) sync_emitter:emit("createEventEntry",k,v,false,_)
local cor,ev,hash = sync_emitter:waitFor("eventEntryCreated",4000) local cor,ev,hash = sync_emitter:waitFor("eventEntryCreated",2000,
function(ev,hash) return hash == k end)
if (not cor) or (not ev) then if (not cor) or (not ev) then
log("INFO","Retrying in 2 seconds") log("INFO","Retrying event "..k.." in 2 seconds")
timer.setTimeout(2000,function() timer.setTimeout(2000,function()
sync_emitter:emit("createEventEntry",k,v,false,_) sync_emitter:emit("createEventEntry",k,v,false,_)
end) end)