Exemple #1
0
        public void doMove(Player player, Prisoner prisoner, int rowOrCol, int row, int col)
        {
            Console.WriteLine("moving " + prisoner + " to " + (rowOrCol == Alcatraz.Alcatraz.ROW ? "row" : "col") + " " + (rowOrCol == Alcatraz.Alcatraz.ROW ? row : col));
            Console.WriteLine("ID" + player.Id);
            ActorSelection[] remoteActors = ClientClass.getRemoteChatActorClient();

            for (int i = 0; i < remoteActors.Length; i++)
            {
                remoteActors[i].Tell(this.convertMove(player, prisoner, rowOrCol, row, col), clientClass.getChild());
            }
        }
Exemple #2
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();
                }
            }
        }