Exemplo n.º 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
            });
        }
        /// <summary>
        /// Informs the PlayFab game server hosting service that the indicated user has left the Game Server Instance specified
        /// </summary>
        public static async Task <PlayFabResult <PlayerLeftResponse> > PlayerLeftAsync(PlayerLeftRequest request, object customData = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new Exception("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            var httpResult = await PlayFabHttp.DoPost("/Matchmaker/PlayerLeft", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey);

            if (httpResult is PlayFabError)
            {
                var error = (PlayFabError)httpResult;
                if (PlayFabSettings.GlobalErrorHandler != null)
                {
                    PlayFabSettings.GlobalErrorHandler(error);
                }
                return(new PlayFabResult <PlayerLeftResponse> {
                    Error = error, CustomData = customData
                });
            }

            var resultRawJson = (string)httpResult;
            var resultData    = JsonWrapper.DeserializeObject <PlayFabJsonSuccess <PlayerLeftResponse> >(resultRawJson);
            var result        = resultData.data;

            return(new PlayFabResult <PlayerLeftResponse> {
                Result = result, CustomData = customData
            });
        }
 public virtual string GetFullUrl(string apiCall, Dictionary <string, string> getParams)
 {
     return(PlayFabSettings.GetFullUrl(apiCall, getParams, this));
 }
Exemplo n.º 4
0
 public virtual string GetFullUrl(string apiCall)
 {
     return(PlayFabSettings.GetFullUrl(apiCall, RequestGetParams, this));
 }