Advertisement
Guest User

playfab

a guest
Jul 22nd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. // PlayFabClientTest.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include <cstdio>
  5.  
  6. #include <stdio.h>
  7.  
  8. #include "playfab\PlayFabClientAPI.h"
  9. #include "playfab\PlayFabSettings.h"
  10.  
  11.  
  12. using namespace PlayFab;
  13. using namespace PlayFab::ClientModels;
  14.  
  15. static bool gRunning = true;
  16.  
  17. void GlobalErrorHandler(PlayFabError& error, void* userData);
  18.  
  19. void OnLogin(LoginResult& result, void* userData);
  20. void OnLoginError(PlayFabError& error, void* userData);
  21.  
  22. void OnRegister(RegisterPlayFabUserResult& result, void* userData);
  23. void OnRegisterError(PlayFabError& error, void* userData);
  24.  
  25.  
  26. int main()
  27. {
  28.  
  29.  
  30. PlayFab::PlayFabSettings::titleId = "CAC9";
  31. PlayFab::PlayFabSettings::globalErrorHandler = GlobalErrorHandler;
  32.  
  33. PlayFab::ClientModels::RegisterPlayFabUserRequest registerRequest_;
  34. //PlayFab::ClientModels::RegisterPlayFabUserResult result_;
  35.  
  36. registerRequest_.Username = "sdkTestUser";
  37. registerRequest_.Password = "sdkTestPass";
  38. registerRequest_.Email = "test@sdk.com";
  39. registerRequest_.DisplayName = "Test SDK User";
  40. registerRequest_.RequireBothUsernameAndEmail = false;
  41.  
  42. PlayFabClientAPI::RegisterPlayFabUser(registerRequest_, OnRegister, OnRegisterError);
  43.  
  44. int counter = 0;
  45.  
  46. do
  47. {
  48. PlayFabClientAPI::Update();
  49. printf("Waiting for Registration. Counter = %d\n", ++counter);
  50. } while (gRunning);
  51.  
  52.  
  53.  
  54. LoginWithPlayFabRequest loginRequest_;
  55.  
  56. loginRequest_.Username = "sdkTestUser";
  57. loginRequest_.Password = "sdkTestPass";
  58.  
  59. PlayFabClientAPI::LoginWithPlayFab(loginRequest_, OnLogin, OnLoginError);
  60.  
  61. gRunning = true;
  62.  
  63. do
  64. {
  65. PlayFabClientAPI::Update();
  66. printf("Waiting for Login. Counter = %d\n", ++counter);
  67. } while (gRunning);
  68.  
  69. system("pause");
  70. return 0;
  71. }
  72.  
  73.  
  74. void GlobalErrorHandler(PlayFabError& error, void* userData)
  75. {
  76. printf("Got a global error\n");
  77. }
  78.  
  79. void OnLogin(LoginResult& result, void* userData)
  80. {
  81. printf("Got successful login\n");
  82. gRunning = false;
  83. }
  84.  
  85. void OnLoginError(PlayFabError& error, void* userData)
  86. {
  87. printf("Got error on login\n");
  88. gRunning = false;
  89. }
  90.  
  91. void OnRegister(RegisterPlayFabUserResult& result, void* userData)
  92. {
  93. printf("Got successful register\n");
  94. gRunning = false;
  95. }
  96.  
  97. void OnRegisterError(PlayFabError& error, void* userData)
  98. {
  99. printf("Got error on register\n");
  100. gRunning = false;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement