Skip to content

Commit f65bb86

Browse files
author
Playfab Jenkins Bot
committed
https://api.playfab.com/releaseNotes/#170109
2 parents 884f0d4 + 89a9125 commit f65bb86

File tree

10 files changed

+191
-26
lines changed

10 files changed

+191
-26
lines changed

AndroidStudioExample/app/src/main/java/com/playfab/PlayFabClientAPI.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3881,7 +3881,7 @@ private static PlayFabResult<ModifyUserVirtualCurrencyResult> privateAddUserVirt
38813881
}
38823882

38833883
/**
3884-
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
3884+
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
38853885
*/
38863886
@SuppressWarnings("unchecked")
38873887
public static FutureTask<PlayFabResult<ConfirmPurchaseResult>> ConfirmPurchaseAsync(final ConfirmPurchaseRequest request) {
@@ -3893,7 +3893,7 @@ public PlayFabResult<ConfirmPurchaseResult> call() throws Exception {
38933893
}
38943894

38953895
/**
3896-
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
3896+
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
38973897
*/
38983898
@SuppressWarnings("unchecked")
38993899
public static PlayFabResult<ConfirmPurchaseResult> ConfirmPurchase(final ConfirmPurchaseRequest request) {
@@ -3911,7 +3911,7 @@ public PlayFabResult<ConfirmPurchaseResult> call() throws Exception {
39113911
}
39123912

39133913
/**
3914-
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
3914+
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
39153915
*/
39163916
@SuppressWarnings("unchecked")
39173917
private static PlayFabResult<ConfirmPurchaseResult> privateConfirmPurchaseAsync(final ConfirmPurchaseRequest request) throws Exception {
@@ -4229,7 +4229,7 @@ private static PlayFabResult<PayForPurchaseResult> privatePayForPurchaseAsync(fi
42294229
}
42304230

42314231
/**
4232-
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
4232+
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
42334233
*/
42344234
@SuppressWarnings("unchecked")
42354235
public static FutureTask<PlayFabResult<PurchaseItemResult>> PurchaseItemAsync(final PurchaseItemRequest request) {
@@ -4241,7 +4241,7 @@ public PlayFabResult<PurchaseItemResult> call() throws Exception {
42414241
}
42424242

42434243
/**
4244-
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
4244+
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
42454245
*/
42464246
@SuppressWarnings("unchecked")
42474247
public static PlayFabResult<PurchaseItemResult> PurchaseItem(final PurchaseItemRequest request) {
@@ -4259,7 +4259,7 @@ public PlayFabResult<PurchaseItemResult> call() throws Exception {
42594259
}
42604260

42614261
/**
4262-
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
4262+
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
42634263
*/
42644264
@SuppressWarnings("unchecked")
42654265
private static PlayFabResult<PurchaseItemResult> privatePurchaseItemAsync(final PurchaseItemRequest request) throws Exception {

AndroidStudioExample/app/src/main/java/com/playfab/PlayFabSettings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import com.playfab.PlayFabErrors.ErrorCallback;
55

66
public class PlayFabSettings {
7-
public static String SdkVersion = "0.42.170102";
7+
public static String SdkVersion = "0.43.170109";
88
public static String BuildIdentifier = "jbuild_javasdk_1";
9-
public static String SdkVersionString = "JavaSDK-0.42.170102";
9+
public static String SdkVersionString = "JavaSDK-0.43.170109";
1010

1111
public static String TitleId = null; // You must set this value for PlayFabSdk to work properly (Found in the Game Manager for your title, at the PlayFab Website)
1212
public static ErrorCallback GlobalErrorHandler;

JavaGettingStarted.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
Java Getting Started Guide
2+
----
3+
4+
This guide will help you make your first API call in Java.
5+
6+
Java Project Setup
7+
----
8+
9+
* OS: This guide is written for Windows 10, however it should also work fine with a Mac
10+
* Installation
11+
* Download and install the latest JDK
12+
* http://www.oracle.com/technetwork/java/javase/downloads/index.html
13+
* Download the PlayFab ActionScriptSDK
14+
* https://api.playfab.com/sdks/download/java
15+
* Download the zip file, and extract it to a location of your choice {PlayFabJavaLocation}
16+
* New Project Setup
17+
* Create a new empty folder for your JavaGettingStarted project
18+
* Create a new empty text file called GettingStarted.java
19+
* We will modify this file in the next section
20+
* Import the PlayFab JavaSDK into this project
21+
* In Windows-Explorer, navigate to {PlayFabJavaLocation}/PlayFabClientSDK/src
22+
* Select everything in this folder (1 subfolder, and 2 jar files)
23+
* Copy it to your project folder
24+
* Your project folder should look like this:
25+
* ![Java image](/images/Java/Installed.png)
26+
* PlayFab Installation Complete!
27+
28+
Set up your first API call
29+
----
30+
31+
This guide will provide the minimum steps to make your first PlayFab API call. Confirmation will be visible as console-output text.
32+
33+
In your favorite text-editor, update the contents of GettingStarted.java as follows:
34+
```Java
35+
import java.util.concurrent.*;
36+
import java.util.*;
37+
38+
import com.playfab.PlayFabErrors.*;
39+
import com.playfab.PlayFabSettings;
40+
import com.playfab.PlayFabClientModels;
41+
import com.playfab.PlayFabClientAPI;
42+
43+
public class GettingStarted
44+
{
45+
private static boolean _running = true;
46+
47+
public static void main(String[] args) {
48+
PlayFabSettings.TitleId = "144";
49+
50+
PlayFabClientModels.LoginWithCustomIDRequest request = new PlayFabClientModels.LoginWithCustomIDRequest();
51+
request.CustomId = "GettingStartedGuide";
52+
request.CreateAccount = true;
53+
54+
FutureTask<PlayFabResult<com.playfab.PlayFabClientModels.LoginResult>> loginTask = PlayFabClientAPI.LoginWithCustomIDAsync(request);
55+
loginTask.run();
56+
57+
while (_running) {
58+
if (loginTask.isDone()) { // You would probably want a more sophisticated way of tracking pending async API calls in a real game
59+
OnLoginComplete(loginTask);
60+
}
61+
62+
// Presumably this would be your main game loop, doing other things
63+
try {
64+
Thread.sleep(1);
65+
} catch(Exception e) {
66+
System.out.println("Critical error in the example main loop: " + e);
67+
}
68+
}
69+
}
70+
71+
private static void OnLoginComplete(FutureTask<PlayFabResult<com.playfab.PlayFabClientModels.LoginResult>> loginTask) {
72+
PlayFabResult<com.playfab.PlayFabClientModels.LoginResult> result = null;
73+
try {
74+
result = loginTask.get(); // Wait for the result from the async call
75+
} catch(Exception e) {
76+
System.out.println("Exception in PlayFab api call: " + e); // Did you assign your PlayFabSettings.TitleId correctly?
77+
}
78+
79+
if (result != null && result.Result != null) {
80+
System.out.println("Congratulations, you made your first successful API call!");
81+
} else if (result != null && result.Error != null) {
82+
System.out.println("Something went wrong with your first API call.");
83+
System.out.println("Here's some debug information:");
84+
System.out.println(CompileErrorsFromResult(result));
85+
}
86+
87+
_running = false; // Because this is just an example, successful login triggers the end of the program
88+
}
89+
90+
// This is a utility function we haven't put into the core SDK yet. Feel free to use it.
91+
private static <RT> String CompileErrorsFromResult(PlayFabResult<RT> result) {
92+
if (result == null || result.Error == null)
93+
return null;
94+
95+
String errorMessage = "";
96+
if (result.Error.errorMessage != null)
97+
errorMessage += result.Error.errorMessage;
98+
if (result.Error.errorDetails != null)
99+
for (Map.Entry<String, List<String>> pair : result.Error.errorDetails.entrySet() )
100+
for (String msg : pair.getValue())
101+
errorMessage += "\n" + pair.getKey() + ": " + msg;
102+
return errorMessage;
103+
}
104+
}
105+
```
106+
107+
* Open a command window in your project folder:
108+
* Hold shift and right click in the empty-white-space of the Explorer window
109+
* ![Java image](/images/Java/CmdExe.png)
110+
* We will use this window in the next section to execute our program
111+
112+
Finish and Execute
113+
----
114+
115+
* In the command window, enter the following sequence of commands:
116+
* javac GettingStarted.java
117+
* If successful, this should finish with no output
118+
* Java -cp . GettingStarted
119+
* If successful, you should see the following text:
120+
* Congratulations, you made your first successful API call!
121+
* At this point, you can start making other api calls, and building your game
122+
* For a list of all available client API calls, see our documentation:
123+
* https://api.playfab.com/
124+
* Happy coding!
125+
126+
Deconstruct the code
127+
----
128+
129+
This optional last section describes every line in GettingStarted.java in detail.
130+
131+
* imports
132+
* This is the minimal set of imports used to make PlayFab API calls
133+
* public static void main(String[] args) {
134+
* Just a basic loop that kicks off an API call, and waits for it to complete
135+
* PlayFabSettings.TitleId = "xxxx";
136+
* Every PlayFab developer creates a title in Game Manager. When you publish your game, you must code that titleId into your game. This lets the client know how to access the correct data within PlayFab. For most users, just consider it a mandatory step that makes PlayFab work.
137+
* PlayFabClientModels.LoginWithCustomIDRequest request = new PlayFabClientModels.LoginWithCustomIDRequest();
138+
* Most PlayFab API methods require input parameters, and those input parameters are packed into a request object
139+
* Every API method requires a unique request object, with a mix of optional and mandatory parameters
140+
* For LoginWithCustomIDRequest, there is a mandatory parameter of CustomId, which uniquely identifies a player and CreateAccount, which allows the creation of a new account with this call.
141+
* For login, most developers will want to use a more appropriate login method
142+
* See the PlayFab Login Documentation for a list of all login methods, and input parameters. Common choices are:
143+
* LoginWithAndroidDeviceID
144+
* LoginWithIOSDeviceID
145+
* LoginWithEmailAddress
146+
* FutureTask&lt;PlayFabResult&lt;com.playfab.PlayFabClientModels.LoginResult>> loginTask = PlayFabClientAPI.LoginWithCustomIDAsync(request);
147+
* This begins the async request to "LoginWithCustomID", using the Java FutureTask framework
148+
* while (running) { if (loginTask.isDone()) { OnLoginComplete(loginTask); } }
149+
* Run a trivial main loop and asynchronously wait for the loginTask to complete
150+
* When finished call OnLoginComplete
151+
* OnLoginComplete(loginTask)
152+
* result = loginTask.get();
153+
* Fetch the async result (this won't cause a block, because we confirmed the FutureTask is already complete
154+
* if (result.Result != null), the API call is successful
155+
* When successful, result.Result object of many API callbacks will contain the requested information
156+
* LoginResult specifically contains some basic information about the player, but for most users, login is simply a mandatory step before calling other APIs.
157+
* if (result.Error != null), the API call has failed
158+
* API calls can fail for many reasons, and you should always attempt to handle failure
159+
* Why API calls fail (In order of likelihood)
160+
* PlayFabSettings.TitleId is not set. If you forget to set titleId to your title, then nothing will work.
161+
* Request parameters. If you have not provided the correct or required information for a particular API call, then it will fail. See error.errorMessage, error.errorDetails, or error.GenerateErrorReport() for more info.
162+
* Device connectivity issue. Cell-phones lose/regain connectivity constantly, and so any API call at any time can fail randomly, and then work immediately after. Going into a tunnel can disconnect you completely.
163+
* PlayFab server issue. As with all software, there can be issues. See our [release notes](https://api.playfab.com/releaseNotes/) for updates.
164+
* The internet is not 100% reliable. Sometimes the message is corrupted or fails to reach the PlayFab server.
165+
* If you are having difficulty debugging an issue, and the information within the error callback is not sufficient, please visit us on our [forums](https://community.playfab.com/index.html)

PlayFabClientSDK/src/com/playfab/PlayFabClientAPI.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3880,7 +3880,7 @@ private static PlayFabResult<ModifyUserVirtualCurrencyResult> privateAddUserVirt
38803880
}
38813881

38823882
/**
3883-
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
3883+
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
38843884
*/
38853885
@SuppressWarnings("unchecked")
38863886
public static FutureTask<PlayFabResult<ConfirmPurchaseResult>> ConfirmPurchaseAsync(final ConfirmPurchaseRequest request) {
@@ -3892,7 +3892,7 @@ public PlayFabResult<ConfirmPurchaseResult> call() throws Exception {
38923892
}
38933893

38943894
/**
3895-
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
3895+
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
38963896
*/
38973897
@SuppressWarnings("unchecked")
38983898
public static PlayFabResult<ConfirmPurchaseResult> ConfirmPurchase(final ConfirmPurchaseRequest request) {
@@ -3910,7 +3910,7 @@ public PlayFabResult<ConfirmPurchaseResult> call() throws Exception {
39103910
}
39113911

39123912
/**
3913-
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
3913+
* Confirms with the payment provider that the purchase was approved (if applicable) and adjusts inventory and virtual currency balances as appropriate
39143914
*/
39153915
@SuppressWarnings("unchecked")
39163916
private static PlayFabResult<ConfirmPurchaseResult> privateConfirmPurchaseAsync(final ConfirmPurchaseRequest request) throws Exception {
@@ -4228,7 +4228,7 @@ private static PlayFabResult<PayForPurchaseResult> privatePayForPurchaseAsync(fi
42284228
}
42294229

42304230
/**
4231-
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
4231+
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
42324232
*/
42334233
@SuppressWarnings("unchecked")
42344234
public static FutureTask<PlayFabResult<PurchaseItemResult>> PurchaseItemAsync(final PurchaseItemRequest request) {
@@ -4240,7 +4240,7 @@ public PlayFabResult<PurchaseItemResult> call() throws Exception {
42404240
}
42414241

42424242
/**
4243-
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
4243+
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
42444244
*/
42454245
@SuppressWarnings("unchecked")
42464246
public static PlayFabResult<PurchaseItemResult> PurchaseItem(final PurchaseItemRequest request) {
@@ -4258,7 +4258,7 @@ public PlayFabResult<PurchaseItemResult> call() throws Exception {
42584258
}
42594259

42604260
/**
4261-
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
4261+
* Buys a single item with virtual currency. You must specify both the virtual currency to use to purchase, as well as what the client believes the price to be. This lets the server fail the purchase if the price has changed.
42624262
*/
42634263
@SuppressWarnings("unchecked")
42644264
private static PlayFabResult<PurchaseItemResult> privatePurchaseItemAsync(final PurchaseItemRequest request) throws Exception {

PlayFabClientSDK/src/com/playfab/PlayFabSettings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import com.playfab.PlayFabErrors.ErrorCallback;
44

55
public class PlayFabSettings {
6-
public static String SdkVersion = "0.42.170102";
6+
public static String SdkVersion = "0.43.170109";
77
public static String BuildIdentifier = "jbuild_javasdk_1";
8-
public static String SdkVersionString = "JavaSDK-0.42.170102";
8+
public static String SdkVersionString = "JavaSDK-0.43.170109";
99

1010
public static String TitleId = null; // You must set this value for PlayFabSdk to work properly (Found in the Game Manager for your title, at the PlayFab Website)
1111
public static ErrorCallback GlobalErrorHandler;

0 commit comments

Comments
 (0)