feat: replace CreateHTTPRequest with CreateHTTPRequestScriptVM
Allows the game client to make HTTP API calls from a listen server (local lobby) instead of requiring a Steam dedicated server. CreateHTTPRequestScriptVM has the exact same API signature but works in both dedicated server and listen server contexts. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -463,7 +463,7 @@ function BattlePassServer.prototype.onHeroSelected(self, playerId, heroName)
|
||||
local state = self:getOrCreateQuestState(playerId)
|
||||
state.heroesPlayed:add(heroName)
|
||||
local steamId = tostring(PlayerResource:GetSteamAccountID(playerId))
|
||||
local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/hero-played")
|
||||
local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/hero-played")
|
||||
setApiHeaders(nil, request)
|
||||
request:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
@@ -680,7 +680,7 @@ function BattlePassServer.prototype.syncAllQuestProgress(self)
|
||||
end
|
||||
end
|
||||
function BattlePassServer.prototype.syncQuestProgressToApi(self, steamId, questId, progress)
|
||||
local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests/progress")
|
||||
local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests/progress")
|
||||
setApiHeaders(nil, request)
|
||||
request:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
@@ -738,7 +738,7 @@ function BattlePassServer.prototype.loadQuests(self, playerId, steamId)
|
||||
nil,
|
||||
((("[BattlePassServer] Запрос квестов для " .. steamId) .. " (playerId: ") .. tostring(playerId)) .. ")"
|
||||
)
|
||||
local request = CreateHTTPRequest("GET", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests")
|
||||
local request = CreateHTTPRequestScriptVM("GET", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests")
|
||||
setApiHeaders(nil, request)
|
||||
request:Send(function(result)
|
||||
local player = PlayerResource:GetPlayer(playerId)
|
||||
@@ -943,7 +943,7 @@ function BattlePassServer.prototype.claimQuest(self, playerId, steamId, questId)
|
||||
return
|
||||
end
|
||||
____print(nil, "[BattlePassServer] Отправляем запрос на клейм квеста " .. questId)
|
||||
local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests/claim")
|
||||
local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/quests/claim")
|
||||
setApiHeadersLong(nil, request)
|
||||
request:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
@@ -1121,7 +1121,7 @@ function BattlePassServer.prototype.setupEventListeners(self)
|
||||
)
|
||||
end
|
||||
function BattlePassServer.prototype.loadBattlePassData(self, playerId, steamId)
|
||||
local request = CreateHTTPRequest("GET", (self.serverUrl .. "/battlepass/") .. steamId)
|
||||
local request = CreateHTTPRequestScriptVM("GET", (self.serverUrl .. "/battlepass/") .. steamId)
|
||||
setApiHeaders(nil, request)
|
||||
request:Send(function(result)
|
||||
do
|
||||
@@ -1246,7 +1246,7 @@ function BattlePassServer.prototype.loadBattlePassData(self, playerId, steamId)
|
||||
end)
|
||||
end
|
||||
function BattlePassServer.prototype.createBattlePass(self, playerId, steamId, afterCreate)
|
||||
local request = CreateHTTPRequest("POST", self.serverUrl .. "/battlepass")
|
||||
local request = CreateHTTPRequestScriptVM("POST", self.serverUrl .. "/battlepass")
|
||||
setApiHeadersLong(nil, request)
|
||||
request:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
@@ -1301,7 +1301,7 @@ function BattlePassServer.prototype.claimReward(self, playerId, steamId, level,
|
||||
isPremium = false
|
||||
end
|
||||
local endpoint = isPremium and "claim-premium" or "claim"
|
||||
local request = CreateHTTPRequest("POST", (((self.serverUrl .. "/battlepass/") .. steamId) .. "/") .. endpoint)
|
||||
local request = CreateHTTPRequestScriptVM("POST", (((self.serverUrl .. "/battlepass/") .. steamId) .. "/") .. endpoint)
|
||||
setApiHeadersLong(nil, request)
|
||||
request:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
@@ -1616,7 +1616,7 @@ function BattlePassServer.prototype.grantRewardInGame(self, playerId, level, isP
|
||||
break
|
||||
end
|
||||
itemSteamId = tostring(PlayerResource:GetSteamAccountID(playerId))
|
||||
purchaseRequest = CreateHTTPRequest("POST", ((self.serverUrl .. "/player/") .. itemSteamId) .. "/purchases")
|
||||
purchaseRequest = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/player/") .. itemSteamId) .. "/purchases")
|
||||
setApiHeaders(nil, purchaseRequest)
|
||||
purchaseRequest:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
@@ -1660,7 +1660,7 @@ function BattlePassServer.prototype.grantRewardInGame(self, playerId, level, isP
|
||||
break
|
||||
end
|
||||
local effectSteamId = tostring(PlayerResource:GetSteamAccountID(playerId))
|
||||
local effectPurchaseRequest = CreateHTTPRequest("POST", ((self.serverUrl .. "/player/") .. effectSteamId) .. "/purchases")
|
||||
local effectPurchaseRequest = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/player/") .. effectSteamId) .. "/purchases")
|
||||
setApiHeaders(nil, effectPurchaseRequest)
|
||||
effectPurchaseRequest:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
@@ -1719,7 +1719,7 @@ function BattlePassServer.prototype.grantRewardInGame(self, playerId, level, isP
|
||||
until true
|
||||
end
|
||||
function BattlePassServer.prototype.claimAllRewards(self, playerId, steamId)
|
||||
local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/claim-all")
|
||||
local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/claim-all")
|
||||
setApiHeadersLong(nil, request)
|
||||
request:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
@@ -1840,7 +1840,7 @@ function BattlePassServer.prototype.claimAllRewards(self, playerId, steamId)
|
||||
end)
|
||||
end
|
||||
function BattlePassServer.prototype.buyPremium(self, playerId, steamId)
|
||||
local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/buy-premium")
|
||||
local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/buy-premium")
|
||||
setApiHeadersLong(nil, request)
|
||||
request:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
@@ -1899,7 +1899,7 @@ function BattlePassServer.prototype.sendAddExpRequest(self, playerId, amount, al
|
||||
nil,
|
||||
((((("[BattlePassServer] Добавляем " .. tostring(expAdd)) .. " опыта Battle Pass игроку ") .. tostring(playerId)) .. " (Steam ID: ") .. steamId) .. ")"
|
||||
)
|
||||
local request = CreateHTTPRequest("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/addexp")
|
||||
local request = CreateHTTPRequestScriptVM("POST", ((self.serverUrl .. "/battlepass/") .. steamId) .. "/addexp")
|
||||
setApiHeadersLong(nil, request)
|
||||
request:SetHTTPRequestRawPostBody(
|
||||
"application/json",
|
||||
|
||||
Reference in New Issue
Block a user