private Dictionary <string, PID> CreataActors <T>(IEnumerable <T> config) where T : IBaseObject, IPropertySource
        {
            var actors = new Dictionary <string, PID>();

            foreach (var actorConfig in config)
            {
                var actor = _actorFactory.CreateActor(actorConfig);
                actors.Add(actorConfig.Uid, actor);
            }
            return(actors);
        }
        protected override void PreStart()
        {
            base.PreStart();
            _booksManagerActor  = _actorFactory.CreateActor <BooksManagerActor>();
            _consoleWriterActor = _actorFactory.CreateActor <ConsoleWriterActor>();
            _badActorActor      = Context.ActorOf <BadActor>();

            Context.System.Scheduler.ScheduleTellRepeatedly(
                TimeSpan.FromSeconds(5),
                TimeSpan.FromSeconds(5),
                _badActorActor,
                new Messages.BadActorMessage.DoThrownInsanelyBadException(),
                ActorRefs.Nobody);
        }
Beispiel #3
0
        private IDictionary <string, PID> MapComponents(HomeCenterConfigDTO result)
        {
            var components             = new Dictionary <string, PID>();
            List <ComponentProxy> comp = new List <ComponentProxy>();

            foreach (var componentConfig in result.HomeCenter.Components)
            {
                var localConfigCopy = componentConfig; // prevents override of componentConfig when executed in multi thread

                var component = _actorFactory.CreateActor(() => _mapper.Map <ComponentProxy>(localConfigCopy), localConfigCopy.Uid);
                components.Add(localConfigCopy.Uid, component);
            }

            return(components);
        }
Beispiel #4
0
        private void Handle(DistributedActorTableMessage <TKey> .Internal.Create m)
        {
            if (_table == null || _stopping)
            {
                return;
            }

            if (_actorFactory == null)
            {
                _log.Error("I don't have ActorFactory.");
                Sender.Tell(new DistributedActorTableMessage <TKey> .Internal.CreateReply(m.Id, null));
                return;
            }

            IActorRef actor;

            try
            {
                actor = _actorFactory.CreateActor(Context, m.Id, m.Args);
            }
            catch (Exception e)
            {
                _log.Error(e, $"Exception in creating actor (Id={m.Id})");
                Sender.Tell(new DistributedActorTableMessage <TKey> .Internal.CreateReply(m.Id, null));
                return;
            }

            _actorMap.Add(m.Id, actor);
            _actorInverseMap.Add(actor, m.Id);
            Context.Watch(actor);
            _watchingActorCount += 1;

            Sender.Tell(new DistributedActorTableMessage <TKey> .Internal.CreateReply(m.Id, actor));
        }
 public ConsoleApplication(
     ActorSystem system,
     IActorFactory actorFactory)
 {
     _system          = system;
     _actorFactory    = actorFactory;
     _chatClientActor = _actorFactory.CreateActor <ChatClientActor>("ChatClient");
 }
Beispiel #6
0
 public ConsoleApplication(
     ActorSystem system,
     IActorFactory actorFactory)
 {
     _system             = system;
     _actorFactory       = actorFactory;
     _consoleReaderActor = _actorFactory.CreateActor <ConsoleReaderActor>();
 }
Beispiel #7
0
        private void StartSystemFromConfiguration(IContext context)
        {
            _configService = _actorFactory.CreateActor <ConfigurationService>(parent: context);



            MessageBroker.Send(StartSystemCommand.Create(_startupConfiguration.ConfigurationLocation), _configService);
        }