Update GaCy-GO
This commit is contained in:
1 parent
da8a32f60d
commit
0cbe460e49
345 files changed
+98202
-77559
No files matched your search
@@ -111,6 +111,12 @@ func apiClientUnstuckResult(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
clientUnstuckState.status.Error = result.Error
|
||||
clientUnstuckState.status.CompletedAt = time.Now().UnixMilli()
|
||||
// Queueing and acknowledgement share the lock, so removing this owned
|
||||
// request cannot delete a newer recovery. A leftover script still checks
|
||||
// the live nonce before touching UI, including after an SDK restart.
|
||||
if err := os.Remove(clientUnstuckRequestFile); err != nil && !os.IsNotExist(err) {
|
||||
Log("[UNSTUCK] cannot remove completed request: " + err.Error())
|
||||
}
|
||||
Log("[UNSTUCK] UI recovery " + clientUnstuckState.status.State + " request=" + result.RequestID)
|
||||
writeJSON(w, clientUnstuckState.status)
|
||||
}
|
||||
@@ -120,27 +126,63 @@ func apiClientUnstuckResult(w http.ResponseWriter, r *http.Request) {
|
||||
// response, erase a run, or reset the Client's loading/phase flags.
|
||||
const clientUnstuckLua = `do
|
||||
local id = %q
|
||||
if _G.__GAC_UNSTUCK_HTTP and _G.__GAC_UNSTUCK_HTTP.isDone then
|
||||
pcall(function() _G.__GAC_UNSTUCK_HTTP:Dispose() end); _G.__GAC_UNSTUCK_HTTP=nil
|
||||
end
|
||||
if _G.__GAC_UNSTUCK_LAST ~= id then
|
||||
_G.__GAC_UNSTUCK_LAST=id
|
||||
local ok,err=pcall(function()
|
||||
local ui=CS.RPG.Client.GlobalVars.s_UIManager
|
||||
if not ui then error('Client UIManager is unavailable') end
|
||||
ui:ClearWaitNetPacketFullScreenBlock()
|
||||
end)
|
||||
CS.UnityEngine.Debug.Log('[GAC_UNSTUCK] request='..id..' success='..tostring(ok)..' '..tostring(err or ''))
|
||||
pcall(function()
|
||||
local url=_G.__GAC_SRTOOL_LIVE_URL
|
||||
if type(url)~='string' or url=='' then return end
|
||||
local body='{"request_id":"'..id..'","success":'..tostring(ok)..',"error":'..CS.Newtonsoft.Json.JsonConvert.SerializeObject(tostring(err or ''))..'}'
|
||||
local req=CS.UnityEngine.Networking.UnityWebRequest(url..'/api/client/unstuck/result','POST')
|
||||
req.uploadHandler=CS.UnityEngine.Networking.UploadHandlerRaw(CS.System.Text.Encoding.UTF8:GetBytes(body))
|
||||
local function tick()
|
||||
local url=_G.__GAC_SRTOOL_LIVE_URL
|
||||
if type(url)~='string' or url=='' then return end
|
||||
local s=_G.__GAC_UNSTUCK_WORK
|
||||
if not s or s.id~=id then
|
||||
if s and s.request then pcall(function()s.request:Dispose()end) end
|
||||
s={id=id,phase='check',next=0};_G.__GAC_UNSTUCK_WORK=s
|
||||
end
|
||||
if s.phase=='done' or s.phase=='stale' then return end
|
||||
local now=CS.UnityEngine.Time.unscaledTime
|
||||
if s.request then
|
||||
if not s.request.isDone then return end
|
||||
local request=s.request;s.request=nil
|
||||
local ok,err=pcall(function()
|
||||
local code=request.responseCode
|
||||
if code<200 or code>=300 then error('recovery HTTP '..tostring(code)) end
|
||||
if s.phase=='check' then
|
||||
local status=CS.Newtonsoft.Json.Linq.JObject.Parse(request.downloadHandler.text)
|
||||
local request_id=status:get_Item('request_id')
|
||||
local phase=status:get_Item('state')
|
||||
if not request_id or tostring(request_id)~=id or not phase or tostring(phase)~='queued' then
|
||||
s.phase='stale';return
|
||||
end
|
||||
-- Only the current queued SDK request authorizes a UI recovery. Old
|
||||
-- generated files are inert after reconnect or SDK process restart.
|
||||
local success,message=pcall(function()
|
||||
local ui=CS.RPG.Client.GlobalVars.s_UIManager
|
||||
if not ui then error('Client UIManager is unavailable') end
|
||||
ui:ClearWaitNetPacketFullScreenBlock()
|
||||
end)
|
||||
s.body='{"request_id":"'..id..'","success":'..tostring(success)..',"error":'..CS.Newtonsoft.Json.JsonConvert.SerializeObject(tostring(message or ''))..'}'
|
||||
s.phase='ack'
|
||||
CS.UnityEngine.Debug.Log('[GAC_UNSTUCK] request='..id..' success='..tostring(success)..' '..tostring(message or ''))
|
||||
else
|
||||
s.phase='done';_G.__GAC_UNSTUCK_LAST=id
|
||||
end
|
||||
end)
|
||||
pcall(function()request:Dispose()end)
|
||||
if not ok then
|
||||
s.next=now+5
|
||||
if s.error~=tostring(err) then CS.UnityEngine.Debug.Log('[GAC_UNSTUCK] '..tostring(err));s.error=tostring(err) end
|
||||
return
|
||||
end
|
||||
end
|
||||
if s.phase=='done' or s.phase=='stale' or now<s.next then return end
|
||||
local req
|
||||
if s.phase=='check' then
|
||||
req=CS.UnityEngine.Networking.UnityWebRequest.Get(url..'/api/client/unstuck')
|
||||
else
|
||||
req=CS.UnityEngine.Networking.UnityWebRequest(url..'/api/client/unstuck/result','POST')
|
||||
req.uploadHandler=CS.UnityEngine.Networking.UploadHandlerRaw(CS.System.Text.Encoding.UTF8:GetBytes(s.body))
|
||||
req.downloadHandler=CS.UnityEngine.Networking.DownloadHandlerBuffer()
|
||||
req:SetRequestHeader('Content-Type','application/json');req.timeout=10
|
||||
req:SendWebRequest();_G.__GAC_UNSTUCK_HTTP=req
|
||||
end)
|
||||
req:SetRequestHeader('Content-Type','application/json')
|
||||
end
|
||||
req.timeout=10;s.request=req;req:SendWebRequest()
|
||||
end
|
||||
local ok,err=pcall(tick)
|
||||
if not ok then CS.UnityEngine.Debug.Log('[GAC_UNSTUCK] '..tostring(err)) end
|
||||
end
|
||||
`
|
||||
Reference in new issue
Block a user