Skip to content

Commit

Permalink
fix(resource): use normal events if latent events are disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Oct 3, 2024
1 parent eaf9507 commit d01028a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Legend:
- [x] check the noLookAlikesAlphabet vs nanoid-dictionary/nolookalikes situation
- the nanoid version is 49 chars long, and yet it's referenced as dict51
- [x] healthmonitor: write to logger.fxserver the internal reason as marker
- [!] check compatibility with `sv_enableNetEventReassembly false`
- [x] check compatibility with `sv_enableNetEventReassembly false`
- [!] check tx on node 22
- [!] update packages
- [!] check cicd stuff on testing repo before release
Expand Down
15 changes: 12 additions & 3 deletions resource/menu/server/sv_webpipe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ end
local _pipeLastReject
local _pipeFastCache = {}

-- Check if we should use latent events
local useLatentEvents = GetConvarBool('sv_enableNetEventReassembly', true);
if not useLatentEvents then
txPrint('^3WARNING: Latent events are disabled. If you have issues using the txAdmin in-game menu, please enable them by setting sv_enableNetEventReassembly to true in your server.cfg.')
end

---@param src string
---@param callbackId number
---@param statusCode number
Expand All @@ -35,10 +41,13 @@ local function sendResponse(src, callbackId, statusCode, path, body, headers, ca
debugPrint(("^3WebPipe[^5%d^0:^1%d^3]^0 %s<< %s ^4%s%s^0"):format(
src, callbackId, resultColor, statusCode, path, cachedStr))
if errorCode then
debugPrint(("^3WebPipe[^5%d^0:^1%d^3]^0 %s<< Headers: %s^0"):format(
src, callbackId, resultColor, json.encode(headers)))
debugPrint(("^3WebPipe[^5%d^0:^1%d^3]^0 %s<< Headers: %s^0"):format(src, callbackId, resultColor, json.encode(headers)))
end
if useLatentEvents then
TriggerLatentClientEvent('txcl:webpipe:resp', src, 125000, callbackId, statusCode, body, headers)
else
TriggerClientEvent('txcl:webpipe:resp', src, callbackId, statusCode, body, headers)
end
TriggerLatentClientEvent('txcl:webpipe:resp', src, 125000, callbackId, statusCode, body, headers)
end

RegisterNetEvent('txsv:webpipe:req', function(callbackId, method, path, headers, body)
Expand Down
29 changes: 27 additions & 2 deletions resource/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,35 @@
-- Truly global
-- =============================================

function GetConvarBool(cvName)
return (GetConvar(cvName, 'false') == 'true')
function GetConvarBool(cvName, defaultConvarValue)
if not cvName then
return false
elseif defaultConvarValue then
return (GetConvar(cvName, 'true') == 'true')
else
return (GetConvar(cvName, 'false') == 'true')
end
end

-- -- Tests for GetConvarBool
-- print("==========================")
-- print('unknown convar')
-- print(GetConvarBool2('xxx', true)) -- true
-- print(GetConvarBool2('xxx', false)) -- false
-- print(GetConvarBool2('xxx')) -- false
-- print('known convar')
-- SetConvar('yyy', 'true')
-- print(GetConvarBool2('yyy', true)) -- true
-- print(GetConvarBool2('yyy', false)) -- true
-- print(GetConvarBool2('yyy')) -- true
-- print('known convar, but with a false value')
-- SetConvar('yyy', 'false')
-- print(GetConvarBool2('yyy', false)) -- false
-- print(GetConvarBool2('yyy', true)) -- false
-- print(GetConvarBool2('yyy')) -- false
-- print("==========================")


-- Setting game-specific global vars
local envName = GetGameName()
if envName == 'fxserver' then
Expand Down

0 comments on commit d01028a

Please sign in to comment.