예제 #1
0
        public static async Task <PlayFabResult <LogoutResult> > Logout(LogoutRequest request)
        {
            //Save titleId
            var titleId = PlayFabSettings.TitleId;

            //Set titleId to editor;
            PlayFabSettings.TitleId = "editor";
            object httpResult = await PlayFabHTTP.DoPost("/DeveloperTools/User/Logout", request, null, null);

            if (httpResult is PlayFabError)
            {
                PlayFabError error = (PlayFabError)httpResult;
                if (PlayFabSettings.GlobalErrorHandler != null)
                {
                    PlayFabSettings.GlobalErrorHandler(error);
                }
                return(new PlayFabResult <LogoutResult> {
                    Error = error,
                });
            }
            string resultRawJson = (string)httpResult;

            var          serializer = JsonSerializer.Create(PlayFabUtil.JsonSettings);
            var          resultData = serializer.Deserialize <PlayFabJsonSuccess <LogoutResult> >(new JsonTextReader(new StringReader(resultRawJson)));
            LogoutResult result     = resultData.data;

            //Set titleId back to what it was before.
            PlayFabSettings.TitleId = titleId;
            return(new PlayFabResult <LogoutResult> {
                Result = result
            });
        }
        private void WaitForApiCalls()
        {
            lastReceivedMessage = null;
            DateTime expireTime = DateTime.UtcNow + TimeSpan.FromSeconds(3);

            while (PlayFabHTTP.GetPendingMessages() != 0 && DateTime.UtcNow < expireTime)
            {
                Thread.Sleep(1);               // Wait for the threaded call to be executed
                PlayFabHTTP.instance.Update(); // Invoke the callbacks for any threaded messages
            }
            UUnitAssert.True(DateTime.UtcNow < expireTime, "Request timed out");
            UUnitAssert.NotNull(lastReceivedMessage, "Unexpected internal error within PlayFab api, or test suite");
        }
예제 #3
0
        /// <summary>
        /// Instructs the PlayFab game server hosting service to instantiate a new Game Server Instance
        /// </summary>
        public static void StartGame(StartGameRequest request, ProcessApiCallback <StartGameResponse> resultCallback, ErrorCallback errorCallback, object customData = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new Exception("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy);
            Action <CallRequestContainer> callback = delegate(CallRequestContainer requestContainer)
            {
                ResultContainer <StartGameResponse> .HandleResults(requestContainer, resultCallback, errorCallback, null);
            };

            PlayFabHTTP.Post("/Matchmaker/StartGame", serializedJson, "X-SecretKey", PlayFabSettings.DeveloperSecretKey, callback, request, customData);
        }
        /// <summary>
        /// Instructs the PlayFab game server hosting service to instantiate a new Game Server Instance
        /// </summary>
        public static void StartGame(StartGameRequest request, StartGameCallback resultCallback, ErrorCallback errorCallback, object customData = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new Exception("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            string serializedJson = JsonConvert.SerializeObject(request, Util.JsonFormatting, Util.JsonSettings);
            Action <CallRequestContainer> callback = delegate(CallRequestContainer requestContainer)
            {
                StartGameResponse result = ResultContainer <StartGameResponse> .HandleResults(requestContainer, resultCallback, errorCallback);

                if (result != null)
                {
                }
            };

            PlayFabHTTP.Post("/Matchmaker/StartGame", serializedJson, "X-SecretKey", PlayFabSettings.DeveloperSecretKey, callback, request, customData);
        }