当前位置: 首页>>代码示例>>C#>>正文


C# ActorSystem.ActorSelection方法代码示例

本文整理汇总了C#中ActorSystem.ActorSelection方法的典型用法代码示例。如果您正苦于以下问题:C# ActorSystem.ActorSelection方法的具体用法?C# ActorSystem.ActorSelection怎么用?C# ActorSystem.ActorSelection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActorSystem的用法示例。


在下文中一共展示了ActorSystem.ActorSelection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static void Main(string[] args)
        {
            MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem");
            MovieStreamingActorSystem.ActorOf(Props.Create<PlaybackActor>(), "Playback");

            do
            {
                ShortPause();

                Console.WriteLine();
                Console.WriteLine("enter a command and hit enter");

                var command = Console.ReadLine();

                if (command.StartsWith("play"))
                {
                    int userId = int.Parse(command.Split(',')[1]);
                    string movieTitle = command.Split(',')[2];

                    var message = new PlayMovieMessage(movieTitle, userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

                if (command.StartsWith("stop"))
                {
                    int userId = int.Parse(command.Split(',')[1]);

                    var message = new StopMovieMessage(userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

            } while (true);
        }
开发者ID:kenlefeb,项目名称:pluralsight-akka-di,代码行数:33,代码来源:Program.cs

示例2: Main

        static void Main(string[] args)
        {
            // Akka prefers creation of objects via factories
            // this is due to the fact that internally Akka does a lot of system internally
            ReceiveActorSystem = ActorSystem.Create("ReceiveActorSystem");
            Console.WriteLine("Actor system created");

            // Akka uses the movie industry to name a few items
            // To create an Actor you use the Props class
            Props whatsMyTypeAgainProps = Props.Create<WhatsMyTypeAgainActor>();

            // ActorOf will create the Actor
            // You can get a reference to the Actor using the ActorOf which returns an IActorRef
            ReceiveActorSystem.ActorOf(whatsMyTypeAgainProps, "WhatsMyTypeAgain");

            // Alternatively you can use ActorSelection and a path to the Actor
            ActorSelection whatsMyTypeAgainActor = ReceiveActorSystem.ActorSelection("/user/WhatsMyTypeAgain");

            // Tell is void
            whatsMyTypeAgainActor.Tell("I'm 30");
            whatsMyTypeAgainActor.Tell("I'm 31"); // This message is ignored since the Actor's behavior has changed
            whatsMyTypeAgainActor.Tell(30);

            Console.ReadKey();
            ReceiveActorSystem.Shutdown();
            ReceiveActorSystem.AwaitTermination();

            Console.ReadKey();
        }
开发者ID:DeonHeyns,项目名称:Exploring-Akka-Dot-NET,代码行数:29,代码来源:Program.cs

示例3: MainWindow_Loaded

 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     system = ActorSystem.Create("MyClientSystem");
     serverActor = system.ActorSelection("akka.tcp://[email protected]:8081/user/MyServerActor");
     uiActor = system.ActorOf(Props.Create(() => new UIActor(this.textBox)), "MyClient");
     clientActor = system.ActorOf(Props.Create(() => new ClientActor(serverActor, uiActor)), Guid.NewGuid().ToString());
 }
开发者ID:billyxing,项目名称:AkkaNetRemoteTest,代码行数:7,代码来源:MainWindow.xaml.cs

示例4: Main

        static void Main(string[] args)
        {
            // Akka prefers creation of objects via factories
            // this is due to the fact that internally Akka does a lot of system internally
            UntypedActorSystem = ActorSystem.Create("UntypedActorSystem");
            Console.WriteLine("Actor system created");

            // Akka uses the movie industry to name a few items
            // To create an Actor you use the Props class
            Props whatsMyTypeAgainProps = Props.Create<WhatsMyTypeAgainActor>();

            // ActorOf will create the Actor
            // You can get a reference to the Actor using the ActorOf which returns an IActorRef
            UntypedActorSystem.ActorOf(whatsMyTypeAgainProps, "WhatsMyTypeAgain");

            // Alternatively you can use ActorSelection and a path to the Actor
            ActorSelection whatsMyTypeAgainActor = UntypedActorSystem.ActorSelection("/user/WhatsMyTypeAgain");

            // Tell is void
            whatsMyTypeAgainActor.Tell("I'm 30");

            // Ask with return a value (request response)
            var askTask = whatsMyTypeAgainActor.Ask<int>("Hey what's my age again?");
            Task.WaitAll(askTask);
            Console.WriteLine(askTask.Result);

            Console.ReadKey();
            UntypedActorSystem.Shutdown();
            UntypedActorSystem.AwaitTermination();
        }
开发者ID:DeonHeyns,项目名称:Exploring-Akka-Dot-NET,代码行数:30,代码来源:Program.cs

示例5: Main

        static void Main(string[] args)
        {
            _exploringRemotingActorSystem = ActorSystem.Create("ExploringRemotingActorSystem");
            ColorConsole.WriteLineGreen("Created the Local ExploringRemotingActorSystem. " +
                                        "RandomTextCoordinatorActor will live here and deploy RandomTextActors to the remote instance");

            Props randomTextActorCoordinatorProps = Props.Create<RandomTextCoordinatorActor>();
            _exploringRemotingActorSystem.ActorOf(randomTextActorCoordinatorProps, "RandomTextCoordinator");
            ColorConsole.WriteLineGreen("Created RandomTextCoordinator");

            var random = new Random(0);

            do
            {
                Thread.Sleep(500);
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.DarkGray;
                ColorConsole.WriteLineGray("Hit enter to receive random text...");

                var input = Console.ReadLine();
                if (input == "q")
                {
                    return;
                }

                for (int i = 0; i < 10000; i++)
                {
                    Task.Run(() =>
                    {
                        RandomTextMessage rtm = new RandomTextMessage(random.Next(0, 5));
                        _exploringRemotingActorSystem.ActorSelection("/user/RandomTextCoordinator").Tell(rtm);
                    });
                }
            } while (true);
        }
开发者ID:DeonHeyns,项目名称:Exploring-Akka-Dot-NET,代码行数:35,代码来源:Program.cs

示例6: _init

 private void _init()
 {
     _log.Debug("初始化监听sina的作业");
     actorSystem = ActorSystem.Create(ConstantsHelper.AKKA_PATH_SERVER);
     // var path = String.Format("akka.tcp://{2}@localhost:8091/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation", ConstantsHelper.AKKA_PATH_SERVER);
     var path = String.Format("/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation");
     sinaActor = actorSystem.ActorSelection(path);
 }
开发者ID:jxcjean,项目名称:quanter,代码行数:8,代码来源:FetchSinaQuoteDataJob.cs

示例7: Main

        private static void Main(string[] args)
        {
            _movieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem");
            Console.WriteLine(string.Format("{0} started...", _movieStreamingActorSystem.Name));

            var playbackActorProps = Props.Create<PlaybackActor>();
            var playbackActorRef = _movieStreamingActorSystem.ActorOf(playbackActorProps, "Playback");

            do
            {
                ShortPause();

                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.DarkGray;
                ColorConsole.WriteLineGray("Enter a command and hit enter");

                var command = Console.ReadLine();

                if (command.StartsWith("play"))
                {
                    var userId = int.Parse(command.Split(',')[1]);
                    var movieTitle = command.Split(',')[2];

                    var message = new PlayMovieMessage(movieTitle, userId);
                    _movieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

                if (command.StartsWith("stop"))
                {
                    var userId = int.Parse(command.Split(',')[1]);

                    var message = new StopMovieMessage(userId);
                    _movieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

                if (command == "exit")
                {
                    _movieStreamingActorSystem.Shutdown();
                    _movieStreamingActorSystem.AwaitTermination();
                    ColorConsole.WriteLineGray("Actor system shutdown");
                    Console.ReadKey();
                    Environment.Exit(1);
                }

            } while (true);
        }
开发者ID:SaberZA,项目名称:AkkaDotNetExample,代码行数:46,代码来源:Program.cs

示例8: Main

        private static void Main(string[] args)
        {
            var builder = new ContainerBuilder();
            builder.RegisterType<SimpleTrendingMovieAnalyzer>().As<ITrendingMovieAnalyzer>();
            builder.RegisterType<TrendingMoviesActor>();
            var container = builder.Build();

            var logger = new LoggerConfiguration()
                .WriteTo.Seq("http://localhost:5341")
                .CreateLogger();

            Serilog.Log.Logger = logger;

            MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem");
            var resolver = new AutoFacDependencyResolver(container, MovieStreamingActorSystem);

            MovieStreamingActorSystem.ActorOf(Props.Create<PlaybackActor>(), "Playback");

            do
            {
                ShortPause();

                Console.WriteLine();
                Console.WriteLine("enter a command and hit enter");

                var command = Console.ReadLine();

                if (command.StartsWith("play"))
                {
                    int userId = int.Parse(command.Split(',')[1]);
                    string movieTitle = command.Split(',')[2];

                    var message = new PlayMovieMessage(movieTitle, userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

                if (command.StartsWith("stop"))
                {
                    int userId = int.Parse(command.Split(',')[1]);

                    var message = new StopMovieMessage(userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

            } while (true);
        }
开发者ID:kenlefeb,项目名称:pluralsight-akka-di,代码行数:46,代码来源:Program.cs

示例9: Main

        static void Main(string[] args)
        {
            ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem");
            MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem");
            Console.WriteLine("Actor system created.");

            ColorConsole.WriteLineGray("Creating actor supervisory hierarchy");
            MovieStreamingActorSystem.ActorOf(Props.Create<PlaybackActor>(), "Playback");

            do
            {
                ShortPause();
                Console.WriteLine();
                Console.ForegroundColor = ConsoleColor.DarkGray;
                ColorConsole.WriteLineGray("Enter a command and hit enter");

                var command = Console.ReadLine();
                if (command.StartsWith("play"))
                {
                    int userId = int.Parse(command.Split(',')[1]);
                    string movieTitle = command.Split(',')[2];

                    var message = new PlayMovieMessage(movieTitle, userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

                if (command.StartsWith("stop"))
                {
                    int userId = int.Parse(command.Split(',')[1]);

                    var message = new StopMovieMessage(userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

                if (command.StartsWith("exit"))
                {
                    MovieStreamingActorSystem.Shutdown();
                    MovieStreamingActorSystem.AwaitTermination();
                    ColorConsole.WriteLineGray("Actor system shutdown");
                    Console.ReadKey();
                    Environment.Exit(1);
                }

            } while (true);
        }
开发者ID:jozbone,项目名称:akkademos,代码行数:45,代码来源:Program.cs

示例10: UntrustedSpec

        public UntrustedSpec()
            : base(@"
            akka.actor.provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
            akka.remote.untrusted-mode = on
            akka.remote.trusted-selection-paths = [""/user/receptionist"", ]    
            akka.remote.helios.tcp = {
                port = 0
                hostname = localhost
            }
            akka.loglevel = DEBUG
            ")
        {
            _client = ActorSystem.Create("UntrustedSpec-client", ConfigurationFactory.ParseString(@"
                akka.actor.provider =  ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
                 akka.remote.helios.tcp = {
                    port = 0
                    hostname = localhost
                }                
            ").WithFallback(Sys.Settings.Config));

            _address = Sys.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress;
            _receptionist = Sys.ActorOf(Props.Create(() => new Receptionist(TestActor)), "receptionist");

            _remoteDaemon = new Lazy<IActorRef>(() =>
            {
                var p = CreateTestProbe(_client);
                _client.ActorSelection(new RootActorPath(_address)/_receptionist.Path.Elements)
                    .Tell(new IdentifyReq("/remote"), p.Ref);
                return p.ExpectMsg<ActorIdentity>().Subject;
            });

            _target2 = new Lazy<IActorRef>(() =>
            {
                var p = CreateTestProbe(_client);
                _client.ActorSelection(new RootActorPath(_address)/_receptionist.Path.Elements)
                    .Tell(new IdentifyReq("child2"), p.Ref);

                var actorRef = p.ExpectMsg<ActorIdentity>().Subject;
                return actorRef;
            });


            EventFilter.Debug().Mute();
        }
开发者ID:juergenhoetzel,项目名称:akka.net,代码行数:44,代码来源:UntrustedSpec.cs

示例11: AkkaDataService

        // rename container ...
        public AkkaDataService(IUnityContainer container, IEventAggregator eventAggregator)
        {
            var config = ConfigurationFactory.ParseString(@"
            akka {
            actor {
            provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
            }
            remote {
            helios.tcp {
            transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
            applied-adapters = []
            transport-protocol = tcp
            port = 0
            hostname = localhost
            }
            }
            }
            ");

            _system = ActorSystem.Create("WebDB", config);
            _resolver = new UnityDependencyResolver(container, _system);

            var chatClient = _system.ActorOf(_resolver.Create<DBClientActor>(), "DBClientActor");
            _system.ActorSelection("akka.tcp://[email protected]:8081/user/DBEntityRoot");
            chatClient.Tell(new GetAllRequest("Party"));
            /*
                while (true) { System.Threading.Thread.Sleep(10); }

                    while (true)
                    {
                        var input = Console.ReadLine();
                        if (input.StartsWith("/"))
                        {
                            var parts = input.Split(' ');
                            var cmd = parts[0].ToLowerInvariant();
                            var rest = string.Join(" ", parts.Skip(1));

                            //if (cmd == "/nick")
                            //{
                            //    chatClient.Tell(new NickRequest
                            //    {
                            //        NewUsername = rest
                            //    });
                            //}
                        }
                        //else
                        //{
                        //    chatClient.Tell(new SayRequest()
                        //    {
                        //        Text = input,
                        //    });
                        //}
                    }
                }
                */
        }
开发者ID:jweimann,项目名称:webdb,代码行数:57,代码来源:AkkaDataService.cs

示例12: Main

        private static void Main(string[] args)
        {
            var container = new WindsorContainer();

            container.Register(Component.For<ITrendingMovieAnalyzer>().ImplementedBy<SimpleTrendingMovieAnalyzer>());
            container.Register(Component.For<TrendingMoviesActor>());

            MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem");

            IDependencyResolver resolver = new WindsorDependencyResolver(container, MovieStreamingActorSystem);

            MovieStreamingActorSystem.ActorOf(Props.Create<PlaybackActor>(), "Playback");

            do
            {
                ShortPause();

                Console.WriteLine();
                Console.WriteLine("enter a command and hit enter");

                var command = Console.ReadLine();

                if (command.StartsWith("play"))
                {
                    int userId = int.Parse(command.Split(',')[1]);
                    string movieTitle = command.Split(',')[2];

                    var message = new PlayMovieMessage(movieTitle, userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

                if (command.StartsWith("stop"))
                {
                    int userId = int.Parse(command.Split(',')[1]);

                    var message = new StopMovieMessage(userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

            } while (true);
        }
开发者ID:kenlefeb,项目名称:pluralsight-akka-di,代码行数:41,代码来源:Program.cs

示例13: Main

        private static void Main(string[] args)
        {
            var logger = new LoggerConfiguration()
                .WriteTo.Seq("http://localhost:5341")
                .MinimumLevel.Information()
                .CreateLogger();

            Serilog.Log.Logger = logger;

            MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem");
            MovieStreamingActorSystem.ActorOf(Props.Create<PlaybackActor>(), "Playback");

            do
            {
                ShortPause();

                Console.WriteLine();
                Console.WriteLine("enter a command and hit enter");

                var command = Console.ReadLine();

                if (command.StartsWith("play"))
                {
                    int userId = int.Parse(command.Split(',')[1]);
                    string movieTitle = command.Split(',')[2];

                    var message = new PlayMovieMessage(movieTitle, userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

                if (command.StartsWith("stop"))
                {
                    int userId = int.Parse(command.Split(',')[1]);

                    var message = new StopMovieMessage(userId);
                    MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message);
                }

            } while (true);
        }
开发者ID:kenlefeb,项目名称:pluralsight-akka-di,代码行数:40,代码来源:Program.cs

示例14: Main

        static void Main(string[] args)
        {
            _actorSystem = ActorSystem.Create("coach");

            var actor = _actorSystem.ActorOf(Props.Empty.WithRouter(FromConfig.Instance), "event");
            _actorSystem.ActorOf(Props.Create<StartSupervisorActor>(actor), "supervisor");
            var startActor = _actorSystem.ActorSelection("/user/supervisor/start");

            var counter = 0;

            Console.WriteLine("Node 1 started...");
            Console.WriteLine("Press [ESC] to stop, [L] 1k messages, [H] for 10k, [M] for 100k or any other key to send a single message");
            while (true)
            {
                ConsoleKeyInfo result = Console.ReadKey();
                if (result.Key == ConsoleKey.Escape)
                {
                    break;
                }

                switch (result.Key)
                {
                    case ConsoleKey.L:
                    {
                        counter = TransmitMessageManyTimes(counter, startActor, 1000);
                        break;
                    }
                    case ConsoleKey.H:
                    {
                        counter = TransmitMessageManyTimes(counter, startActor, 10000);
                        break;
                    }
                    case ConsoleKey.M:
                    {
                        counter = TransmitMessageManyTimes(counter, startActor, 100000);
                        break;
                    }
                    default:
                    {
                        counter = TransmitMessageManyTimes(counter, startActor, 1);
                        break;
                    }
                }

                //actor.Tell(new AuditMessage("Hi - " + counter.ToString()));
            }

            Console.ReadKey();
        }
开发者ID:garrardkitchen,项目名称:akka-clustering,代码行数:49,代码来源:Program.cs

示例15: CreaContexto

        public static void CreaContexto()
        {
            ActorSystem = ActorSystem.Create("SistemaPanelComentario");

            //Actores.PanelComentarioControlador = 
            //    ActorSystem.ActorSelection("akka.tcp://[email protected]:8091/user/PanelComentarioControlador")
            //    .ResolveOne(TimeSpan.FromSeconds(3))
            //    .Result;

            Actores.CuentaAhorroControlador =
                ActorSystem.ActorSelection("akka.tcp://[email protected]:8091/user/CuentaAhorroControlador")
                .ResolveOne(TimeSpan.FromSeconds(3))
                .Result;

            //Actores.PanelRespuestaControlador = ActorSystem.ActorOf<PanelRespuestaActor>();
            Actores.CuentaAhorroRespuestaControlador = ActorSystem.ActorOf<CuentaAhorroActorLocal>();
        }
开发者ID:berczeck,项目名称:.Net,代码行数:17,代码来源:SistemaPanelComentario.cs


注:本文中的ActorSystem.ActorSelection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。