-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIPlayFabHttps.lua
54 lines (47 loc) · 2.37 KB
/
IPlayFabHttps.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-- IPlayFabHttps.lua
-- Defines the MakePlayFabApiCall function signature which is used by all PlayFab-HTTPS implementations
-- Also serves as a selector/redirect to the actual HTTPS implementation that should be used
-- (DEFAULT, no overrides - Suggested for LuaDist)
-- local PlayFabClientApi = require("PlayFab.PlayFabClientApi")
-- PlayFabClientApi.<YourApiCall>(...)
-- (DEFOLD EXAMPLE) An alternate HTTPS file is pre-included for Defold
-- local IPlayFabHttps = require("PlayFab.IPlayFabHttps")
-- local PlayFabHttps_Defold = require("PlayFab.PlayFabHttps_Defold")
-- IPlayFabHttps.SetHttp(PlayFabHttps_Defold) -- Assign the Defold-specific IHttps wrapper
-- local PlayFabClientApi = require("PlayFab.PlayFabClientApi")
-- PlayFabClientApi.<YourApiCall>(...)
-- (CUSTOM USE, None of the above) In your client code, directly over-ride the HTTPS instance:
-- To override and implement your own HTTPS handler, create a new file,
-- implement: MakePlayFabApiCall(urlPath, request, authKey, authValue, onSuccess, onError)
-- local IPlayFabHttps = require("PlayFab.IPlayFabHttps")
-- local CustomHttps = require("<YourCustomHttps>") -- Assign the custom-specific IHttps wrapper
-- IPlayFabHttps.SetHttp(CustomHttps)
-- local PlayFabClientApi = require("PlayFab.PlayFabClientApi")
-- PlayFabClientApi.<YourApiCall>(...)
--
-- 11-Jan-2023 - Changed _defaultHttpsFile to PlayFabHttps_CoroHttp
local PlayFabSettings = require("PlayFab/PlayFabSettings")
local IPlayFabHttps = {
_defaultHttpsFile = "PlayFab/PlayFabHttps_CoroHttp", -- implied .lua
_internalHttp = nil,
}
function IPlayFabHttps.SetHttp(httpInterface)
if (httpInterface) then
IPlayFabHttps._internalHttp = httpInterface
return
end
if (IPlayFabHttps._defaultHttpsFile) then
IPlayFabHttps._internalHttp = require(IPlayFabHttps._defaultHttpsFile)
return
end
end
function IPlayFabHttps.MakePlayFabApiCall(urlPath, request, authKey, authValue, onSuccess, onError)
if (IPlayFabHttps._internalHttp == nil) then
IPlayFabHttps.SetHttp(nil) -- Load the default
end
if (PlayFabSettings.settings.titleId == nil) then
error("PlayFabSettings.settings.titleId must be set before making API calls")
end
IPlayFabHttps._internalHttp.MakePlayFabApiCall(urlPath, request, authKey, authValue, onSuccess, onError)
end
return IPlayFabHttps