Skip to content

Commit e142427

Browse files
author
Paul Gilmore
authored
* Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated build from Jenkins * Automated pf-main build from Jenkins * Automated pf-main build from Jenkins * Automated build from Jenkins * PlayFab/SDKGenerator@2bb9f5f * PlayFab/SDKGenerator@00e8d9c * PlayFab/SDKGenerator@f3e0f08 * PlayFab/SDKGenerator@9be767d * PlayFab/SDKGenerator@edce013 * Automated pf-main build from Jenkins * Automated pf-main build from Jenkins * Automated pf-main build from Jenkins * Automated pf-main build from Jenkins * Automated pf-main build from Jenkins * PlayFab/SDKGenerator@5f5eaa0 * Automated pf-main build from Jenkins * PlayFab/SDKGenerator@4cf7e87 * Automated pf-main build from Jenkins * PlayFab/SDKGenerator@8c46b50 * Automated pf-main build from Jenkins * Automated pf-main build from Jenkins * Automated build from Jenkins * Automated pf-main build from Jenkins * PlayFab/SDKGenerator@0643bb2
1 parent 11e6724 commit e142427

File tree

16 files changed

+223
-37
lines changed

16 files changed

+223
-37
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,19 @@ public static class GameInfo {
813813
/**
814814
* game specific string denoting server configuration
815815
*/
816-
public String GameServerState;
816+
public GameInstanceState GameServerState;
817+
/**
818+
* game session custom data
819+
*/
820+
public String GameServerData;
817821

818822
}
819823

824+
public static enum GameInstanceState {
825+
Open,
826+
Closed
827+
}
828+
820829
public static class GameServerRegionsRequest {
821830
/**
822831
* version of game server for which stats are being requested

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

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

66
public class PlayFabSettings {
7+
public static String SdkVersion = "0.27.160613";
8+
public static String BuildIdentifier = "jbuild_0";
9+
public static String SdkVersionString = "JavaSDK-0.27.160613";
10+
711
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)
812
public static ErrorCallback GlobalErrorHandler;
9-
public static String LogicServerURL = null; // Assigned by GetCloudScriptUrl, used by RunCloudScript
13+
public static String LogicServerURL = null; // Deprecated
1014
public static String AdvertisingIdType = null; // Set this to the appropriate AD_TYPE_X constant below
1115
public static String AdvertisingIdValue = null; // Set this to corresponding device value
1216
public static Context androidContext = null; // Context object for android devices

AndroidStudioExample/app/src/main/java/com/playfab/internal/PlayFabHTTP.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.*;
77
import com.google.gson.*;
88

9+
import com.playfab.PlayFabSettings;
910
import com.playfab.PlayFabErrors.PlayFabError;
1011
import com.playfab.PlayFabErrors.PlayFabErrorCode;
1112
import com.playfab.PlayFabErrors.PlayFabJsonError;
@@ -43,7 +44,7 @@ else if (request instanceof String) {
4344
if(authType != null) {
4445
con.setRequestProperty(authType, authKey);
4546
}
46-
con.setRequestProperty("X-PlayFabSDK", PlayFabVersion.getVersionString());
47+
con.setRequestProperty("X-PlayFabSDK", PlayFabSettings.SdkVersionString);
4748
con.setDoOutput(true);
4849
con.setDoInput(true);
4950

PlayFabClientSDK/src/com/playfab/PlayFabClientModels.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,19 @@ public static class GameInfo {
813813
/**
814814
* game specific string denoting server configuration
815815
*/
816-
public String GameServerState;
816+
public GameInstanceState GameServerState;
817+
/**
818+
* game session custom data
819+
*/
820+
public String GameServerData;
817821

818822
}
819823

