Exemplo n.º 1
0
        public static Task FetchSessionToken(IFizzAuthRestClient client, string userId, string locale)
        {
            TaskCompletionSource <object> fetched = new TaskCompletionSource <object>();

            client.Open(userId, locale);
            client.FetchSessionToken(ex =>
            {
                if (ex != null)
                {
                    fetched.SetException(ex);
                }
                else
                {
                    fetched.SetResult(null);
                }
            });

            return(fetched.Task);
        }
Exemplo n.º 2
0
        public void Open(string userId, IFizzLanguageCode locale, FizzServices services, Action <FizzException> callback)
        {
            try
            {
                if (State == FizzClientState.Opened)
                {
                    FizzUtils.DoCallback(null, callback);
                    return;
                }

                FizzSessionRepository sessionRepo = new FizzSessionRepository(userId, locale.Code, _sessionClient);
                _authClient.Open(sessionRepo, ex =>
                {
                    if (ex == null)
                    {
                        if (services.HasFlag(FizzServices.Chat))
                        {
                            _chat.Open(userId, _authClient, sessionRepo);
                        }
                        if (services.HasFlag(FizzServices.Analytics))
                        {
                            _ingestionClient.Open(userId, sessionRepo.Session._serverTS, _authClient);
                        }
                        if (services.HasFlag(FizzServices.Moderation))
                        {
                            _moderationClient.Open(_authClient);
                        }

                        State = FizzClientState.Opened;
                        FizzUtils.DoCallback(null, callback);
                    }
                    else
                    {
                        FizzUtils.DoCallback(ex, callback);
                    }
                });
            }
            catch (FizzException ex)
            {
                FizzUtils.DoCallback(ex, callback);
            }
        }