Exemple #1
0
        private void UpdateState(object e)
        {
            e.Match().With <ChatCreatedEvent>(x =>
            {
                State = new ChatEntity(x.Id);
                State.Participants = x.Participants;
                Context.Become(Initialized);
                if (!IsRecovering)
                {
                    ResendToView(x);

                    foreach (var user in x.Participants)
                    {
                        var envelop = new ShardEnvelope(user.Id.ToString(), x);
                        _userRegion.Tell(envelop);
                    }
                }
            });

            e.Match().With <ChatMessageAddedEvent>(x =>
            {
                var chatLogEntity = new ChatLogEntity(x.MessageId, x.Author, x.Message, DateTime.UtcNow);
                State.Log.Add(chatLogEntity);
                if (!IsRecovering)
                {
                    ResendToView(x);
                    foreach (var user in State.Participants)
                    {
                        var envelop = new ShardEnvelope(user.Id.ToString(), x);
                        _userRegion.Tell(envelop);
                    }
                }
            });
        }
Exemple #2
0
 public async Task Add(ChatLogEntity user)
 {
     await _logRepository.Add(user);
 }