示例#1
0
        //TODO: Track Actor Shutdown instead of just broadcast

        public ProcessSupervisor(bool autoRun, ISystemStarted firstMsg, List <IProcessInfo> processInfos, List <IComplexEventAction> processComplexEvents) : base(firstMsg.Process)
        {
            ctx                  = Context;
            ProcessInfos         = processInfos;
            ProcessComplexEvents = processComplexEvents;
            EventMessageBus.Current.GetEvent <IStartSystemProcess>(Source).Where(x => autoRun && x.ProcessToBeStartedId == ProcessActions.NullProcess).Subscribe(x => StartParentProcess(x.Process.Id, x.User));
            EventMessageBus.Current.GetEvent <IStartSystemProcess>(Source).Where(x => !autoRun && x.ProcessToBeStartedId != ProcessActions.NullProcess).Subscribe(x => StartProcess(x.ProcessToBeStartedId, x.User));
            StartProcess(firstMsg.Process.Id, firstMsg.User);
        }
        public ViewModelSupervisor(List <IViewModelInfo> processViewModelInfos, ISystemProcess process, ISystemStarted firstMsg) : base(process)
        {
            ProcessViewModelInfos = processViewModelInfos;
            ctx = Context;
            Task.Run(() =>
            {
                ctx.ActorOf(
                    Props.Create <ViewModelActor>(process)
                    .WithRouter(new RoundRobinPool(1,
                                                   new DefaultResizer(1, Environment.ProcessorCount, 1, .2, .3, .1, Environment.ProcessorCount))),
                    "ViewModelActorEntityActor");
            });


            EventMessageBus.Current.GetEvent <ISystemProcessStarted>(Source).Subscribe(x => HandleProcessViews(x));

            EventMessageBus.Current.GetEvent <IServiceStarted <IViewModelService> >(Source).Subscribe(x =>
            {
                EventMessageBus.Current.Publish(new ServiceStarted <IViewModelSupervisor>(this, new StateEventInfo(process.Id, RevolutionData.Context.Actor.Events.ActorStarted), process, Source), Source);
            });

            //HandleProcessViews(firstMsg);
        }