Ejemplo n.º 1
0
        public XboxLiveContext(XboxLiveUser user)
        {
            this.User = user;

            try
            {
                this.AppConfig = XboxLiveAppConfiguration.Instance;
            }
            catch (FileLoadException)
            {
                this.AppConfig = null;
            }
            this.Settings = new XboxLiveContextSettings();

            this.LeaderboardService = UseMockServices ? (ILeaderboardService) new MockLeaderboardService(user, Settings, AppConfig) : new LeaderboardService(user, Settings, AppConfig);
        }
Ejemplo n.º 2
0
        public XboxLiveContext(XboxLiveUser user)
        {
#if WINDOWS_UWP
            IntPtr xboxLiveContext;
            var    xsapiResult = XboxLiveContextCreate(user.PCXboxLiveUser, out xboxLiveContext);

            if (xsapiResult != XSAPI_RESULT.XSAPI_RESULT_OK)
            {
                throw new XboxException(xsapiResult);
            }
            XboxLiveContextPtr = xboxLiveContext;

            this.TitleStorageService = new TitleStorageService(XboxLiveContextPtr);
            this.PrivacyService      = new PrivacyService(XboxLiveContextPtr);
#else
            // TODO MockServices and/or MockHttp
            this.TitleStorageService = null;
            this.PrivacyService      = null;
#endif
        }
        public XboxLiveServices(XboxLiveUser user)
        {
#if UNITY_EDITOR
            // TODO Implement mock title storage service for unity editor
            this.TitleStorageService = null;
            this.PrivacyService      = null;
#else
            IntPtr xboxLiveContext;
            var    xsapiResult = XboxLiveContextCreate(user.PCXboxLiveUser, out xboxLiveContext);

            if (xsapiResult != XSAPI_RESULT.XSAPI_RESULT_OK)
            {
                throw new XboxException(xsapiResult);
            }
            XboxLiveContextPtr = xboxLiveContext;

            this.TitleStorageService = new TitleStorageService(XboxLiveContextPtr);
            this.PrivacyService      = new PrivacyService(XboxLiveContextPtr);
#endif
        }
        public Task <XboxLiveHttpResponse> GetResponseWithAuth(XboxLiveUser user, HttpCallResponseBodyType httpCallResponseBodyType)
        {
            TaskCompletionSource <XboxLiveHttpResponse> getResponseCompletionSource = new TaskCompletionSource <XboxLiveHttpResponse>();

            user.GetTokenAndSignatureAsync(this.Method, this.Url, this.Headers).ContinueWith(
                tokenTask =>
            {
                if (tokenTask.IsFaulted)
                {
                    getResponseCompletionSource.SetException(tokenTask.Exception);
                    return;
                }

                var result = tokenTask.Result;
#if !WINDOWS_UWP
                this.SetCustomHeader(AuthorizationHeaderName, string.Format("XBL3.0 x={0};{1}", result.XboxUserHash, result.Token));
#else
                this.SetCustomHeader(AuthorizationHeaderName, string.Format("{0}", result.Token));
#endif
                this.SetCustomHeader(SignatureHeaderName, tokenTask.Result.Signature);
                try
                {
                    this.GetResponseWithoutAuth(httpCallResponseBodyType).ContinueWith(getResponseTask =>
                    {
                        if (getResponseTask.IsFaulted)
                        {
                            getResponseCompletionSource.SetException(getResponseTask.Exception);
                        }

                        getResponseCompletionSource.SetResult(getResponseTask.Result);
                    });
                }
                catch (Exception e)
                {
                    getResponseCompletionSource.SetException(e);
                }
            });

            return(getResponseCompletionSource.Task);
        }
Ejemplo n.º 5
0
        public Task <XboxLiveHttpResponse> GetResponseWithAuth(XboxLiveUser user)
        {
            TaskCompletionSource <XboxLiveHttpResponse> taskCompletionSource = new TaskCompletionSource <XboxLiveHttpResponse>();

            this.User = user;

            user.GetTokenAndSignatureAsync(this.Method, this.Url, this.Headers).ContinueWith(
                tokenTask =>
            {
                if (tokenTask.IsFaulted)
                {
                    taskCompletionSource.SetException(tokenTask.Exception);
                    return;
                }

                try
                {
                    this.SetAuthHeaders(tokenTask.Result);
                    this.SetRequestHeaders();
                    this.InternalGetResponse().ContinueWith(getResponseTask =>
                    {
                        if (getResponseTask.IsFaulted)
                        {
                            taskCompletionSource.SetException(getResponseTask.Exception);
                        }
                        else
                        {
                            taskCompletionSource.SetResult(getResponseTask.Result);
                        }
                    });
                }
                catch (Exception e)
                {
                    taskCompletionSource.SetException(e);
                }
            });

            return(taskCompletionSource.Task);
        }
 public SignOutCompletedEventArgs(XboxLiveUser user)
 {
     this.User = user;
 }
 public XboxLiveServices(XboxLiveUser user)
 {
     this.privacyService = new PrivacyService(user);
 }