824+
public static enum GameInstanceState {
825+
Open,
826+
Closed
827+
}
828+
820829
public static class GameServerRegionsRequest {
821830
/**
822831
* version of game server for which stats are being requested

PlayFabClientSDK/src/com/playfab/PlayFabSettings.java

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

55
public class PlayFabSettings {
6+
public static String SdkVersion = "0.27.160613";
7+
public static String BuildIdentifier = "jbuild_0";
8+
public static String SdkVersionString = "JavaSDK-0.27.160613";
9+
610
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)
711
public static ErrorCallback GlobalErrorHandler;
8-
public static String LogicServerURL = null; // Assigned by GetCloudScriptUrl, used by RunCloudScript
12+
public static String LogicServerURL = null; // Deprecated
913
public static String AdvertisingIdType = null; // Set this to the appropriate AD_TYPE_X constant below
1014
public static String AdvertisingIdValue = null; // Set this to corresponding device value
1115

PlayFabClientSDK/src/com/playfab/internal/PlayFabHTTP.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.*;
77
import com.google.gson.*;
88

9+
import com.playfab.PlayFabSettings;
910
import com.playfab.PlayFabErrors.PlayFabError;
1011
import com.playfab.PlayFabErrors.PlayFabErrorCode;
1112
import com.playfab.PlayFabErrors.PlayFabJsonError;
@@ -43,7 +44,7 @@ else if (request instanceof String) {
4344
if(authType != null) {
4445
con.setRequestProperty(authType, authKey);
4546
}
46-
con.setRequestProperty("X-PlayFabSDK", PlayFabVersion.getVersionString());
47+
con.setRequestProperty("X-PlayFabSDK", PlayFabSettings.SdkVersionString);
4748
con.setDoOutput(true);
4849
con.setDoInput(true);
4950

PlayFabSDK/src/PlayFabApiTest.java

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ public void InvalidRegistration()
165165
@Test
166166
public void LoginOrRegister()
167167
{
168-
PlayFabClientModels.LoginWithEmailAddressRequest request = new PlayFabClientModels.LoginWithEmailAddressRequest();
168+
PlayFabClientModels.LoginWithCustomIDRequest request = new PlayFabClientModels.LoginWithCustomIDRequest();
169169
request.TitleId = PlayFabSettings.TitleId;
170-
request.Email = USER_EMAIL;
171-
request.Password = USER_PASSWORD;
170+
request.CustomId = PlayFabSettings.BuildIdentifier;
171+
request.CreateAccount = true;
172172

173-
PlayFabResult<PlayFabClientModels.LoginResult> result = PlayFabClientAPI.LoginWithEmailAddress(request);
173+
PlayFabResult<PlayFabClientModels.LoginResult> result = PlayFabClientAPI.LoginWithCustomID(request);
174174
VerifyResult(result, true);
175175
assertNotNull(result.Result.PlayFabId);
176176
playFabId = result.Result.PlayFabId;
@@ -188,11 +188,11 @@ public void LoginWithAdvertisingId()
188188
PlayFabSettings.AdvertisingIdType = PlayFabSettings.AD_TYPE_ANDROID_ID;
189189
PlayFabSettings.AdvertisingIdValue = "PlayFabTestId";
190190

191-
PlayFabClientModels.LoginWithEmailAddressRequest request = new PlayFabClientModels.LoginWithEmailAddressRequest();
191+
PlayFabClientModels.LoginWithCustomIDRequest request = new PlayFabClientModels.LoginWithCustomIDRequest();
192192
request.TitleId = PlayFabSettings.TitleId;
193-
request.Email = USER_EMAIL;
194-
request.Password = USER_PASSWORD;
195-
PlayFabResult<PlayFabClientModels.LoginResult> result = PlayFabClientAPI.LoginWithEmailAddress(request);
193+
request.CustomId = PlayFabSettings.BuildIdentifier;
194+
request.CreateAccount = true;
195+
PlayFabResult<PlayFabClientModels.LoginResult> result = PlayFabClientAPI.LoginWithCustomID(request);
196196

197197
assertEquals(PlayFabSettings.AD_TYPE_ANDROID_ID + "_Successful", PlayFabSettings.AdvertisingIdType);
198198
}
@@ -258,7 +258,8 @@ public void UserStatisticsApi()
258258
PlayFabClientModels.GetUserStatisticsRequest getRequest = new PlayFabClientModels.GetUserStatisticsRequest();
259259
PlayFabResult<PlayFabClientModels.GetUserStatisticsResult> getStatsResult = PlayFabClientAPI.GetUserStatistics(getRequest);
260260
VerifyResult(getStatsResult, true);
261-
int testStatExpected = getStatsResult.Result.UserStatistics == null ? 0 : getStatsResult.Result.UserStatistics.get(TEST_STAT_NAME);
261+
boolean hasStat = getStatsResult.Result.UserStatistics != null && getStatsResult.Result.UserStatistics.containsKey(TEST_STAT_NAME);
262+
int testStatExpected = !hasStat ? 0 : getStatsResult.Result.UserStatistics.get(TEST_STAT_NAME);
262263
testStatExpected = (testStatExpected + 1) % 100; // This test is about the expected value changing - but not testing more complicated issues like bounds
263264

264265
PlayFabClientModels.UpdateUserStatisticsRequest updateRequest = new PlayFabClientModels.UpdateUserStatisticsRequest();
@@ -269,7 +270,9 @@ public void UserStatisticsApi()
269270

270271
getStatsResult = PlayFabClientAPI.GetUserStatistics(getRequest);
271272
VerifyResult(getStatsResult, true);
272-
int testStatActual = getStatsResult.Result.UserStatistics == null ? 0 : getStatsResult.Result.UserStatistics.get(TEST_STAT_NAME);
273+
hasStat = getStatsResult.Result.UserStatistics != null && getStatsResult.Result.UserStatistics.containsKey(TEST_STAT_NAME);
274+
assertTrue(hasStat);
275+
int testStatActual = getStatsResult.Result.UserStatistics.get(TEST_STAT_NAME);
273276

274277
assertEquals(testStatExpected, testStatActual);
275278
}
@@ -388,24 +391,12 @@ public void CloudScript()
388391
{
389392
LoginOrRegister();
390393

391-
//if (PlayFabSettings.LogicServerURL == null || PlayFabSettings.LogicServerURL.length() == 0)
392-
{
393-
PlayFabClientModels.GetCloudScriptUrlRequest urlRequest = new PlayFabClientModels.GetCloudScriptUrlRequest();
394-
PlayFabResult<PlayFabClientModels.GetCloudScriptUrlResult> urlResult = PlayFabClientAPI.GetCloudScriptUrl(urlRequest);
395-
VerifyResult(urlResult, true);
396-
assertNotNull(urlResult.Result.Url);
397-
assertTrue(urlResult.Result.Url.length() > 0);
398-
}
399-
400-
PlayFabClientModels.RunCloudScriptRequest hwRequest = new PlayFabClientModels.RunCloudScriptRequest();
401-
hwRequest.ActionId = "helloWorld";
402-
PlayFabResult<PlayFabClientModels.RunCloudScriptResult> hwResult = PlayFabClientAPI.RunCloudScript(hwRequest);
394+
PlayFabClientModels.ExecuteCloudScriptRequest hwRequest = new PlayFabClientModels.ExecuteCloudScriptRequest();
395+
hwRequest.FunctionName = "helloWorld";
396+
PlayFabResult<PlayFabClientModels.ExecuteCloudScriptResult> hwResult = PlayFabClientAPI.ExecuteCloudScript(hwRequest);
403397
VerifyResult(hwResult, true);
404-
assertNotNull(hwResult.Result.ResultsEncoded);
405-
assertTrue(hwResult.Result.ResultsEncoded.length() > 0);
406-
//assertTrue(hwResult.Result.ResultsEncoded, false);
407-
408-
Map<String, String> arbitraryResults = (Map<String, String>)hwResult.Result.Results;
398+
assertNotNull(hwResult.Result.FunctionResult);
399+
Map<String, String> arbitraryResults = (Map<String, String>)hwResult.Result.FunctionResult;
409400
assertEquals(arbitraryResults.get("messageValue"), "Hello " + playFabId + "!");
410401
}
411402

PlayFabSDK/src/com/playfab/PlayFabClientModels.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,19 @@ public static class GameInfo {
813813
/**
814814
* game specific string denoting server configuration
815815
*/
816-
public String GameServerState;
816+
public GameInstanceState GameServerState;
817+
/**
818+
* game session custom data
819+
*/
820+
public String GameServerData;
817821

818822
}
819823

