Comments (5)
The latest published npm package solves the problem.
You can install the package, and then access it like this:
var playfab = require("playfab-sdk");
for(var each in playfab)
{
console.log("Each : " + each);
}
for(var each in playfab.settings)
{
console.log("Each.settings : " + each);
}
from nodesdk.
https://github.com/PlayFab/NodeSDK/tree/master/PlayFabTestingExample
This is our testing project.
In order to be published, the following steps must occur:
The vs solution must build with no errors (this is mostly to test the typescript bindings)
Then we execute a suite of tests via test.bat, which executes this file:
https://github.com/PlayFab/NodeSDK/blob/master/PlayFabTestingExample/PlayFabApiTests.js
Those tests must all execute, pass, and be relayed to our test-system, in order for our build to pass, which is a requirement for publishing (publishing to npm is another step in the same job).
I obviously can't test that the npm module works from npm, before I even publish it to npm, so I try to mimic the final structure of the node module in my test project.
From that testing file I can guarantee you a few things:
The test file does this:
var PlayFab = require("./Scripts/PlayFab/PlayFab");
And https://github.com/PlayFab/NodeSDK/blob/master/PlayFabSdk/Scripts/PlayFab/PlayFabClient.js does this:
var PlayFab = require("./PlayFab.js");
So, your specific point about whether require returns the same object or not:
PlayFab.settings.titleId = TitleData.titleId;
And PlayFabClient.js reads it from the same object:
request.TitleId = PlayFab.settings.titleId != null ? PlayFab.settings.titleId : request.TitleId;
And this is demonstrably working.
So, I disagree with your statement, I think that require does indeed return the same object when called from multiple files.
As for the npm module itself:
I tested it when we first created it, and my test environment is designed to mimic the structure of the npm module once fetched.
You are attempting require statements which differ slightly from mine, so I may have accidentally designed it in some non-standard way. This is fixable of course, and I'm happy to work with you to do so.
The best way to resolve this I think is for you to join our PlayFab Community Slack channel, and we can work out the details of the fix via a faster communication method.
https://api.playfab.com/slack
and then contact me directly: @pgilmore
I'll leave this open for now, pending the resolution.
from nodesdk.
While I'm sure require return the same object for multiple files in the project, it looks like it's not guaranteed when one of the require resides in a module:
http://justjs.com/posts/singletons-in-node-js-modules-cannot-be-trusted-or-why-you-can-t-just-do-var-foo-require-baz-init
There is the possibility this particular situation allows for your approach, but I suspect it's not idiomatic (and could break in the future anyway) but I couldn't test it because I couldn't import the objects directly anyway.
I will join the slack channel in the following days to discuss the other topic, until then thank you for your time.
from nodesdk.
Hello again.
If you check the https://github.com/PlayFab/NodeSDK/tree/T3626 branch, you can see that we're working on an alternate version of the node package, which should resolve all of the issues we discussed.
Please take a look and let us know if it handles all the issues you found.
Thanks!
from nodesdk.
var playfab = require("playfab-sdk");
var PlayFab = playfab.PlayFab;
var PlayFabClient = playfab.PlayFabClient;
from nodesdk.
Related Issues (18)
- Have you published a NPM module yet? HOT 1
- ProfileConstraints marked as number, should probably be different structure HOT 7
- Latest package does not include root imports. HOT 4
- PlayerProfileViewConstraints typings: Variables with default value marked as required
- [Enhancement request] On Request functions return a promise and set callback as optional argument
- Missing `AccessToken` param on `LoginWithGoogleAccountRequest` object causes compile error when using TypeScript
- [Question] How to remove session token from PlayFabClient? HOT 1
- [Question] Will this package's releases no longer be published to npm registry?
- [Question] Should the IPlayFabResultCommon interface extend the IPlayFabError interface?
- Is there a way to use the Client SDK in a stateless manner? HOT 2
- Setting EntityToken manually to request multiplayer server HOT 1
- [Question] How to set entityToken and SessionTicket in PlayFab SDK?
- Do not throw strings HOT 3
- Update typings to new standards HOT 2
- Do not ship redundant files HOT 2
- Does this support async/await? HOT 2
- Linting error: index.d.ts on Value HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodesdk.