示例#1
0
        public OgnConvertActor(
            IActorRefFactory actorSystem,
            AircraftProvider aircraftProvider,
            GatewayConfiguration gatewayConfiguration
            )
        {
            // When receiving the raw string from the listener, convert it to FlightData and pass it to the next Actor
            Receive <string>(message =>
            {
                var convertedMessage = StreamConversionService.ConvertData(message);
                if (convertedMessage == null)
                {
                    // Ignore non-parseable messages
                    return;
                }

                // The next step also happens on this Actor so tell another "Self" to handle the FlightData
                actorSystem.ActorSelection(Self.Path).Tell(convertedMessage, Self);
            });

            // When receiving FlightData, convert it into FlightDataDto and pass it to the next actor
            Receive <FlightData>(message =>
            {
                var aircraft = aircraftProvider.Load(message.AircraftId);
                if (!aircraft.Visible)
                {
                    // The aircraft should not be visible, therefore drop the message.
                    return;
                }

                var flying = message.Altitude >= gatewayConfiguration.MinimalAltitude &&
                             message.Speed >= gatewayConfiguration.MinimalSpeed;

                var convertedMessage = new FlightDataDto(
                    message.Speed,
                    message.Altitude,
                    message.VerticalSpeed,
                    message.TurnRate,
                    message.Course,
                    message.Position,
                    message.DateTime,
                    new AircraftDto(aircraft),
                    flying
                    );

                // Pass the convertedMessage to the IMessageProcessActor so it can be further processed.
                actorSystem
                .ActorSelection($"user/{ActorControlService.MessageProcessActorName}")
                .Tell(convertedMessage, Self);
            });
        }
 public PushNotificationsService(
     IActorRefFactory actorsFactory,
     ActorPathsBuilder actorPathsBuilder)
 {
     this.pushNotificationsDevicesActor = actorsFactory.ActorSelection(
         actorPathsBuilder.Get(WellKnownActorPaths.PushNotificationsDevices));
 }
示例#3
0
 public static void TellEntityChildren <TMessageType>(this IActorRefFactory selector, IActorRef sender)
     where TMessageType : EntityActorMessage, new()
 {
     selector
     .ActorSelection(MEAKKASelectionConstants.ALL_DIRECT_CHILDREN_SELECTOR)
     .TellEntitySelection(new TMessageType(), sender);
 }
 public UserPreferencesService(
     IActorRefFactory actorsFactory,
     ActorPathsBuilder actorPathsBuilder,
     ITimeoutSettings timeoutSettings)
 {
     this.userPreferencesActor = actorsFactory.ActorSelection(
         actorPathsBuilder.Get(WellKnownActorPaths.UserPreferences));
     this.timeoutSettings = timeoutSettings;
 }
 public DepartmentFeaturesService(
     IActorRefFactory actorsFactory,
     ActorPathsBuilder actorPathsBuilder,
     ITimeoutSettings timeoutSettings)
 {
     this.organizationActor = actorsFactory.ActorSelection(
         actorPathsBuilder.Get(WellKnownActorPaths.Organization));
     this.timeoutSettings = timeoutSettings;
 }
示例#6
0
        public ShellViewModel(HomeViewModel home, SettingsViewModel settings, ConversationsViewModel convos, IActorRefFactory system)
        {
            _screens.Add(Screens.Home, home);
            _screens.Add(Screens.Settings, settings);
            _screens.Add(Screens.Conversations, convos);

            system.ActorSelection(ClientActorPaths.ErrorDialogActor.Path)
                .Tell(new ErrorDialogActor.RegisterShell(this));

            _shellViewModelActor = system.ActorOf(Props.Create(() => new ShellViewModelActor(this)),
                ClientActorPaths.ShellViewModelActor.Name);
        }
示例#7
0
        public MagazineQuery(IActorRefFactory actorSystem)
        {
            Name = "Query";

            var categoryQuery = actorSystem.ActorSelection($"/user/{SystemData.CategoryQueryActor.Name}-group");

            FieldAsync <ListGraphType <CategoryType> >("categories", resolve: async context =>
            {
                var result = await categoryQuery.Ask <List <CategoryViewResponse> >(new ListCategoryViewRequest());
                return(result.Select(x => new CategoryGraph
                {
                    Id = x.Id.ToString(),
                    Name = x.Name,
                    Status = x.Status.ToString()
                }));
            });
        }
        public IActorRef GetOrCreateActorForComponent(T component)
        {
            string    actorName = $"Component_{component.Id}";
            IActorRef componentActor;

            try
            {
                componentActor = actorRefFactory.ActorSelection($"user/{actorName}").ResolveOne(TimeSpan.FromSeconds(1))
                                 .Result;
            }
            catch (AggregateException exception) when(exception.InnerException is ActorNotFoundException)
            {
                componentActor = ActorRefs.Nobody;
            }

            return(!componentActor.IsNobody()
                ? componentActor
                : actorRefFactory.ActorOf(GetProps(component), actorName));
        }
示例#9
0
 public ActorSelection Selection(IActorRefFactory context)
 {
     return(context.ActorSelection(Path));
 }
 /// <summary>
 /// Constructor for CategoryController
 /// </summary>
 /// <param name="actorSystem"></param>
 public CategoryController(IActorRefFactory actorSystem)
 {
     _categoryCommander = actorSystem.ActorSelection($"/user/{SystemData.CategoryCommanderActor.Name}-group");
     _categoryQuery     = actorSystem.ActorSelection($"/user/{SystemData.CategoryQueryActor.Name}-group");
 }
示例#11
0
 public static void TellEntityChildren(this IActorRefFactory selector, EntityActorMessage message)
 {
     selector
     .ActorSelection(MEAKKASelectionConstants.ALL_DIRECT_CHILDREN_SELECTOR)
     .TellEntitySelection(message);
 }