824+
public static enum GameInstanceState {
825+
Open,
826+
Closed
827+
}
828+
820829
public static class GameServerRegionsRequest {
821830
/**
822831
* version of game server for which stats are being requested

PlayFabSDK/src/com/playfab/PlayFabServerAPI.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,6 +3264,64 @@ private static PlayFabResult<RedeemMatchmakerTicketResult> privateRedeemMatchmak
32643264
return pfResult;
32653265
}
32663266

3267+
/**
3268+
* Sets the custom data of the indicated Game Server Instance
3269+
*/
3270+
@SuppressWarnings("unchecked")
3271+
public static FutureTask<PlayFabResult<SetGameServerInstanceDataResult>> SetGameServerInstanceDataAsync(final SetGameServerInstanceDataRequest request) {
3272+
return new FutureTask(new Callable<PlayFabResult<SetGameServerInstanceDataResult>>() {
3273+
public PlayFabResult<SetGameServerInstanceDataResult> call() throws Exception {
3274+
return privateSetGameServerInstanceDataAsync(request);
3275+
}
3276+
});
3277+
}
3278+
3279+
/**
3280+
* Sets the custom data of the indicated Game Server Instance
3281+
*/
3282+
@SuppressWarnings("unchecked")
3283+
public static PlayFabResult<SetGameServerInstanceDataResult> SetGameServerInstanceData(final SetGameServerInstanceDataRequest request) {
3284+
FutureTask<PlayFabResult<SetGameServerInstanceDataResult>> task = new FutureTask(new Callable<PlayFabResult<SetGameServerInstanceDataResult>>() {
3285+
public PlayFabResult<SetGameServerInstanceDataResult> call() throws Exception {
3286+
return privateSetGameServerInstanceDataAsync(request);
3287+
}
3288+
});
3289+
try {
3290+
task.run();
3291+
return task.get();
3292+
} catch(Exception e) {
3293+
return null;
3294+
}
3295+
}
3296+
3297+
/**
3298+
* Sets the custom data of the indicated Game Server Instance
3299+
*/
3300+
@SuppressWarnings("unchecked")
3301+
private static PlayFabResult<SetGameServerInstanceDataResult> privateSetGameServerInstanceDataAsync(final SetGameServerInstanceDataRequest request) throws Exception {
3302+
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
3303+
3304+
FutureTask<Object> task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Server/SetGameServerInstanceData", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
3305+
task.run();
3306+
Object httpResult = task.get();
3307+
if(httpResult instanceof PlayFabError) {
3308+
PlayFabError error = (PlayFabError)httpResult;
3309+
if (PlayFabSettings.GlobalErrorHandler != null)
3310+
PlayFabSettings.GlobalErrorHandler.callback(error);
3311+
PlayFabResult result = new PlayFabResult<SetGameServerInstanceDataResult>();
3312+
result.Error = error;
3313+
return result;
3314+
}
3315+
String resultRawJson = (String) httpResult;
3316+
3317+
PlayFabJsonSuccess<SetGameServerInstanceDataResult> resultData = gson.fromJson(resultRawJson, new TypeToken<PlayFabJsonSuccess<SetGameServerInstanceDataResult>>(){}.getType());
3318+
SetGameServerInstanceDataResult result = resultData.data;
3319+
3320+
PlayFabResult<SetGameServerInstanceDataResult> pfResult = new PlayFabResult<SetGameServerInstanceDataResult>();
3321+
pfResult.Result = result;
3322+
return pfResult;
3323+
}
3324+
32673325
/**
32683326
* Sets the state of the indicated Game Server Instance
32693327
*/

PlayFabSDK/src/com/playfab/PlayFabServerModels.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,6 +1931,22 @@ public static class SendPushNotificationResult {
19311931

19321932
}
19331933

1934+
public static class SetGameServerInstanceDataRequest {
1935+
/**
1936+
* Unique identifier of the Game Instance to be updated.
1937+
*/
1938+
public String LobbyId;
1939+
/**
1940+
* Custom data to set for the specified game server instance.
1941+
*/
1942+
public String GameServerData;
1943+
1944+
}
1945+
1946+
public static class SetGameServerInstanceDataResult {
1947+
1948+
}
1949+
19341950
public static class SetGameServerInstanceStateRequest {
19351951
/**
19361952
* Unique identifier of the Game Instance to be updated.

PlayFabSDK/src/com/playfab/PlayFabSettings.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
import com.playfab.PlayFabErrors.ErrorCallback;
44

55
public class PlayFabSettings {
6+
public static String SdkVersion = "0.27.160613";
7+
public static String BuildIdentifier = "jbuild_0";
8+
public static String SdkVersionString = "JavaSDK-0.27.160613";
9+
610
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)
711
public static ErrorCallback GlobalErrorHandler;
812
public static String DeveloperSecretKey = null; // You must set this value for PlayFabSdk to work properly (Found in the Game Manager for your title, at the PlayFab Website)
9-
public static String LogicServerURL = null; // Assigned by GetCloudScriptUrl, used by RunCloudScript
13+
public static String LogicServerURL = null; // Deprecated
1014
public static String AdvertisingIdType = null; // Set this to the appropriate AD_TYPE_X constant below
1115
public static String AdvertisingIdValue = null; // Set this to corresponding device value
1216

PlayFabSDK/src/com/playfab/internal/PlayFabHTTP.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.*;
77
import com.google.gson.*;
88

9+
import com.playfab.PlayFabSettings;
910
import com.playfab.PlayFabErrors.PlayFabError;
1011
import com.playfab.PlayFabErrors.PlayFabErrorCode;
1112
import com.playfab.PlayFabErrors.PlayFabJsonError;
@@ -43,7 +44,7 @@ else if (request instanceof String) {
4344
if(authType != null) {
4445
con.setRequestProperty(authType, authKey);
4546
}
46-
con.setRequestProperty("X-PlayFabSDK", PlayFabVersion.getVersionString());
47+
con.setRequestProperty("X-PlayFabSDK", PlayFabSettings.SdkVersionString);
4748
con.setDoOutput(true);
4849
con.setDoInput(true);
4950

PlayFabServerSDK/src/com/playfab/PlayFabServerAPI.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,6 +3264,64 @@ private static PlayFabResult<RedeemMatchmakerTicketResult> privateRedeemMatchmak
32643264
return pfResult;
32653265
}
32663266

3267+
/**
3268+
* Sets the custom data of the indicated Game Server Instance
3269+
*/
3270+
@SuppressWarnings("unchecked")
3271+
public static FutureTask<PlayFabResult<SetGameServerInstanceDataResult>> SetGameServerInstanceDataAsync(final SetGameServerInstanceDataRequest request) {
3272+
return new FutureTask(new Callable<PlayFabResult<SetGameServerInstanceDataResult>>() {
3273+
public PlayFabResult<SetGameServerInstanceDataResult> call() throws Exception {
3274+
return privateSetGameServerInstanceDataAsync(request);
3275+
}
3276+
});
3277+
}
3278+
3279+
/**
3280+
* Sets the custom data of the indicated Game Server Instance
3281+
*/
3282+
@SuppressWarnings("unchecked")
3283+
public static PlayFabResult<SetGameServerInstanceDataResult> SetGameServerInstanceData(final SetGameServerInstanceDataRequest request) {
3284+
FutureTask<PlayFabResult<SetGameServerInstanceDataResult>> task = new FutureTask(new Callable<PlayFabResult<SetGameServerInstanceDataResult>>() {
3285+
public PlayFabResult<SetGameServerInstanceDataResult> call() throws Exception {
3286+
return privateSetGameServerInstanceDataAsync(request);
3287+
}
3288+
});
3289+
try {
3290+
task.run();
3291+
return task.get();
3292+
} catch(Exception e) {
3293+
return null;
3294+
}
3295+
}
3296+
3297+
/**
3298+
* Sets the custom data of the indicated Game Server Instance
3299+
*/
3300+
@SuppressWarnings("unchecked")
3301+
private static PlayFabResult<SetGameServerInstanceDataResult> privateSetGameServerInstanceDataAsync(final SetGameServerInstanceDataRequest request) throws Exception {
3302+
if (PlayFabSettings.DeveloperSecretKey == null) throw new Exception ("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
3303+
3304+
FutureTask<Object> task = PlayFabHTTP.doPost(PlayFabSettings.GetURL() + "/Server/SetGameServerInstanceData", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);
3305+
task.run();
3306+
Object httpResult = task.get();
3307+
if(httpResult instanceof PlayFabError) {
3308+
PlayFabError error = (PlayFabError)httpResult;
3309+
if (PlayFabSettings.GlobalErrorHandler != null)
3310+
PlayFabSettings.GlobalErrorHandler.callback(error);
3311+
PlayFabResult result = new PlayFabResult<SetGameServerInstanceDataResult>();
3312+
result.Error = error;
3313+
return result;
3314+
}
3315+
String resultRawJson = (String) httpResult;
3316+
3317+
PlayFabJsonSuccess<SetGameServerInstanceDataResult> resultData = gson.fromJson(resultRawJson, new TypeToken<PlayFabJsonSuccess<SetGameServerInstanceDataResult>>(){}.getType());
3318+
SetGameServerInstanceDataResult result = resultData.data;
3319+
3320+
PlayFabResult<SetGameServerInstanceDataResult> pfResult = new PlayFabResult<SetGameServerInstanceDataResult>();
3321+
pfResult.Result = result;
3322+
return pfResult;
3323+
}
3324+
32673325
/**
32683326
* Sets the state of the indicated Game Server Instance
32693327
*/

0 commit comments

Comments
 (0)