Line data Source code
1 : using System;
2 : using cdmdotnet.Logging;
3 : using Cqrs.Akka.Commands;
4 : using Cqrs.Akka.Domain;
5 : using Cqrs.Akka.Events;
6 : using Cqrs.Akka.Tests.Unit.Commands;
7 : using Cqrs.Commands;
8 : using Cqrs.Events;
9 : using Cqrs.Authentication;
10 :
11 : namespace Cqrs.Akka.Tests.Unit.Events.Handlers
12 : {
13 : public class HelloWorldRepliedToSendEndConversationCommandEventHandler
14 : : IEventHandler<Guid, HelloWorldRepliedTo>
15 0 : {
16 : /// <summary>
17 : /// Instantiates the <see cref="HelloWorldRepliedToSendEndConversationCommandEventHandler"/> class registering any <see cref="ReceiveActor.Receive{T}(System.Func{T,System.Threading.Tasks.Task})"/> required.
18 : /// </summary>
19 1 : public HelloWorldRepliedToSendEndConversationCommandEventHandler(IAkkaAggregateResolver aggregateResolver)
20 : {
21 : AggregateResolver = aggregateResolver;
22 : }
23 :
24 : protected IAkkaAggregateResolver AggregateResolver { get; private set; }
25 :
26 : #region Implementation of IMessageHandler<in HelloWorldRepliedTo>
27 :
28 0 : public void Handle(HelloWorldRepliedTo @event)
29 : {
30 : global::Akka.Actor.IActorRef item = AggregateResolver.ResolveActor<Actor>();
31 : // bool result = global::Akka.Actor.Futures.Ask<bool>(item, @event).Result;
32 : global::Akka.Actor.ActorRefImplicitSenderExtensions.Tell(item, @event);
33 : }
34 :
35 : #endregion
36 :
37 : public partial class Actor
38 : : AkkaEventHandler<Guid>
39 0 : {
40 : protected ICommandPublisher<Guid> CommandBus { get; private set; }
41 :
42 : #region Implementation of IMessageHandler<in HelloWorldRepliedTo>
43 :
44 0 : public void Handle(HelloWorldRepliedTo message)
45 : {
46 : CommandBus.Publish(new EndConversationCommand { Id = message.Id });
47 : AkkaUnitTests.Step3Reached[message.CorrelationId] = true;
48 : }
49 :
50 : #endregion
51 :
52 0 : public Actor(ILogger logger, ICorrelationIdHelper correlationIdHelper, IAuthenticationTokenHelper<Guid> authenticationTokenHelper, IAkkaCommandSender<Guid> commandBus)
53 : : base(logger, correlationIdHelper, authenticationTokenHelper)
54 : {
55 : CommandBus = commandBus;
56 : Receive<HelloWorldRepliedTo>(@event => Execute(Handle, @event));
57 : }
58 : }
59 : }
60 : }
|