Example #1
0
        public void Open(string userId, IFizzAuthRestClient client, FizzSessionRepository sessionRepository)
        {
            IfClosed(() =>
            {
                if (string.IsNullOrEmpty(userId))
                {
                    throw FizzException.ERROR_INVALID_USER_ID;
                }
                if (client == null)
                {
                    throw ERROR_INVALID_REST_CLIENT;
                }
                if (sessionRepository == null)
                {
                    throw FizzException.ERROR_INVALID_SESSION_REPOSITORY;
                }

                if (_userId == userId)
                {
                    return;
                }

                _userId     = userId;
                _restClient = client;

                _messageListener.Open(userId, sessionRepository);
            });
        }
Example #2
0
 public void Close()
 {
     IfOpened(() =>
     {
         _restClient = null;
     });
 }
        public void Open(string userId, long curServerTS, IFizzAuthRestClient client)
        {
            IfClosed(() =>
            {
                if (_userId != null)
                {
                    FizzLogger.W("Please close instance before re-opening");
                    return;
                }

                if (userId == null)
                {
                    throw FizzException.ERROR_INVALID_USER_ID;
                }
                if (client == null)
                {
                    throw ERROR_INVALID_CLIENT;
                }

                _client     = client;
                _userId     = userId;
                _timeOffset = FizzUtils.Now() - curServerTS;
                _startTime  = FizzUtils.Now() + _timeOffset;
                _sessionId  = Guid.NewGuid().ToString();

                ClosePreviousSession();
                SessionStarted();

                _interval.Enable();
                _onLogEmpty = () => { };
            });
        }
Example #4
0
 public void Open(IFizzAuthRestClient client)
 {
     IfClosed(() =>
     {
         _client = client;
     });
 }
Example #5
0
        public void Close(Action cb)
        {
            IfOpened(() =>
            {
                _userId     = null;
                _restClient = null;

                _messageListener.Close(cb);
            });
        }
Example #6
0
 public FizzClient(IFizzSessionProvider sessionClient)
 {
     _dispatcher       = new FizzActionDispatcher();
     _sessionClient    = sessionClient;
     _chat             = new FizzChatClient(_dispatcher);
     _restClient       = new FizzRestClient(_dispatcher);
     _authClient       = new FizzAuthRestClient(_restClient);
     _ingestionClient  = new FizzIngestionClient(new FizzInMemoryEventLog(), _dispatcher);
     _moderationClient = new FizzModerationClient();
 }
Example #7
0
        public void Open(IFizzAuthRestClient client)
        {
            IfClosed(() =>
            {
                if (client == null)
                {
                    throw ERROR_INVALID_REST_CLIENT;
                }

                _restClient = client;
            });
        }
        public void Close(Action cb)
        {
            IfOpened(() =>
            {
                _userId     = null;
                _restClient = null;

                _users.Close();
                _groups.Close();
                _userNotifications.Close();
                _messageListener.Close(cb);
            });
        }
Example #9
0
        public FizzClient(string appId, IFizzSessionProvider sessionClient)
        {
            if (string.IsNullOrEmpty(appId))
            {
                throw FizzException.ERROR_INVALID_APP_ID;
            }

            _sessionClient    = sessionClient;
            _chat             = new FizzChatClient(appId, _dispatcher);
            _restClient       = new FizzRestClient(_dispatcher);
            _authClient       = new FizzAuthRestClient(_restClient);
            _ingestionClient  = new FizzIngestionClient(new FizzInMemoryEventLog(), _dispatcher);
            _moderationClient = new FizzModerationClient();
        }
Example #10
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);
        }
Example #11
0
        public void Close(Action callback)
        {
            IfOpened(() =>
            {
                _interval.Disable();
                UpdateSessionTimestamp();

                _onLogEmpty = () =>
                {
                    _userId     = null;
                    _client     = null;
                    _sessionId  = null;
                    _onLogEmpty = null;
                    callback();
                };

                Flush();
            });
        }
Example #12
0
        public FizzClient(string appId, string appSecret)
        {
            if (string.IsNullOrEmpty(appId))
            {
                throw FizzException.ERROR_INVALID_APP_ID;
            }

            if (string.IsNullOrEmpty(appSecret))
            {
                throw FizzException.ERROR_INVALID_APP_SECRET;
            }

            _dispatcher       = new FizzActionDispatcher();
            _chat             = new FizzChatClient(_dispatcher);
            _restClient       = new FizzRestClient(_dispatcher);
            _sessionClient    = new FizzIdSecretSessionProvider(appId, appSecret, _restClient);
            _authClient       = new FizzAuthRestClient(_restClient);
            _ingestionClient  = new FizzIngestionClient(new FizzInMemoryEventLog(), _dispatcher);
            _moderationClient = new FizzModerationClient();
        }
        public void Close(Action callback)
        {
            IfOpened(() =>
            {
                _interval.Disable();
                UpdateSessionTimestamp();
                //SessionEnded(_startTime, FizzUtils.Now() + _timeOffset);

                _onLogEmpty = () =>
                {
                    _userId     = null;
                    _client     = null;
                    _sessionId  = null;
                    _onLogEmpty = null;
                    callback();
                };

                Flush();
            });
        }
 public void Close()
 {
     _restClient = null;
 }
Example #15
0
 public FizzFetchUserGroupsQuery(string userId, IFizzAuthRestClient restClient)
 {
     _userId     = userId;
     _restClient = restClient;
     HasNext     = true;
 }