コード例 #1
0
        public void Open(string userId, string userName, IFizzLanguageCode lang, FizzServices services, bool tranlation, Action <bool> onDone)
        {
            if (!_isIntialized)
            {
                Initialize();
            }

            if (string.IsNullOrEmpty(userId))
            {
                FizzLogger.E("FizzService can not open client with null of empty userId.");
                return;
            }

            if (string.IsNullOrEmpty(userName))
            {
                FizzLogger.E("FizzService can not open client with null of empty userName.");
                return;
            }

            if (lang == null)
            {
                FizzLogger.E("FizzService can not open client with null language code.");
                return;
            }

            UserId               = userId;
            UserName             = userName;
            Language             = lang;
            IsTranslationEnabled = tranlation;
            Client.Open(userId, lang, services, ex =>
            {
                if (onDone != null)
                {
                    onDone(ex == null);
                }

                if (ex != null)
                {
                    FizzLogger.E("Something went wrong while connecting to FizzClient. " + ex);
                }
                else
                {
                    AddInternalListeners();
                }
            });
        }
コード例 #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);
            }
        }