Example #1
0
        //static void Main(string[] args)
        //{
        //    using (var system = ActorSystem.Create("Client", ConfigurationFactory.ParseString(@"
        //        akka {
        //            actor{
        //                provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
        //                deployment {
        //                /localecho {
        //                        local = ""akka.tcp://Server@localhost:555""
        //                    }
        //                    /remoteecho {
        //                        remote = ""akka.tcp://Server@localhost:8090""
        //                    }
        //                }
        //            }
        //            remote {
        //                helios.tcp {
        //              port = 550
        //              hostname = localhost
        //                }
        //            }
        //        }")))
        //    {
        //        var remoteAddress = Address.Parse("akka.tcp://Server@localhost:8090");
        //        var remoteEcho1 = system.ActorOf(Props.Create(() => new EchoActor()), "remoteecho"); //
        //        var local = system.ActorOf(Props.Create(() => new EchoActor()), "localecho"); //
        //        var remoteEcho2 =
        //            system.ActorOf(
        //                Props.Create(() => new EchoActor())
        //                    .WithDeploy(Deploy.None.WithScope(new RemoteScope(remoteAddress))), "coderemoteecho");

        //        //system.ActorOf(Props.Create(() => new HelloActor(remoteEcho1)));
        //        ////system.ActorOf(Props.Create(() => new HelloActor(remoteEcho2)));

        //        //system.ActorSelection("/user/remoteecho").Tell(new Hello("hi from selection!"));

        //        system.ActorOf(Props.Create(() => new ClientActor(remoteEcho2)));
        //        //system.ActorSelection("/user/remoteecho").Ask(new Hello("heloooooo"));
        //        system.ActorSelection("/user/remoteecho").Tell(new Client(1, "22", 2, "", 3333), local);

        //        Console.ReadKey();
        //    }
        //}

        //static void Main(string[] args)
        //{
        //    string actorSystemName = "peer1";
        //    Console.Title = actorSystemName;

        //    try
        //    {
        //        using (var actorSystem = ActorSystem.Create(actorSystemName))
        //        {
        //            var localChatActor = actorSystem.ActorOf(Props.Create<MessagingActor>(), "MessagingActor");
        //            var child = actorSystem.ActorOf(Props.Create<MessagingActor>(), "MessagingActorChild");

        //            string remoteActorAddress = "akka.tcp://peer2@localhost:5249/user/MessagingActor";
        //            var remoteChatActor = actorSystem.ActorSelection(remoteActorAddress);

        //            if (remoteChatActor != null)
        //            {
        //                string line = string.Empty;
        //                while (line != null)
        //                {
        //                    line = Console.ReadLine();
        //                    remoteChatActor.Tell(line, child);
        //                }
        //            }
        //            else
        //            {
        //                Console.WriteLine("Could not get remote actor ref");
        //                Console.ReadLine();
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Console.WriteLine(ex);
        //    }
        //}


        static void Main(string[] args)
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            Alcatraz.Alcatraz player = new Alcatraz.Alcatraz();

            string actorSystemName = "client2";

            Console.Title = actorSystemName;
            try
            {
                using (var actorSystem = ActorSystem.Create(actorSystemName))
                {
                    var localChatActor = actorSystem.ActorOf(Props.Create <EchoActor>(), "EchoActor");
                    //var child = actorSystem.ActorOf(Props.Create<EchoActor>(), "EchoActorClient2Child");
                    string remoteActorAddressClient1 = "akka.tcp://client1@localhost:1111/user/EchoActor";
                    //string remoteActorAddressClient2 = "akka.tcp://client3@localhost:3333/user/EchoActor";
                    Players players = new Players(new string[10, 10]);
                    players.players[1, 1] = actorSystemName;

                    var remoteChatActorClient1 = actorSystem.ActorSelection(remoteActorAddressClient1);
                    //var remoteChatActorClient2 = actorSystem.ActorSelection(remoteActorAddressClient2);
                    if (remoteChatActorClient1 != null /*&& remoteChatActorClient2 != null*/)
                    {
                        string line = string.Empty;
                        while (line != null)
                        {
                            line = Console.ReadLine();
                            remoteChatActorClient1.Tell(players, localChatActor);
                            //remoteChatActorClient2.Tell(players, child);

                            //remoteChatActorClient1.Tell(line, child);
                            //remoteChatActorClient2.Tell(line, child);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Could not get remote actor ref");
                        Console.ReadLine();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Example #2
0
 public Client(Alcatraz.Alcatraz alcatraz, ClientData clientData)
 {
     this.alcatraz   = alcatraz;
     this.clientData = clientData;
 }
Example #3
0
        //  [STAThread]
        public static void Main(String[] args)
        {
            Console.WriteLine("To cancel the registration enter 'delete'");
            Console.WriteLine("Please choose a player name:");
            playerName = Console.ReadLine();

            while (playerName == "")
            {
                Console.WriteLine("Your name cannot be empty. Please choose a player name:");
                playerName = Console.ReadLine();
            }


            try
            {
                startActorSystem("alcatraz");

                // Setup an actor that will handle deadletter type messages
                var deadletterWatchMonitorProps = Props.Create(() => new DeadletterMonitor());
                var deadletterWatchActorRef     = mainActorSystem.ActorOf(deadletterWatchMonitorProps, "DeadLetterMonitoringActor");

                // subscribe to the event stream for messages of type "DeadLetter"
                mainActorSystem.EventStream.Subscribe(deadletterWatchActorRef, typeof(DeadLetter));

                var localChatActor = mainActorSystem.ActorOf(Props.Create <GameActor>(), "GameActor");


                string remoteActorAddressClient1 = "akka.tcp://alcatraz@localhost:5555/user/RegisterActor";
                var    remoteChatActorClient1    = mainActorSystem.ActorSelection(remoteActorAddressClient1);

                if (remoteChatActorClient1 != null)
                {
                    remoteChatActorClient1.Tell(playerName, localChatActor);

                    string line = string.Empty;
                    while (line != null)
                    {
                        line = Console.ReadLine();

                        if (line == "delete")
                        {
                            remoteChatActorClient1.Tell("delete|" + playerName, localChatActor);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Could not get remote actor ref");
                    Console.ReadLine();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            clientClass = new ClientClass(data, playerName);
            clientItem  = clientClass.initializeClient(1, data.Length + 1, data);

            t1 = new Test();
            t1.setNumPlayer(data.Length + 1);


            // line = Console.ReadLine();
            line = "";
            //System.Threading.Thread.Sleep(5000);

            while (line != null)
            {
                line = Console.ReadLine();
                if (line == "start")
                {
                    clientAlcatraz = clientItem.alcatraz;
                    clientItem.alcatraz.showWindow();
                    clientAlcatraz.addMoveListener(t1);
                    clientItem.alcatraz.getWindow().FormClosed += new FormClosedEventHandler(Test_FormClosed);
                    clientItem.alcatraz.start();
                    Application.Run();
                }
            }
        }
Example #4
0
 public void setOther(int i, Alcatraz.Alcatraz t)
 {
     other[i] = t;
 }