Inheritance: Akka.Interfaced.InterfacedObserver, IUserEventObserver
コード例 #1
0
ファイル: MockClient.cs プロジェクト: SaladLab/TicTacToe
        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>();
        }
コード例 #2
0
ファイル: UserActor.cs プロジェクト: SaladLab/TicTacToe
        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) });
        }