playfab / javascriptsdk Goto Github PK
View Code? Open in Web Editor NEWJavaScriptSDK for the Client API of PlayFab
License: Apache License 2.0
JavaScriptSDK for the Client API of PlayFab
License: Apache License 2.0
When using any of the API's functions that should store the session ticket, the actual retrieved ticked never is considered for being saved in exports.settings.session_ticket
.
The erroneous line is
settings.session_ticket = result.SessionTicket != null ? settings.session_ticket : settings.session_ticket;
and should be corrected to
settings.session_ticket = result.SessionTicket != null ? result.SessionTicket : settings.session_ticket;
I'm not sure why it happens, maybe I do miss something. Probably, there must be types
property in package.json
, as described here: How to get your d.ts files to users
But if I copy type definitions to my project manually, it works fine. So problem is in a package settings or something, not in files itself.
result.CustomData contains the customData object
passed to the LoginXXX API
The extraHeaders
object passed to the LoginXXX API is used in the REST request
result.CustomData is undefined
extraHeaders
is not used for LoginXXX calls
A result of this behavior is that you are unable to use extraHeaders
or customData
with the various LoginXXX calls.
Is there an option to install SDK to project via npm or bower package managers? If not, is it planned?
Hello,
I have a previous version and it has:
sdkVersion: "1.82.210208"
, the file in the latest release shows:
sdkVersion: "1.79.201217"
Is that intended?
Thank you.
As comment in this line say it should not be exposed
https://github.com/PlayFab/JavaScriptSDK/blob/master/PlayFabSdk/src/PlayFab/PlayFabClientApi.js#L8
but if I understand correctly use of this file it is used in browser on client side so this settings will be exposed.
Why is this value used on client side in this line?
https://github.com/PlayFab/JavaScriptSDK/blob/master/PlayFabSdk/src/PlayFab/PlayFabClientApi.js#L216
http://code.jquery.com/jquery-1.7.1.min.js
should be called as
https://code.jquery.com/jquery-1.7.1.min.js
(https)
Manually changed and resolves this part, but causes this issue: #62
The docs are not working and i am confused
PlayFabApiTest.js:589 null ", Failed to save test report to CloudScript: " "jbuild_0" "
" "[
{
"name": "jbuild_0",
"tests": 0,
"failures": 0,
"errors": 0,
"skipped": 0,
"time": 0.003,
"timestamp": "2016-06-20T05:56:58.185Z",
"testResults": []
}
]"
PlayFabApiTest.js:92 testTitleData input file did not parse correctly
I've been using both this SDK and the NodeJS SDK extensively for a few months now, and I've found that the SDKs are much easier to use when API calls are promise-based. I've been using a wrapper function that provides this functionality, which works fine but is not ideal. That looks something like this (shortened for brevity)
function playfabAPI(endpoint, requestObject) {
return new Promise(function(resolve, reject) {
PlayFabClientSDK[endpoint](requestObject, function(error, result) {
if (error !== null) {
// Request error
return reject(new Error(error));
}
else if (result && result["code"] == 200) {
// Request successful
return resolve(result);
}
else {
// Non-200 HTTP status
return reject(new Error(result.status));
}
});
});
}
This makes for cleaner code, adds useful functionality, and eliminates a lot of redundant error checking code. The current request functions are consistent enough for this to work in most cases so far but I'm a bit wary of using it in production. What I would propose is to implement this either alongside the current format, or as an additional SDK/script, for compatibility reasons.
exports.UpdateUserData = function (request, callback) {
if (PlayFab._internalSettings.sessionTicket == null) {
throw "Must be logged in to call this method";
}
PlayFab.MakeRequest(
PlayFab.GetServerUrl() + "/Client/UpdateUserData",
request,
"X-Authorization",
PlayFab._internalSettings.sessionTicket,
function (error, result) {
if (callback != null) {
callback(error, result);
}
},
);
};
exports.UpdateUserData = function (request)
{
return new Promise((resolve, reject) => {
if (PlayFab._internalSettings.sessionTicket == null) {
throw "Must be logged in to call this method";
}
PlayFab.MakeRequest(
PlayFab.GetServerUrl() + "/Client/UpdateUserData",
request,
"X-Authorization",
PlayFab._internalSettings.sessionTicket,
(error, result) => {
if (error !== null) {
return reject(new Error(error));
}
else if (result && result["code"] == 200) {
return resolve(result);
}
else {
return reject(new Error(result.status));
}
},
);
});
};
PlayFabClientSDK.UpdateUserData(requestParameters, function(error, result) {
// Check for + handle errors...
// Handle result...
});
PlayFabClientSDK.UpdateUserData(requestParameters).then((userDataResult) => {
// Handle userDataResult...
}).catch((error) => {
// Handle errors...
});
This would also have the added benefit of allowing the use of async/await which can greatly simplify code structure, e.g. when chaining requests
(async function() {
const userDataResult = await PlayFabClientSDK.UpdateUserData(requestParameters);
// Handle userDataResult/make additional API requests
})();
Let me know what you guys think. Is this something that would be better served using the SDK generator with a custom config, or would it be feasible to get an official implementation?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.