Inheritance: Akka.Interfaced.InterfacedObserver, IUserEventObserver
Beispiel #1
0
        public async Task PrepareUserAsync(string id, string password, string userName = null)
        {
            if (User != null)
                throw new InvalidOperationException("Already user prepared!");

            if (UserInitiator == null)
                await LoginAsync(id, password);

            _userEventObserver = (UserEventObserver)Channel.CreateObserver<IUserEventObserver>(this);

            try
            {
                UserContext = await UserInitiator.Load(_userEventObserver);
            }
            catch (ResultException e)
            {
                if (e.ResultCode == ResultCodeType.UserNeedToBeCreated)
                    UserContext = await UserInitiator.Create(_userEventObserver, userName ?? id.ToUpper());
                else
                    throw;
            }

            User = UserInitiator.Cast<UserRef>();
        }
Beispiel #2
0
        private async Task OnUserInitiated(TrackableUserContext userContext, IUserEventObserver observer)
        {
            _userContext = userContext.Clone();
            _userContext.SetDefaultTracker();
            _userContextSaveTracker = new TrackableUserContextTracker();

            _userEventObserver = (UserEventObserver)observer;

            _channel.WithNoReply().UnbindType(Self, new[] { typeof(IUserInitiator) });
            await _channel.BindType(Self, new TaggedType[] { typeof(IUser) });
        }